_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...
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'); } ...
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(...
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(); ...
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($...
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($t...
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) { ...
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 { ...
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->addChil...
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; ...
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->tryMatchT...
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...
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 = ne...
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, 'lexic...
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->...
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(), 'prope...
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)...
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) { ...
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, ...
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 !== $termina...
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($...
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_...
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->objectDerefe...
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 =...
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); } el...
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_referen...
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 === '(') { $n...
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->offsetVariabl...
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...
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; defau...
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...
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()); } wh...
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 ($t...
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 N...
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")...
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_...
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 Statem...
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->matc...
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()); ...
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)-...
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, TR...
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 abst...
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-...
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 ($t...
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->addChil...
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')...
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, $no...
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)) { ...
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) { ...
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 {...
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) { ret...
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(); ...
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(); ...
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.'); ...
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.' ...
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] !== '-') { $isAbso...
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; } } ...
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; } } retur...
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; } ...
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 (...
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()) { ...
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'); ...
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()->get...
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_val...
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('Rew...
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->setM...
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. $allAr...
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->pars...
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) { ...
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...
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": "" }