_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
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; } $node->addChild($this->expr(), 'expression'); $this->endStatement($node); 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)) { $node->addChild($expr, 'key'); $node->addChild($this->expr(), 'value'); } else { $node->addChild($expr, 'value'); } return $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()); } while ($this->tryMatch(',', $variables)); $node->addChild($variables, 'variables'); $this->endStatement($node); return $node; }
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(); } else { $node = new VariableVariableNode(); $this->mustMatch('$', $node); $node->addChild($this->variable()); return $node; } } throw new ParserException( $this->filename, $this->iterator->getLineNumber(), $this->iterator->getColumnNumber(), 'expected a global variable (eg. T_VARIABLE)'); }
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()); } while ($this->tryMatch(',', $expressions)); $node->addChild($expressions, 'expressions'); $this->endStatement($node); return $node; }
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'); $node->addChild($arguments, 'arguments'); do { $arguments->addChild($this->variable()); } while ($this->tryMatch(',', $arguments)); $this->mustMatch(')', $node, 'closeParen', FALSE); $statement_node->addChild($node, 'functionCall'); $this->endStatement($statement_node); return $statement_node; }
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'); } $this->mustMatch(')', $node, 'closeParen', FALSE, TRUE); if ($this->tryMatch(':', $node, NULL, FALSE, TRUE)) { $node->addChild($this->innerStatementListNode(T_ENDFOREACH), 'body'); $this->mustMatch(T_ENDFOREACH, $node); $this->endStatement($node); return $node; } else { $node->addChild($this->statement(), 'body'); return $node; } }
php
{ "resource": "" }
q1907
Parser.foreachVariable
train
private function foreachVariable() { if ($this->currentType === T_LIST) { return $this->_list(); } else { if ($this->currentType === '&') { return $this->writeVariable(); } else { return $this->variable(); } } }
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 ($this->tryMatch(':', $node, NULL, FALSE, TRUE)) { $node->addChild($this->innerStatementListNode(T_ENDDECLARE), 'body'); $this->mustMatch(T_ENDDECLARE, $node); $this->endStatement($node); return $node; } else { $node->addChild($this->statement(), 'body'); return $node; } }
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, 'closeParen', FALSE, TRUE); $catch_node->addChild($this->innerStatementBlock(), 'body'); $node->addChild($catch_node); $catch_node = new CatchNode(); } if ($this->tryMatch(T_FINALLY, $node)) { $node->addChild($this->innerStatementBlock(), 'finally'); } return $node; }
php
{ "resource": "" }
q1910
Parser._throw
train
private function _throw() { $node = new ThrowStatementNode(); $this->mustMatch(T_THROW, $node); $node->addChild($this->expr(), 'expression'); $this->endStatement($node); return $node; }
php
{ "resource": "" }
q1911
Parser._goto
train
private function _goto() { $node = new GotoStatementNode(); $this->mustMatch(T_GOTO, $node); $this->mustMatch(T_STRING, $node, 'label'); $this->endStatement($node); return $node; }
php
{ "resource": "" }
q1912
Parser.exprList
train
private function exprList() { $node = new CommaListNode(); do { $node->addChild($this->expr()); } while ($this->tryMatch(',', $node)); return $node; }
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 === '[') { $node = new ArrayNode(); $this->mustMatch('[', $node); $this->staticArrayPairList($node, ']'); $this->mustMatch(']', $node, NULL, TRUE); return $node; } else { return $this->expr(TRUE); } }
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 === T_STATIC) { $static_node = $this->mustMatchToken(T_STATIC); $colon_node = new PartialNode(); $this->mustMatch(T_DOUBLE_COLON, $colon_node); if ($this->currentType === T_CLASS) { return $this->classNameScalar($static_node, $colon_node); } else { $class_constant = $this->mustMatchToken(T_STRING); return $this->classConstant($static_node, $colon_node, $class_constant); } } elseif ($this->currentType === T_START_HEREDOC) { $node = new HeredocNode(); $this->mustMatch(T_START_HEREDOC, $node); if ($this->tryMatch(T_END_HEREDOC, $node)) { return $node; } $this->mustMatch(T_ENCAPSED_AND_WHITESPACE, $node); $this->mustMatch(T_END_HEREDOC, $node); return $node; } else { return NULL; } }
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())) { $expression_nodes[] = $operand; } else { throw new ParserException( $this->filename, $this->iterator->getLineNumber(), $this->iterator->getColumnNumber(), "invalid expression"); } } return $this->expressionParser->parse($expression_nodes, $this->filename); }
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); $operator->colon = $colon; return $operator; } } elseif ($token_type === '=' && $this->currentType === '&') { $by_ref_node = new PartialNode(); $this->mustMatch('&', $by_ref_node); return OperatorFactory::createAssignReferenceOperator($operator, $by_ref_node); } return $operator; } return NULL; }
php
{ "resource": "" }
q1917
Parser.backtick
train
private function backtick() { $node = new BacktickNode(); $this->mustMatch('`', $node); $this->encapsList($node, '`', TRUE); $this->mustMatch('`', $node, NULL, TRUE); return $node; }
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); } else { $this->mustMatch(T_VARIABLE, $lexical_vars_node, NULL, TRUE); } } while ($this->tryMatch(',', $lexical_vars_node)); $node->addChild($lexical_vars_node, 'lexicalVariables'); $this->mustMatch(')', $node, 'lexicalCloseParen'); } $this->matchHidden($node); $node->addChild($this->innerStatementBlock(), 'body'); return $node; }
php
{ "resource": "" }
q1919
Parser.newExpr
train
private function newExpr() { $node = new NewNode(); $this->mustMatch(T_NEW, $node); $node->addChild($this->classNameReference(), 'className'); if ($this->currentType === '(') { $this->functionCallParameterList($node); } return $node; }
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; } default: if ($this->currentType === '$' && !$this->isLookAhead('{')) { return $this->dynamicClassNameReference($this->indirectReference()); } $var_node = $this->referenceVariable(); if ($this->currentType === T_DOUBLE_COLON) { $var_node = $this->staticMember($var_node); } return $this->dynamicClassNameReference($var_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); $node->addChild($this->indirectReference(), 'memberName'); return $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); $node->addChild($this->objectProperty(), 'property'); $object = $this->offsetVariable($node); } return $node; }
php
{ "resource": "" }
q1923
Parser.arrayPairList
train
private function arrayPairList(ArrayNode $node, $terminator) { $elements = new CommaListNode(); do { if ($this->currentType === $terminator) { break; } $this->matchHidden($elements); $elements->addChild($this->arrayPair()); } while ($this->tryMatch(',', $elements, NULL, TRUE)); $node->addChild($elements, 'elements'); }
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); $pair->addChild($this->staticScalar(), 'value'); $elements->addChild($pair); } else { $elements->addChild($value); } } while ($this->tryMatch(',', $elements, NULL, TRUE)); $node->addChild($elements, 'elements'); }
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 === '&') { $node->addChild($this->writeVariable(), 'value'); } else { $node->addChild($this->expr(), 'value'); } } return $node; }
php
{ "resource": "" }
q1926
Parser.writeVariable
train
private function writeVariable() { $node = new ReferenceVariableNode(); $this->mustMatch('&', $node); $node->addChild($this->variable(), 'variable'); return $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)) { $node->addChild($this->encapsVar()); } } while ($this->currentType !== NULL && $this->currentType !== $terminator) { $this->tryMatch(T_ENCAPSED_AND_WHITESPACE, $node) || $node->addChild($this->encapsVar()); } }
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( $this->filename, $this->iterator->getLineNumber(), $this->iterator->getColumnNumber(), 'expected encaps_var_offset (T_STRING or T_NUM_STRING or T_VARIABLE)'); } $node->addChild($this->tryMatchToken($offset_types)); $this->mustMatch(']', $node); } elseif ($this->tryMatch(T_OBJECT_OPERATOR, $node)) { $this->mustMatch(T_STRING, $node); } return $node; } throw new ParserException( $this->filename, $this->iterator->getLineNumber(), $this->iterator->getColumnNumber(), 'expected encaps variable'); }
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 { return $this->classConstant($class_name, $colon_node, $class_constant); } } elseif ($this->currentType === T_CLASS) { return $this->classNameScalar($class_name, $colon_node); } else { return $this->classVariable($class_name, $colon_node); } }
php
{ "resource": "" }
q1930
Parser.classConstant
train
private function classConstant($class_name, $colon_node, $class_constant) { $node = new ClassConstantLookupNode(); $node->addChild($class_name, 'className'); $node->mergeNode($colon_node); $node->addChild($class_constant, 'constantName'); return $node; }
php
{ "resource": "" }
q1931
Parser.classMethodCall
train
private function classMethodCall($class_name, $colon_node, $method_name) { $node = new ClassMethodCallNode(); $node->addChild($class_name, 'className'); $node->mergeNode($colon_node); $node->addChild($method_name, 'methodName'); $this->functionCallParameterList($node); return $this->objectDereference($this->arrayDeference($node)); }
php
{ "resource": "" }
q1932
Parser.classNameScalar
train
private function classNameScalar($class_name, $colon_node) { $node = new ClassNameScalarNode(); $node->addChild($class_name, 'className'); $node->mergeNode($colon_node); $this->mustMatch(T_CLASS, $node, NULL, TRUE); return $node; }
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); } elseif (!($var instanceof VariableVariableNode) && $this->currentType === T_DOUBLE_COLON) { return $this->varClass($var); } else { return $this->objectDereference($var); } } throw new ParserException( $this->filename, $this->iterator->getLineNumber(), $this->iterator->getColumnNumber(), "expected variable"); }
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); return $this->classMethodCall($class_name, $colon_node, $method_name); } else { return $this->classVariable($class_name, $colon_node); } }
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 { $node = new FunctionCallNode(); } $node->addChild($function_reference, 'name'); } $this->functionCallParameterList($node); return $this->objectDereference($this->arrayDeference($node)); }
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); $node->addChild($object_property, 'property'); $node = $this->offsetVariable($node); if ($this->currentType === '(') { $call = new CallbackCallNode(); $call->addChild($node, 'callback'); $this->functionCallParameterList($call); $node = $this->arrayDeference($call); } } $object = $node; } return $object; }
php
{ "resource": "" }
q1937
Parser.objectProperty
train
private function objectProperty() { if ($this->currentType === T_STRING) { return $this->mustMatchToken(T_STRING); } elseif ($this->currentType === '{') { return $this->bracesExpr(); } else { return $this->indirectReference(); } }
php
{ "resource": "" }
q1938
Parser.indirectReference
train
private function indirectReference() { if ($this->currentType === '$' && !$this->isLookAhead('{')) { $node = new VariableVariableNode(); $this->mustMatch('$', $node); $node->addChild($this->indirectReference(), 'variable'); return $node; } return $this->referenceVariable(); }
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 === '[') { $node = new ArrayLookupNode(); $node->addChild($var, 'array'); $this->dimOffset($node); return $this->offsetVariable($node); } else { return $var; } }
php
{ "resource": "" }
q1940
Parser._compoundVariable
train
private function _compoundVariable() { $node = new CompoundVariableNode(); $this->mustMatch('$', $node); $this->mustMatch('{', $node); $node->addChild($this->expr(), 'expression'); $this->mustMatch('}', $node, NULL, TRUE); return $node; }
php
{ "resource": "" }
q1941
Parser.bracesExpr
train
private function bracesExpr() { $node = new NameExpressionNode(); $this->mustMatch('{', $node); $node->addChild($this->expr()); $this->mustMatch('}', $node, NULL, TRUE); return $node; }
php
{ "resource": "" }
q1942
Parser.dimOffset
train
private function dimOffset(ArrayLookupNode $node) { $this->mustMatch('[', $node); if ($this->currentType !== ']') { $node->addChild($this->expr(), 'key'); } $this->mustMatch(']', $node, NULL, TRUE); }
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 { do { $arguments->addChild($this->functionCallParameter()); } while ($this->tryMatch(',', $arguments)); } $this->mustMatch(')', $node, 'closeParen', TRUE); }
php
{ "resource": "" }
q1944
Parser.functionCallParameter
train
private function functionCallParameter() { switch ($this->currentType) { case '&': return $this->writeVariable(); case T_ELLIPSIS: $node = new SplatNode(); $this->mustMatch(T_ELLIPSIS, $node); $node->addChild($this->expr(), 'expression'); return $node; default: return $this->expr(); } }
php
{ "resource": "" }
q1945
Parser.arrayDeference
train
private function arrayDeference(Node $node) { while ($this->currentType === '[') { $n = $node; $node = new ArrayLookupNode(); $node->addChild($n, 'array'); $this->dimOffset($node); } return $node; }
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); $node->addChild($name_node, 'name'); $this->parameterList($node); $this->matchHidden($node); $this->body($node); return $node; }
php
{ "resource": "" }
q1947
Parser.parameterList
train
private function parameterList(ParentNode $parent) { $node = new CommaListNode(); $this->mustMatch('(', $parent, 'openParen'); $parent->addChild($node, 'parameters'); if ($this->tryMatch(')', $parent, 'closeParen', TRUE)) { return; } do { $node->addChild($this->parameter()); } while ($this->tryMatch(',', $node)); $this->mustMatch(')', $parent, 'closeParen', TRUE); }
php
{ "resource": "" }
q1948
Parser.parameter
train
private function parameter() { $node = new ParameterNode(); if ($type = $this->optionalTypeHint()) { $node->addChild($type, 'typeHint'); } $this->tryMatch('&', $node, 'reference'); $this->tryMatch(T_ELLIPSIS, $node, 'variadic'); $this->mustMatch(T_VARIABLE, $node, 'name', TRUE); if ($this->tryMatch('=', $node)) { $node->addChild($this->staticScalar(), 'value'); } return $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; } elseif (in_array($this->currentType, self::$namespacePathTypes)) { return $this->name(); } return NULL; }
php
{ "resource": "" }
q1950
Parser.innerStatementList
train
private function innerStatementList(StatementBlockNode $parent, $terminator) { while ($this->currentType !== NULL && $this->currentType !== $terminator) { $this->matchHidden($parent); $parent->addChild($this->innerStatement()); } }
php
{ "resource": "" }
q1951
Parser.innerStatementBlock
train
private function innerStatementBlock() { $node = new StatementBlockNode(); $this->mustMatch('{', $node, NULL, FALSE, TRUE); $this->innerStatementList($node, '}'); $this->mustMatch('}', $node, NULL, TRUE, TRUE); return $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"); case T_ABSTRACT: case T_FINAL: case T_CLASS: return $this->classDeclaration(); case T_INTERFACE: return $this->interfaceDeclaration(); case T_TRAIT: return $this->traitDeclaration(); default: if ($this->currentType === T_FUNCTION && $this->isLookAhead(T_STRING, '&')) { return $this->functionDeclaration(); } return $this->statement(); } }
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 } $this->mustMatch(T_STRING, $node, NULL, TRUE); while ($this->tryMatch(T_NS_SEPARATOR, $node)) { $this->mustMatch(T_STRING, $node, NULL, TRUE); } return $node; }
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, '}'); $this->mustMatch('}', $body); $node->addChild($body, 'body'); } else { $this->endStatement($node); $this->matchHidden($node); $node->addChild($this->namespaceBlock(), 'body'); } return $node; }
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; } $node->addChild($this->topStatement()); $this->matchHidden($node); } $this->matchHidden($node); return $node; }
php
{ "resource": "" }
q1956
Parser.namespaceName
train
private function namespaceName() { $node = new NameNode(); $this->mustMatch(T_STRING, $node, NULL, TRUE); while ($this->tryMatch(T_NS_SEPARATOR, $node)) { $this->mustMatch(T_STRING, $node, NULL, TRUE); } return $node; }
php
{ "resource": "" }
q1957
Parser.useBlock
train
private function useBlock() { $node = new UseDeclarationBlockNode(); $node->addChild($this->_use()); while ($this->currentType === T_USE) { $this->matchHidden($node); $node->addChild($this->_use()); } return $node; }
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 { $declarations->addChild($this->useDeclaration()); } while ($this->tryMatch(',', $declarations)); $node->addChild($declarations, 'declarations'); $this->endStatement($node); return $node; }
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(); } $declaration->addChild($node, 'name'); if ($this->tryMatch(T_AS, $declaration)) { $this->mustMatch(T_STRING, $declaration, 'alias', TRUE)->getText(); } return $declaration; }
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, TRUE); $is_abstract = $node->getAbstract() !== NULL; while ($this->currentType !== NULL && $this->currentType !== '}') { $this->matchHidden($statement_block); $statement_block->addChild($this->classStatement($is_abstract)); } $this->mustMatch('}', $statement_block, NULL, TRUE, TRUE); $node->addChild($statement_block, 'statements'); return $node; }
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()) { throw new ParserException( $this->filename, $this->iterator->getLineNumber(), $this->iterator->getColumnNumber(), "members can not be declared final"); } $node = new ClassMemberListNode(); $node->mergeNode($doc_comment); $node->mergeNode($modifiers); $members = new CommaListNode(); do { $members->addChild($this->classMember()); } while ($this->tryMatch(',', $members)); $node->addChild($members, 'members'); $this->endStatement($node); return $node; }
php
{ "resource": "" }
q1962
Parser.classMember
train
private function classMember() { $node = new ClassMemberNode(); $this->mustMatch(T_VARIABLE, $node, 'name', TRUE); if ($this->tryMatch('=', $node)) { $node->addChild($this->staticScalar(), 'value'); } return $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'); $this->parameterList($node); if ($modifiers->getAbstract()) { $this->endStatement($node); return $node; } $this->matchHidden($node); $this->body($node); return $node; }
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 !== '}') { $adaptations->addChild($this->traitAdaptation()); $this->matchHidden($adaptations); } $node->addChild($adaptations, 'adaptations'); $this->mustMatch('}', $node, NULL, TRUE, TRUE); return $node; } $this->endStatement($node); return $node; }
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 = $node; $node = new TraitPrecedenceNode(); $node->addChild($method_reference_node, 'traitMethodReference'); $this->mustMatch(T_INSTEADOF, $node); $trait_names = new CommaListNode(); do { $trait_names->addChild($this->name()); } while ($this->tryMatch(',', $trait_names)); $node->addChild($trait_names, 'traitNames'); $this->endStatement($node); return $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, $node, 'alias'); $this->endStatement($node); return $node; } $this->mustMatch(T_STRING, $node, 'alias'); $this->endStatement($node); return $node; }
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); while ($this->currentType !== NULL && $this->currentType !== '}') { $this->matchHidden($statement_block); if ($this->currentType === T_CONST) { $statement_block->addChild($this->_const()); } else { $statement_block->addChild($this->interfaceMethod()); } } $this->mustMatch('}', $statement_block, NULL, TRUE, TRUE); $node->addChild($statement_block, 'statements'); return $node; }
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." ); } $this->mustMatch($this->currentType, $node, 'visibility'); } !$is_static && $this->tryMatch(T_STATIC, $node, 'static'); $this->mustMatch(T_FUNCTION, $node); $this->tryMatch('&', $node, 'reference'); $this->mustMatch(T_STRING, $node, 'name'); $this->parameterList($node); $this->endStatement($node); return $node; }
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 interfaces.' ); } $this->matchHidden($node); $statement_block = new StatementBlockNode(); $this->mustMatch('{', $statement_block, NULL, FALSE, TRUE); while ($this->currentType !== NULL && $this->currentType !== '}') { $this->matchHidden($statement_block); $statement_block->addChild($this->classStatement(TRUE)); } $this->mustMatch('}', $statement_block, NULL, TRUE, TRUE); $node->addChild($statement_block, 'statements'); return $node; }
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) { $this->currentType = $this->current->getType(); } else { $this->currentType = NULL; } }
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 instanceof HiddenNode) && $token->getType() !== $skip_type) { return $expected_type === $token->getType(); } } return FALSE; }
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()) ->setChapo($event->getChapo()) ->setPostscriptum($event->getPostscriptum()) ->save($con) ; $content->setDefaultFolder($event->getDefaultFolder()); $event->setContent($content); $con->commit(); } catch (PropelException $e) { $con->rollBack(); throw $e; } } }
php
{ "resource": "" }
q1973
Content.updateSeo
train
public function updateSeo(UpdateSeoEvent $event, $eventName, EventDispatcherInterface $dispatcher) { return $this->genericUpdateSeo(ContentQuery::create(), $event, $dispatcher); }
php
{ "resource": "" }
q1974
Content.viewCheck
train
public function viewCheck(ViewCheckEvent $event, $eventName, EventDispatcherInterface $dispatcher) { if ($event->getView() == 'content') { $content = ContentQuery::create() ->filterById($event->getViewId()) ->filterByVisible(1) ->count(); if ($content == 0) { $dispatcher->dispatch(TheliaEvents::VIEW_CONTENT_ID_NOT_VISIBLE, $event); } } }
php
{ "resource": "" }
q1975
GenerateSQLCommand.initParser
train
protected function initParser() { $this->parser->unregisterPlugin('function', 'intl'); $this->parser->registerPlugin('function', 'intl', [$this, 'translate']); $this->parser->assign("locales", $this->locales); }
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)) { $translation = ($inString) ? '' : "NULL"; } else { $translation = $this->con->quote($translation); // remove quote if ($inString) { $translation = substr($translation, 1, -1); } } } return $translation; }
php
{ "resource": "" }
q1977
Import.importChangePosition
train
public function importChangePosition(UpdatePositionEvent $updatePositionEvent, $eventName, EventDispatcherInterface $dispatcher) { $this->handler->getImport($updatePositionEvent->getObjectId(), true); $this->genericUpdatePosition(new ImportQuery, $updatePositionEvent, $dispatcher); }
php
{ "resource": "" }
q1978
Import.importCategoryChangePosition
train
public function importCategoryChangePosition(UpdatePositionEvent $updatePositionEvent, $eventName, EventDispatcherInterface $dispatcher) { $this->handler->getCategory($updatePositionEvent->getObjectId(), true); $this->genericUpdatePosition(new ImportCategoryQuery, $updatePositionEvent, $dispatcher); }
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) { throw new \RuntimeException(sprintf('%s module does not exists. Try to refresh first.', $matches[1])); } $this->modulesList[] = $matches[1]; $this->positionsList[] = $matches[2]; }
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 { $isRelative = true; } } if ($isAbsolute && $isRelative) { /** @var FormatterHelper $formatter */ $formatter = $this->getHelper('formatter'); $formattedBlock = $formatter->formatBlock( 'Mix absolute and relative positions may produce unexpected results !', 'bg=yellow;fg=black', true ); $output->writeln($formattedBlock); /** @var QuestionHelper $helper */ $helper = $this->getHelper('question'); $question = new ConfirmationQuestion('<question>Do you want to continue ? y/[n]<question>', false); return $helper->ask($input, $output, $question); } return true; }
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() === $class_name) { return TRUE; } } return FALSE; } else { return TRUE; } }
php
{ "resource": "" }
q1982
UseDeclarationStatementNode.importsFunction
train
public function importsFunction($function_name = NULL) { if (!$this->useFunction) { return FALSE; } if ($function_name) { foreach ($this->getDeclarations() as $declaration) { if ($declaration->getName()->getPath() === $function_name) { return TRUE; } } return FALSE; } else { return TRUE; } }
php
{ "resource": "" }
q1983
UseDeclarationStatementNode.importsConst
train
public function importsConst($const_name = NULL) { if (!$this->useConst) { return FALSE; } if ($const_name) { foreach ($this->getDeclarations() as $declaration) { if ($declaration->getName()->getPath() === $const_name) { return TRUE; } } return FALSE; } else { return TRUE; } }
php
{ "resource": "" }
q1984
BaseFacade.getDeliveryAddress
train
public function getDeliveryAddress() { try { return AddressQuery::create()->findPk( $this->getRequest()->getSession()->getOrder()->getChoosenDeliveryAddress() ); } catch (\Exception $ex) { throw new \LogicException("Failed to get delivery address (" . $ex->getMessage() . ")"); } }
php
{ "resource": "" }
q1985
BaseFacade.getCartTotalPrice
train
public function getCartTotalPrice($withItemsInPromo = true) { $total = 0; $cartItems = $this->getRequest()->getSession()->getSessionCart($this->getDispatcher())->getCartItems(); foreach ($cartItems as $cartItem) { if ($withItemsInPromo || ! $cartItem->getPromo()) { $total += $cartItem->getRealPrice() * $cartItem->getQuantity(); } } return $total; }
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) { // Only valid coupons are returned try { if (false !== $couponInterface = $couponFactory->buildCouponFromCode($couponCode)) { $coupons[] = $couponInterface; } } catch (\Exception $ex) { // Just ignore the coupon and log the problem, just in case someone realize it. Tlog::getInstance()->warning( sprintf("Coupon %s ignored, exception occurred: %s", $couponCode, $ex->getMessage()) ); } } return $coupons; }
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( $this->parser->getTemplateHelper()->getActiveAdminTemplate() ); } return $this->parser; }
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])) { // Prevent accumulation of the same Coupon on a Checkout $consumedCoupons[$couponCode] = $couponCode; $this->getRequest()->getSession()->setConsumedCoupons($consumedCoupons); } }
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, // The attributes list field 'attribute_av_field_name' => $this->makeCouponFieldName(self::ATTRIBUTES_AV_LIST), 'attribute_av_values' => $this->attributeAvList ])); }
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 your description in the first 150-160 characters.'), ], 'attr' => [ 'rows' => 6, 'placeholder' => Translator::getInstance()->trans('Make sure it uses keywords found within the page itself.'), ] ] ); } if (! \in_array('meta_keywords', $exclude)) { $this->formBuilder->add( 'meta_keywords', 'textarea', [ 'required' => false, 'label' => Translator::getInstance()->trans('Meta Keywords'), 'label_attr' => [ 'for' => 'meta_keywords', 'help' => Translator::getInstance()->trans('You don\'t need to use commas or other punctuations.'), ], 'attr' => [ 'rows' => 3, 'placeholder' => Translator::getInstance()->trans('Don\'t repeat keywords over and over in a row. Rather, put in keyword phrases.'), ] ] ); } }
php
{ "resource": "" }
q1991
AbstractCrudController.getCurrentListOrder
train
protected function getCurrentListOrder($update_session = true) { return $this->getListOrderFromSession( $this->objectName, $this->orderRequestParameterName, $this->defaultListOrder ); }
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', ''); $zoneConfig = $this->params()->fromRoute('zoneconfig', array()); $view = new ViewModel(); $view->melisKey = $melisKey; $view->title = $melisTool->getTitle();; return $view; }
php
{ "resource": "" }
q1993
ToolStyleController.getStyleByPageId
train
public function getStyleByPageId($pageId) { $style = ""; $pageStyle = $this->getServiceLocator()->get('MelisPageStyle'); if($pageStyle){ $dataStyle = $pageStyle->getStyleByPageId($pageId); $style = $dataStyle; } return $style; }
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; } if ("css" === $type) { $event->add($this->addCSS($filepath)); continue; } if ("js" === $type) { $event->add($this->addJS($filepath)); continue; } if (method_exists($this, $type)) { $this->{$type}($filepath, $allArguments); } } } }
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 = $this->parser->render($templateDir . DS . $templateName, $parameters); } else { $content = sprintf("ERR: Unknown template %s for module %s", $templateName, $this->module->getCode()); } return $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 = file_get_contents($fileDir . DS . $fileName); if (false === $content) { $content = ""; } } else { $content = sprintf("ERR: Unknown file %s for module %s", $fileName, $this->module->getCode()); } return $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" '; $tags[] = ' href="' . $url . '" '; foreach ($attributes as $name => $val) { if (\is_string($name) && !\in_array($name, [ "href", "rel", "type" ])) { $tags[] = $name . '="' . $val . '" '; } } $tags[] = "/>"; $tag = implode($tags); } return $tag; }
php
{ "resource": "" }
q1998
BaseHook.getRequest
train
protected function getRequest() { if (null === $this->request) { $this->request = $this->getParser()->getRequest(); } return $this->request; }
php
{ "resource": "" }
q1999
BaseHook.getSession
train
protected function getSession() { if (null === $this->session) { if (null !== $this->getRequest()) { $this->session = $this->request->getSession(); } } return $this->session; }
php
{ "resource": "" }