function_name stringlengths 2 38 | file_path stringlengths 15 82 | focal_code stringlengths 232 4.12k | file_content stringlengths 930 234k | language stringclasses 1
value | function_component dict | metadata dict |
|---|---|---|---|---|---|---|
verifyModifier | PHP-Parser/lib/PhpParser/Modifiers.php | public static function verifyModifier(int $a, int $b): void {
assert(self::isValidModifier($b));
if (($a & Modifiers::VISIBILITY_MASK && $b & Modifiers::VISIBILITY_MASK) ||
($a & Modifiers::VISIBILITY_SET_MASK && $b & Modifiers::VISIBILITY_SET_MASK)
) {
throw new Error('M... | <?php declare(strict_types=1);
namespace PhpParser;
/**
* Modifiers used (as a bit mask) by various flags subnodes, for example on classes, functions,
* properties and constants.
*/
final class Modifiers {
public const PUBLIC = 1;
public const PROTECTED = 2;
public const PRIVATE = 4;
public... | PHP | {
"end_line": 84,
"name": "verifyModifier",
"signature": "public static function verifyModifier(int $a, int $b): void {",
"start_line": 68
} | {
"class_name": "Modifiers",
"class_signature": "class Modifiers",
"namespace": "PhpParser"
} |
addAlias | PHP-Parser/lib/PhpParser/NameContext.php | public function addAlias(Name $name, string $aliasName, int $type, array $errorAttrs = []): void {
// Constant names are case sensitive, everything else case insensitive
if ($type === Stmt\Use_::TYPE_CONSTANT) {
$aliasLookupName = $aliasName;
} else {
$aliasLookupName = s... | <?php declare(strict_types=1);
namespace PhpParser;
use PhpParser\Node\Name;
use PhpParser\Node\Name\FullyQualified;
use PhpParser\Node\Stmt;
class NameContext {
/** @var null|Name Current namespace */
protected ?Name $namespace;
/** @var Name[][] Map of format [aliasType => [aliasName => originalName]]... | PHP | {
"end_line": 82,
"name": "addAlias",
"signature": "public function addAlias(Name $name, string $aliasName, int $type, array $errorAttrs = []): void {",
"start_line": 55
} | {
"class_name": "NameContext",
"class_signature": "class NameContext",
"namespace": "PhpParser"
} |
find | PHP-Parser/lib/PhpParser/NodeFinder.php | public function find($nodes, callable $filter): array {
if ($nodes === []) {
return [];
}
if (!is_array($nodes)) {
$nodes = [$nodes];
}
$visitor = new FindingVisitor($filter);
$traverser = new NodeTraverser($visitor);
$traverser->travers... | <?php declare(strict_types=1);
namespace PhpParser;
use PhpParser\NodeVisitor\FindingVisitor;
use PhpParser\NodeVisitor\FirstFindingVisitor;
class NodeFinder {
/**
* Find all nodes satisfying a filter callback.
*
* @param Node|Node[] $nodes Single node or array of nodes to search in
* @param ... | PHP | {
"end_line": 32,
"name": "find",
"signature": "public function find($nodes, callable $filter): array {",
"start_line": 17
} | {
"class_name": "NodeFinder",
"class_signature": "class NodeFinder",
"namespace": "PhpParser"
} |
findFirst | PHP-Parser/lib/PhpParser/NodeFinder.php | public function findFirst($nodes, callable $filter): ?Node {
if ($nodes === []) {
return null;
}
if (!is_array($nodes)) {
$nodes = [$nodes];
}
$visitor = new FirstFindingVisitor($filter);
$traverser = new NodeTraverser($visitor);
$traver... | <?php declare(strict_types=1);
namespace PhpParser;
use PhpParser\NodeVisitor\FindingVisitor;
use PhpParser\NodeVisitor\FirstFindingVisitor;
class NodeFinder {
/**
* Find all nodes satisfying a filter callback.
*
* @param Node|Node[] $nodes Single node or array of nodes to search in
* @param ... | PHP | {
"end_line": 73,
"name": "findFirst",
"signature": "public function findFirst($nodes, callable $filter): ?Node {",
"start_line": 58
} | {
"class_name": "NodeFinder",
"class_signature": "class NodeFinder",
"namespace": "PhpParser"
} |
traverse | PHP-Parser/lib/PhpParser/NodeTraverser.php | public function traverse(array $nodes): array {
$this->stopTraversal = false;
foreach ($this->visitors as $visitor) {
if (null !== $return = $visitor->beforeTraverse($nodes)) {
$nodes = $return;
}
}
$nodes = $this->traverseArray($nodes);
... | <?php declare(strict_types=1);
namespace PhpParser;
class NodeTraverser implements NodeTraverserInterface {
/**
* @deprecated Use NodeVisitor::DONT_TRAVERSE_CHILDREN instead.
*/
public const DONT_TRAVERSE_CHILDREN = NodeVisitor::DONT_TRAVERSE_CHILDREN;
/**
* @deprecated Use NodeVisitor::ST... | PHP | {
"end_line": 86,
"name": "traverse",
"signature": "public function traverse(array $nodes): array {",
"start_line": 67
} | {
"class_name": "NodeTraverser",
"class_signature": "class NodeTraverser implements NodeTraverserInterface",
"namespace": "PhpParser"
} |
parse | PHP-Parser/lib/PhpParser/ParserAbstract.php | public function parse(string $code, ?ErrorHandler $errorHandler = null): ?array {
$this->errorHandler = $errorHandler ?: new ErrorHandler\Throwing();
$this->createdArrays = new \SplObjectStorage();
$this->parenthesizedArrowFunctions = new \SplObjectStorage();
$this->tokens = $this->lexe... | <?php declare(strict_types=1);
namespace PhpParser;
/*
* This parser is based on a skeleton written by Moriyoshi Koizumi, which in
* turn is based on work by Masato Bito.
*/
use PhpParser\Node\Arg;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\Array_;
use PhpParser\Node\Expr\Cast\Double;
use PhpParser\Node\Ide... | PHP | {
"end_line": 222,
"name": "parse",
"signature": "public function parse(string $code, ?ErrorHandler $errorHandler = null): ?array {",
"start_line": 187
} | {
"class_name": "ParserAbstract",
"class_signature": "class ParserAbstract implements Parser",
"namespace": "PhpParser"
} |
createForVersion | PHP-Parser/lib/PhpParser/ParserFactory.php | public function createForVersion(PhpVersion $version): Parser {
if ($version->isHostVersion()) {
$lexer = new Lexer();
} else {
$lexer = new Lexer\Emulative($version);
}
if ($version->id >= 80000) {
return new Php8($lexer, $version);
}
... | <?php declare(strict_types=1);
namespace PhpParser;
use PhpParser\Parser\Php7;
use PhpParser\Parser\Php8;
class ParserFactory {
/**
* Create a parser targeting the given version on a best-effort basis. The parser will generally
* accept code for the newest supported version, but will try to accommodate... | PHP | {
"end_line": 24,
"name": "createForVersion",
"signature": "public function createForVersion(PhpVersion $version): Parser {",
"start_line": 14
} | {
"class_name": "ParserFactory",
"class_signature": "class ParserFactory",
"namespace": "PhpParser"
} |
prettyPrintFile | PHP-Parser/lib/PhpParser/PrettyPrinterAbstract.php | public function prettyPrintFile(array $stmts): string {
if (!$stmts) {
return "<?php" . $this->newline . $this->newline;
}
$p = "<?php" . $this->newline . $this->newline . $this->prettyPrint($stmts);
if ($stmts[0] instanceof Stmt\InlineHTML) {
$p = preg_replace(... | <?php declare(strict_types=1);
namespace PhpParser;
use PhpParser\Internal\DiffElem;
use PhpParser\Internal\Differ;
use PhpParser\Internal\PrintableNewAnonClassNode;
use PhpParser\Internal\TokenStream;
use PhpParser\Node\AttributeGroup;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\AssignOp;
use PhpParser\Node\Exp... | PHP | {
"end_line": 310,
"name": "prettyPrintFile",
"signature": "public function prettyPrintFile(array $stmts): string {",
"start_line": 295
} | {
"class_name": "PrettyPrinterAbstract",
"class_signature": "class PrettyPrinterAbstract implements PrettyPrinter",
"namespace": "PhpParser"
} |
printFormatPreserving | PHP-Parser/lib/PhpParser/PrettyPrinterAbstract.php | public function printFormatPreserving(array $stmts, array $origStmts, array $origTokens): string {
$this->initializeNodeListDiffer();
$this->initializeLabelCharMap();
$this->initializeFixupMap();
$this->initializeRemovalMap();
$this->initializeInsertionMap();
$this->initi... | <?php declare(strict_types=1);
namespace PhpParser;
use PhpParser\Internal\DiffElem;
use PhpParser\Internal\Differ;
use PhpParser\Internal\PrintableNewAnonClassNode;
use PhpParser\Internal\TokenStream;
use PhpParser\Node\AttributeGroup;
use PhpParser\Node\Expr;
use PhpParser\Node\Expr\AssignOp;
use PhpParser\Node\Exp... | PHP | {
"end_line": 586,
"name": "printFormatPreserving",
"signature": "public function printFormatPreserving(array $stmts, array $origStmts, array $origTokens): string {",
"start_line": 560
} | {
"class_name": "PrettyPrinterAbstract",
"class_signature": "class PrettyPrinterAbstract implements PrettyPrinter",
"namespace": "PhpParser"
} |
addStmt | PHP-Parser/lib/PhpParser/Builder/Class_.php | public function addStmt($stmt) {
$stmt = BuilderHelpers::normalizeNode($stmt);
if ($stmt instanceof Stmt\Property) {
$this->properties[] = $stmt;
} elseif ($stmt instanceof Stmt\ClassMethod) {
$this->methods[] = $stmt;
} elseif ($stmt instanceof Stmt\TraitUse) {
... | <?php declare(strict_types=1);
namespace PhpParser\Builder;
use PhpParser;
use PhpParser\BuilderHelpers;
use PhpParser\Modifiers;
use PhpParser\Node;
use PhpParser\Node\Name;
use PhpParser\Node\Stmt;
class Class_ extends Declaration {
protected string $name;
protected ?Name $extends = null;
/** @var list... | PHP | {
"end_line": 122,
"name": "addStmt",
"signature": "public function addStmt($stmt) {",
"start_line": 106
} | {
"class_name": "Class_",
"class_signature": "class Class_",
"namespace": "PhpParser\\Builder"
} |
addStmt | PHP-Parser/lib/PhpParser/Builder/Enum_.php | public function addStmt($stmt) {
$stmt = BuilderHelpers::normalizeNode($stmt);
if ($stmt instanceof Stmt\EnumCase) {
$this->enumCases[] = $stmt;
} elseif ($stmt instanceof Stmt\ClassMethod) {
$this->methods[] = $stmt;
} elseif ($stmt instanceof Stmt\TraitUse) {
... | <?php declare(strict_types=1);
namespace PhpParser\Builder;
use PhpParser;
use PhpParser\BuilderHelpers;
use PhpParser\Node;
use PhpParser\Node\Identifier;
use PhpParser\Node\Name;
use PhpParser\Node\Stmt;
class Enum_ extends Declaration {
protected string $name;
protected ?Identifier $scalarType = null;
... | PHP | {
"end_line": 88,
"name": "addStmt",
"signature": "public function addStmt($stmt) {",
"start_line": 72
} | {
"class_name": "Enum_",
"class_signature": "class Enum_",
"namespace": "PhpParser\\Builder"
} |
addStmt | PHP-Parser/lib/PhpParser/Builder/Interface_.php | public function addStmt($stmt) {
$stmt = BuilderHelpers::normalizeNode($stmt);
if ($stmt instanceof Stmt\ClassConst) {
$this->constants[] = $stmt;
} elseif ($stmt instanceof Stmt\ClassMethod) {
// we erase all statements in the body of an interface method
$st... | <?php declare(strict_types=1);
namespace PhpParser\Builder;
use PhpParser;
use PhpParser\BuilderHelpers;
use PhpParser\Node;
use PhpParser\Node\Name;
use PhpParser\Node\Stmt;
class Interface_ extends Declaration {
protected string $name;
/** @var list<Name> */
protected array $extends = [];
/** @var ... | PHP | {
"end_line": 67,
"name": "addStmt",
"signature": "public function addStmt($stmt) {",
"start_line": 53
} | {
"class_name": "Interface_",
"class_signature": "class Interface_",
"namespace": "PhpParser\\Builder"
} |
as | PHP-Parser/lib/PhpParser/Builder/TraitUseAdaptation.php | public function as($alias) {
if ($this->type === self::TYPE_UNDEFINED) {
$this->type = self::TYPE_ALIAS;
}
if ($this->type !== self::TYPE_ALIAS) {
throw new \LogicException('Cannot set alias for not alias adaptation buider');
}
$this->alias = BuilderHelp... | <?php declare(strict_types=1);
namespace PhpParser\Builder;
use PhpParser\Builder;
use PhpParser\BuilderHelpers;
use PhpParser\Modifiers;
use PhpParser\Node;
use PhpParser\Node\Stmt;
class TraitUseAdaptation implements Builder {
private const TYPE_UNDEFINED = 0;
private const TYPE_ALIAS = 1;
privat... | PHP | {
"end_line": 55,
"name": "as",
"signature": "public function as($alias) {",
"start_line": 44
} | {
"class_name": "TraitUseAdaptation",
"class_signature": "class TraitUseAdaptation implements Builder",
"namespace": "PhpParser\\Builder"
} |
insteadof | PHP-Parser/lib/PhpParser/Builder/TraitUseAdaptation.php | public function insteadof(...$traits) {
if ($this->type === self::TYPE_UNDEFINED) {
if (is_null($this->trait)) {
throw new \LogicException('Precedence adaptation must have trait');
}
$this->type = self::TYPE_PRECEDENCE;
}
if ($this->type !== ... | <?php declare(strict_types=1);
namespace PhpParser\Builder;
use PhpParser\Builder;
use PhpParser\BuilderHelpers;
use PhpParser\Modifiers;
use PhpParser\Node;
use PhpParser\Node\Stmt;
class TraitUseAdaptation implements Builder {
private const TYPE_UNDEFINED = 0;
private const TYPE_ALIAS = 1;
privat... | PHP | {
"end_line": 112,
"name": "insteadof",
"signature": "public function insteadof(...$traits) {",
"start_line": 94
} | {
"class_name": "TraitUseAdaptation",
"class_signature": "class TraitUseAdaptation implements Builder",
"namespace": "PhpParser\\Builder"
} |
addStmt | PHP-Parser/lib/PhpParser/Builder/Trait_.php | public function addStmt($stmt) {
$stmt = BuilderHelpers::normalizeNode($stmt);
if ($stmt instanceof Stmt\Property) {
$this->properties[] = $stmt;
} elseif ($stmt instanceof Stmt\ClassMethod) {
$this->methods[] = $stmt;
} elseif ($stmt instanceof Stmt\TraitUse) {
... | <?php declare(strict_types=1);
namespace PhpParser\Builder;
use PhpParser;
use PhpParser\BuilderHelpers;
use PhpParser\Node;
use PhpParser\Node\Stmt;
class Trait_ extends Declaration {
protected string $name;
/** @var list<Stmt\TraitUse> */
protected array $uses = [];
/** @var list<Stmt\ClassConst> *... | PHP | {
"end_line": 55,
"name": "addStmt",
"signature": "public function addStmt($stmt) {",
"start_line": 39
} | {
"class_name": "Trait_",
"class_signature": "class Trait_",
"namespace": "PhpParser\\Builder"
} |
is | PHP-Parser/lib/PhpParser/Internal/TokenPolyfill.php | public function is($kind): bool {
if (\is_int($kind)) {
return $this->id === $kind;
}
if (\is_string($kind)) {
return $this->text === $kind;
}
if (\is_array($kind)) {
foreach ($kind as $entry) {
if (\is_int($entry)) {
... | <?php declare(strict_types=1);
namespace PhpParser\Internal;
if (\PHP_VERSION_ID >= 80000) {
class TokenPolyfill extends \PhpToken {
}
return;
}
/**
* This is a polyfill for the PhpToken class introduced in PHP 8.0. We do not actually polyfill
* PhpToken, because composer might end up picking a differe... | PHP | {
"end_line": 96,
"name": "is",
"signature": "public function is($kind): bool {",
"start_line": 69
} | {
"class_name": "TokenPolyfill",
"class_signature": "class TokenPolyfill",
"namespace": "PhpParser\\Internal"
} |
tokenize | PHP-Parser/lib/PhpParser/Internal/TokenPolyfill.php | public static function tokenize(string $code, int $flags = 0): array {
self::init();
$tokens = [];
$line = 1;
$pos = 0;
$origTokens = \token_get_all($code, $flags);
$numTokens = \count($origTokens);
for ($i = 0; $i < $numTokens; $i++) {
$token = $ori... | <?php declare(strict_types=1);
namespace PhpParser\Internal;
if (\PHP_VERSION_ID >= 80000) {
class TokenPolyfill extends \PhpToken {
}
return;
}
/**
* This is a polyfill for the PhpToken class introduced in PHP 8.0. We do not actually polyfill
* PhpToken, because composer might end up picking a differe... | PHP | {
"end_line": 215,
"name": "tokenize",
"signature": "public static function tokenize(string $code, int $flags = 0): array {",
"start_line": 124
} | {
"class_name": "TokenPolyfill",
"class_signature": "class TokenPolyfill",
"namespace": "PhpParser\\Internal"
} |
haveTokenImmediatelyBefore | PHP-Parser/lib/PhpParser/Internal/TokenStream.php | public function haveTokenImmediatelyBefore(int $pos, $expectedTokenType): bool {
$tokens = $this->tokens;
$pos--;
for (; $pos >= 0; $pos--) {
$token = $tokens[$pos];
if ($token->is($expectedTokenType)) {
return true;
}
if (!$token->... | <?php declare(strict_types=1);
namespace PhpParser\Internal;
use PhpParser\Token;
/**
* Provides operations on token streams, for use by pretty printer.
*
* @internal
*/
class TokenStream {
/** @var Token[] Tokens (in PhpToken::tokenize() format) */
private array $tokens;
/** @var int[] Map from posi... | PHP | {
"end_line": 74,
"name": "haveTokenImmediatelyBefore",
"signature": "public function haveTokenImmediatelyBefore(int $pos, $expectedTokenType): bool {",
"start_line": 61
} | {
"class_name": "TokenStream",
"class_signature": "class TokenStream",
"namespace": "PhpParser\\Internal"
} |
haveTokenImmediatelyAfter | PHP-Parser/lib/PhpParser/Internal/TokenStream.php | public function haveTokenImmediatelyAfter(int $pos, $expectedTokenType): bool {
$tokens = $this->tokens;
$pos++;
for ($c = \count($tokens); $pos < $c; $pos++) {
$token = $tokens[$pos];
if ($token->is($expectedTokenType)) {
return true;
}
... | <?php declare(strict_types=1);
namespace PhpParser\Internal;
use PhpParser\Token;
/**
* Provides operations on token streams, for use by pretty printer.
*
* @internal
*/
class TokenStream {
/** @var Token[] Tokens (in PhpToken::tokenize() format) */
private array $tokens;
/** @var int[] Map from posi... | PHP | {
"end_line": 99,
"name": "haveTokenImmediatelyAfter",
"signature": "public function haveTokenImmediatelyAfter(int $pos, $expectedTokenType): bool {",
"start_line": 86
} | {
"class_name": "TokenStream",
"class_signature": "class TokenStream",
"namespace": "PhpParser\\Internal"
} |
skipLeft | PHP-Parser/lib/PhpParser/Internal/TokenStream.php | public function skipLeft(int $pos, $skipTokenType): int {
$tokens = $this->tokens;
$pos = $this->skipLeftWhitespace($pos);
if ($skipTokenType === \T_WHITESPACE) {
return $pos;
}
if (!$tokens[$pos]->is($skipTokenType)) {
// Shouldn't happen. The skip toke... | <?php declare(strict_types=1);
namespace PhpParser\Internal;
use PhpParser\Token;
/**
* Provides operations on token streams, for use by pretty printer.
*
* @internal
*/
class TokenStream {
/** @var Token[] Tokens (in PhpToken::tokenize() format) */
private array $tokens;
/** @var int[] Map from posi... | PHP | {
"end_line": 117,
"name": "skipLeft",
"signature": "public function skipLeft(int $pos, $skipTokenType): int {",
"start_line": 102
} | {
"class_name": "TokenStream",
"class_signature": "class TokenStream",
"namespace": "PhpParser\\Internal"
} |
skipRight | PHP-Parser/lib/PhpParser/Internal/TokenStream.php | public function skipRight(int $pos, $skipTokenType): int {
$tokens = $this->tokens;
$pos = $this->skipRightWhitespace($pos);
if ($skipTokenType === \T_WHITESPACE) {
return $pos;
}
if (!$tokens[$pos]->is($skipTokenType)) {
// Shouldn't happen. The skip to... | <?php declare(strict_types=1);
namespace PhpParser\Internal;
use PhpParser\Token;
/**
* Provides operations on token streams, for use by pretty printer.
*
* @internal
*/
class TokenStream {
/** @var Token[] Tokens (in PhpToken::tokenize() format) */
private array $tokens;
/** @var int[] Map from posi... | PHP | {
"end_line": 135,
"name": "skipRight",
"signature": "public function skipRight(int $pos, $skipTokenType): int {",
"start_line": 120
} | {
"class_name": "TokenStream",
"class_signature": "class TokenStream",
"namespace": "PhpParser\\Internal"
} |
tokenize | PHP-Parser/lib/PhpParser/Lexer/Emulative.php | public function tokenize(string $code, ?ErrorHandler $errorHandler = null): array {
$emulators = array_filter($this->emulators, function ($emulator) use ($code) {
return $emulator->isEmulationNeeded($code);
});
if (empty($emulators)) {
// Nothing to emulate, yay
... | <?php declare(strict_types=1);
namespace PhpParser\Lexer;
use PhpParser\Error;
use PhpParser\ErrorHandler;
use PhpParser\Lexer;
use PhpParser\Lexer\TokenEmulator\AsymmetricVisibilityTokenEmulator;
use PhpParser\Lexer\TokenEmulator\AttributeEmulator;
use PhpParser\Lexer\TokenEmulator\EnumTokenEmulator;
use PhpParser\L... | PHP | {
"end_line": 105,
"name": "tokenize",
"signature": "public function tokenize(string $code, ?ErrorHandler $errorHandler = null): array {",
"start_line": 68
} | {
"class_name": "Emulative",
"class_signature": "class Emulative",
"namespace": "PhpParser\\Lexer"
} |
slice | PHP-Parser/lib/PhpParser/Node/Name.php | public function slice(int $offset, ?int $length = null) {
if ($offset === 1 && $length === null) {
// Short-circuit the common case.
if (false !== $pos = \strpos($this->name, '\\')) {
return new static(\substr($this->name, $pos + 1));
}
return null... | <?php declare(strict_types=1);
namespace PhpParser\Node;
use PhpParser\NodeAbstract;
class Name extends NodeAbstract {
/**
* @psalm-var non-empty-string
* @var string Name as string
*/
public string $name;
/** @var array<string, bool> */
private static array $specialClassNames = [
... | PHP | {
"end_line": 207,
"name": "slice",
"signature": "public function slice(int $offset, ?int $length = null) {",
"start_line": 175
} | {
"class_name": "Name",
"class_signature": "class Name",
"namespace": "PhpParser\\Node"
} |
concat | PHP-Parser/lib/PhpParser/Node/Name.php | public static function concat($name1, $name2, array $attributes = []) {
if (null === $name1 && null === $name2) {
return null;
}
if (null === $name1) {
return new static($name2, $attributes);
}
if (null === $name2) {
return new static($name1, $... | <?php declare(strict_types=1);
namespace PhpParser\Node;
use PhpParser\NodeAbstract;
class Name extends NodeAbstract {
/**
* @psalm-var non-empty-string
* @var string Name as string
*/
public string $name;
/** @var array<string, bool> */
private static array $specialClassNames = [
... | PHP | {
"end_line": 240,
"name": "concat",
"signature": "public static function concat($name1, $name2, array $attributes = []) {",
"start_line": 226
} | {
"class_name": "Name",
"class_signature": "class Name",
"namespace": "PhpParser\\Node"
} |
isPublic | PHP-Parser/lib/PhpParser/Node/Param.php | public function isPublic(): bool {
$public = (bool) ($this->flags & Modifiers::PUBLIC);
if ($public) {
return true;
}
if (!$this->isPromoted()) {
return false;
}
return ($this->flags & Modifiers::VISIBILITY_MASK) === 0;
} | <?php declare(strict_types=1);
namespace PhpParser\Node;
use PhpParser\Modifiers;
use PhpParser\Node;
use PhpParser\NodeAbstract;
class Param extends NodeAbstract {
/** @var null|Identifier|Name|ComplexType Type declaration */
public ?Node $type;
/** @var bool Whether parameter is passed by reference */
... | PHP | {
"end_line": 89,
"name": "isPublic",
"signature": "public function isPublic(): bool {",
"start_line": 78
} | {
"class_name": "Param",
"class_signature": "class Param",
"namespace": "PhpParser\\Node"
} |
enterNode | PHP-Parser/lib/PhpParser/NodeVisitor/CommentAnnotatingVisitor.php | public function enterNode(Node $node) {
$nextCommentPos = current($this->commentPositions);
if ($nextCommentPos === false) {
// No more comments.
return self::STOP_TRAVERSAL;
}
$oldPos = $this->pos;
$this->pos = $pos = $node->getStartTokenPos();
i... | <?php declare(strict_types=1);
namespace PhpParser\NodeVisitor;
use PhpParser\Comment;
use PhpParser\Node;
use PhpParser\NodeVisitorAbstract;
use PhpParser\Token;
class CommentAnnotatingVisitor extends NodeVisitorAbstract {
/** @var int Last seen token start position */
private int $pos = 0;
/** @var Tok... | PHP | {
"end_line": 81,
"name": "enterNode",
"signature": "public function enterNode(Node $node) {",
"start_line": 35
} | {
"class_name": "CommentAnnotatingVisitor",
"class_signature": "class CommentAnnotatingVisitor",
"namespace": "PhpParser\\NodeVisitor"
} |
enterNode | PHP-Parser/lib/PhpParser/NodeVisitor/NodeConnectingVisitor.php | public function enterNode(Node $node) {
if (!empty($this->stack)) {
$parent = $this->stack[count($this->stack) - 1];
if ($this->weakReferences) {
$node->setAttribute('weak_parent', \WeakReference::create($parent));
} else {
$node->setAttribute(... | <?php declare(strict_types=1);
namespace PhpParser\NodeVisitor;
use PhpParser\Node;
use PhpParser\NodeVisitorAbstract;
/**
* Visitor that connects a child node to its parent node
* as well as its sibling nodes.
*
* With <code>$weakReferences=false</code> on the child node, the parent node can be accessed through... | PHP | {
"end_line": 66,
"name": "enterNode",
"signature": "public function enterNode(Node $node) {",
"start_line": 41
} | {
"class_name": "NodeConnectingVisitor",
"class_signature": "class NodeConnectingVisitor",
"namespace": "PhpParser\\NodeVisitor"
} |
enterNode | PHP-Parser/lib/PhpParser/NodeVisitor/ParentConnectingVisitor.php | public function enterNode(Node $node) {
if (!empty($this->stack)) {
$parent = $this->stack[count($this->stack) - 1];
if ($this->weakReferences) {
$node->setAttribute('weak_parent', \WeakReference::create($parent));
} else {
$node->setAttribute(... | <?php declare(strict_types=1);
namespace PhpParser\NodeVisitor;
use PhpParser\Node;
use PhpParser\NodeVisitorAbstract;
use function array_pop;
use function count;
/**
* Visitor that connects a child node to its parent node.
*
* With <code>$weakReferences=false</code> on the child node, the parent node can be acc... | PHP | {
"end_line": 46,
"name": "enterNode",
"signature": "public function enterNode(Node $node) {",
"start_line": 35
} | {
"class_name": "ParentConnectingVisitor",
"class_signature": "class ParentConnectingVisitor",
"namespace": "PhpParser\\NodeVisitor"
} |
emulate | PHP-Parser/lib/PhpParser/Lexer/TokenEmulator/AsymmetricVisibilityTokenEmulator.php | public function emulate(string $code, array $tokens): array {
$map = [
\T_PUBLIC => \T_PUBLIC_SET,
\T_PROTECTED => \T_PROTECTED_SET,
\T_PRIVATE => \T_PRIVATE_SET,
];
for ($i = 0, $c = count($tokens); $i < $c; ++$i) {
$token = $tokens[$i];
... | <?php declare(strict_types=1);
namespace PhpParser\Lexer\TokenEmulator;
use PhpParser\PhpVersion;
use PhpParser\Token;
final class AsymmetricVisibilityTokenEmulator extends TokenEmulator {
public function getPhpVersion(): PhpVersion {
return PhpVersion::fromComponents(8, 4);
}
public function isE... | PHP | {
"end_line": 42,
"name": "emulate",
"signature": "public function emulate(string $code, array $tokens): array {",
"start_line": 19
} | {
"class_name": "AsymmetricVisibilityTokenEmulator",
"class_signature": "class AsymmetricVisibilityTokenEmulator",
"namespace": "PhpParser\\Lexer\\TokenEmulator"
} |
reverseEmulate | PHP-Parser/lib/PhpParser/Lexer/TokenEmulator/AsymmetricVisibilityTokenEmulator.php | public function reverseEmulate(string $code, array $tokens): array {
$reverseMap = [
\T_PUBLIC_SET => \T_PUBLIC,
\T_PROTECTED_SET => \T_PROTECTED,
\T_PRIVATE_SET => \T_PRIVATE,
];
for ($i = 0, $c = count($tokens); $i < $c; ++$i) {
$token = $tokens[... | <?php declare(strict_types=1);
namespace PhpParser\Lexer\TokenEmulator;
use PhpParser\PhpVersion;
use PhpParser\Token;
final class AsymmetricVisibilityTokenEmulator extends TokenEmulator {
public function getPhpVersion(): PhpVersion {
return PhpVersion::fromComponents(8, 4);
}
public function isE... | PHP | {
"end_line": 69,
"name": "reverseEmulate",
"signature": "public function reverseEmulate(string $code, array $tokens): array {",
"start_line": 44
} | {
"class_name": "AsymmetricVisibilityTokenEmulator",
"class_signature": "class AsymmetricVisibilityTokenEmulator",
"namespace": "PhpParser\\Lexer\\TokenEmulator"
} |
emulate | PHP-Parser/lib/PhpParser/Lexer/TokenEmulator/AttributeEmulator.php | public function emulate(string $code, array $tokens): array {
// We need to manually iterate and manage a count because we'll change
// the tokens array on the way.
for ($i = 0, $c = count($tokens); $i < $c; ++$i) {
$token = $tokens[$i];
if ($token->text === '#' && isset(... | <?php declare(strict_types=1);
namespace PhpParser\Lexer\TokenEmulator;
use PhpParser\PhpVersion;
use PhpParser\Token;
final class AttributeEmulator extends TokenEmulator {
public function getPhpVersion(): PhpVersion {
return PhpVersion::fromComponents(8, 0);
}
public function isEmulationNeeded(... | PHP | {
"end_line": 32,
"name": "emulate",
"signature": "public function emulate(string $code, array $tokens): array {",
"start_line": 17
} | {
"class_name": "AttributeEmulator",
"class_signature": "class AttributeEmulator",
"namespace": "PhpParser\\Lexer\\TokenEmulator"
} |
emulate | PHP-Parser/lib/PhpParser/Lexer/TokenEmulator/ExplicitOctalEmulator.php | public function emulate(string $code, array $tokens): array {
for ($i = 0, $c = count($tokens); $i < $c; ++$i) {
$token = $tokens[$i];
if ($token->id == \T_LNUMBER && $token->text === '0' &&
isset($tokens[$i + 1]) && $tokens[$i + 1]->id == \T_STRING &&
pre... | <?php declare(strict_types=1);
namespace PhpParser\Lexer\TokenEmulator;
use PhpParser\PhpVersion;
use PhpParser\Token;
class ExplicitOctalEmulator extends TokenEmulator {
public function getPhpVersion(): PhpVersion {
return PhpVersion::fromComponents(8, 1);
}
public function isEmulationNeeded(st... | PHP | {
"end_line": 32,
"name": "emulate",
"signature": "public function emulate(string $code, array $tokens): array {",
"start_line": 17
} | {
"class_name": "ExplicitOctalEmulator",
"class_signature": "class ExplicitOctalEmulator",
"namespace": "PhpParser\\Lexer\\TokenEmulator"
} |
emulate | PHP-Parser/lib/PhpParser/Lexer/TokenEmulator/KeywordEmulator.php | public function emulate(string $code, array $tokens): array {
$keywordString = $this->getKeywordString();
foreach ($tokens as $i => $token) {
if ($token->id === T_STRING && strtolower($token->text) === $keywordString
&& $this->isKeywordContext($tokens, $i)) {
... | <?php declare(strict_types=1);
namespace PhpParser\Lexer\TokenEmulator;
use PhpParser\Token;
abstract class KeywordEmulator extends TokenEmulator {
abstract public function getKeywordString(): string;
abstract public function getKeywordToken(): int;
public function isEmulationNeeded(string $code): bool ... | PHP | {
"end_line": 35,
"name": "emulate",
"signature": "public function emulate(string $code, array $tokens): array {",
"start_line": 25
} | {
"class_name": "KeywordEmulator",
"class_signature": "class KeywordEmulator",
"namespace": "PhpParser\\Lexer\\TokenEmulator"
} |
emulate | PHP-Parser/lib/PhpParser/Lexer/TokenEmulator/NullsafeTokenEmulator.php | public function emulate(string $code, array $tokens): array {
// We need to manually iterate and manage a count because we'll change
// the tokens array on the way
for ($i = 0, $c = count($tokens); $i < $c; ++$i) {
$token = $tokens[$i];
if ($token->text === '?' && isset($... | <?php declare(strict_types=1);
namespace PhpParser\Lexer\TokenEmulator;
use PhpParser\PhpVersion;
use PhpParser\Token;
final class NullsafeTokenEmulator extends TokenEmulator {
public function getPhpVersion(): PhpVersion {
return PhpVersion::fromComponents(8, 0);
}
public function isEmulationNee... | PHP | {
"end_line": 54,
"name": "emulate",
"signature": "public function emulate(string $code, array $tokens): array {",
"start_line": 17
} | {
"class_name": "NullsafeTokenEmulator",
"class_signature": "class NullsafeTokenEmulator",
"namespace": "PhpParser\\Lexer\\TokenEmulator"
} |
emulate | PHP-Parser/lib/PhpParser/Lexer/TokenEmulator/PipeOperatorEmulator.php | public function emulate(string $code, array $tokens): array {
for ($i = 0, $c = count($tokens); $i < $c; ++$i) {
$token = $tokens[$i];
if ($token->text === '|' && isset($tokens[$i + 1]) && $tokens[$i + 1]->text === '>') {
array_splice($tokens, $i, 2, [
... | <?php declare(strict_types=1);
namespace PhpParser\Lexer\TokenEmulator;
use PhpParser\Lexer\TokenEmulator\TokenEmulator;
use PhpParser\PhpVersion;
use PhpParser\Token;
class PipeOperatorEmulator extends TokenEmulator {
public function getPhpVersion(): PhpVersion {
return PhpVersion::fromComponents(8, 5);... | PHP | {
"end_line": 29,
"name": "emulate",
"signature": "public function emulate(string $code, array $tokens): array {",
"start_line": 18
} | {
"class_name": "PipeOperatorEmulator",
"class_signature": "class PipeOperatorEmulator",
"namespace": "PhpParser\\Lexer\\TokenEmulator"
} |
reverseEmulate | PHP-Parser/lib/PhpParser/Lexer/TokenEmulator/PipeOperatorEmulator.php | public function reverseEmulate(string $code, array $tokens): array {
for ($i = 0, $c = count($tokens); $i < $c; ++$i) {
$token = $tokens[$i];
if ($token->id === \T_PIPE) {
array_splice($tokens, $i, 1, [
new Token(\ord('|'), '|', $token->line, $token->p... | <?php declare(strict_types=1);
namespace PhpParser\Lexer\TokenEmulator;
use PhpParser\Lexer\TokenEmulator\TokenEmulator;
use PhpParser\PhpVersion;
use PhpParser\Token;
class PipeOperatorEmulator extends TokenEmulator {
public function getPhpVersion(): PhpVersion {
return PhpVersion::fromComponents(8, 5);... | PHP | {
"end_line": 44,
"name": "reverseEmulate",
"signature": "public function reverseEmulate(string $code, array $tokens): array {",
"start_line": 31
} | {
"class_name": "PipeOperatorEmulator",
"class_signature": "class PipeOperatorEmulator",
"namespace": "PhpParser\\Lexer\\TokenEmulator"
} |
emulate | PHP-Parser/lib/PhpParser/Lexer/TokenEmulator/VoidCastEmulator.php | public function emulate(string $code, array $tokens): array {
for ($i = 0, $c = count($tokens); $i < $c; ++$i) {
$token = $tokens[$i];
if ($token->text !== '(') {
continue;
}
$numTokens = 1;
$text = '(';
$j = $i + 1;
... | <?php declare(strict_types=1);
namespace PhpParser\Lexer\TokenEmulator;
use PhpParser\PhpVersion;
use PhpParser\Token;
class VoidCastEmulator extends TokenEmulator {
public function getPhpVersion(): PhpVersion {
return PhpVersion::fromComponents(8, 5);
}
public function isEmulationNeeded(string ... | PHP | {
"end_line": 58,
"name": "emulate",
"signature": "public function emulate(string $code, array $tokens): array {",
"start_line": 17
} | {
"class_name": "VoidCastEmulator",
"class_signature": "class VoidCastEmulator",
"namespace": "PhpParser\\Lexer\\TokenEmulator"
} |
reverseEmulate | PHP-Parser/lib/PhpParser/Lexer/TokenEmulator/VoidCastEmulator.php | public function reverseEmulate(string $code, array $tokens): array {
for ($i = 0, $c = count($tokens); $i < $c; ++$i) {
$token = $tokens[$i];
if ($token->id !== \T_VOID_CAST) {
continue;
}
if (!preg_match('/^\(([ \t]*)(void)([ \t]*)\)$/i', $token-... | <?php declare(strict_types=1);
namespace PhpParser\Lexer\TokenEmulator;
use PhpParser\PhpVersion;
use PhpParser\Token;
class VoidCastEmulator extends TokenEmulator {
public function getPhpVersion(): PhpVersion {
return PhpVersion::fromComponents(8, 5);
}
public function isEmulationNeeded(string ... | PHP | {
"end_line": 97,
"name": "reverseEmulate",
"signature": "public function reverseEmulate(string $code, array $tokens): array {",
"start_line": 60
} | {
"class_name": "VoidCastEmulator",
"class_signature": "class VoidCastEmulator",
"namespace": "PhpParser\\Lexer\\TokenEmulator"
} |
parse | PHP-Parser/lib/PhpParser/Node/Scalar/Float_.php | public static function parse(string $str): float {
$str = str_replace('_', '', $str);
// Check whether this is one of the special integer notations.
if ('0' === $str[0]) {
// hex
if ('x' === $str[1] || 'X' === $str[1]) {
return hexdec($str);
}... | <?php declare(strict_types=1);
namespace PhpParser\Node\Scalar;
use PhpParser\Node\Scalar;
class Float_ extends Scalar {
/** @var float Number value */
public float $value;
/**
* Constructs a float number scalar node.
*
* @param float $value Value of the number
* @param array<string,... | PHP | {
"end_line": 70,
"name": "parse",
"signature": "public static function parse(string $str): float {",
"start_line": 45
} | {
"class_name": "Float_",
"class_signature": "class Float_",
"namespace": "PhpParser\\Node\\Scalar"
} |
fromString | PHP-Parser/lib/PhpParser/Node/Scalar/Int_.php | public static function fromString(string $str, array $attributes = [], bool $allowInvalidOctal = false): Int_ {
$attributes['rawValue'] = $str;
$str = str_replace('_', '', $str);
if ('0' !== $str[0] || '0' === $str) {
$attributes['kind'] = Int_::KIND_DEC;
return new Int... | <?php declare(strict_types=1);
namespace PhpParser\Node\Scalar;
use PhpParser\Error;
use PhpParser\Node\Scalar;
class Int_ extends Scalar {
/* For use in "kind" attribute */
public const KIND_BIN = 2;
public const KIND_OCT = 8;
public const KIND_DEC = 10;
public const KIND_HEX = 16;
/** @var... | PHP | {
"end_line": 74,
"name": "fromString",
"signature": "public static function fromString(string $str, array $attributes = [], bool $allowInvalidOctal = false): Int_ {",
"start_line": 42
} | {
"class_name": "Int_",
"class_signature": "class Int_",
"namespace": "PhpParser\\Node\\Scalar"
} |
parse | PHP-Parser/lib/PhpParser/Node/Scalar/String_.php | public static function parse(string $str, bool $parseUnicodeEscape = true): string {
$bLength = 0;
if ('b' === $str[0] || 'B' === $str[0]) {
$bLength = 1;
}
if ('\'' === $str[$bLength]) {
return str_replace(
['\\\\', '\\\''],
['\\'... | <?php declare(strict_types=1);
namespace PhpParser\Node\Scalar;
use PhpParser\Error;
use PhpParser\Node\Scalar;
class String_ extends Scalar {
/* For use in "kind" attribute */
public const KIND_SINGLE_QUOTED = 1;
public const KIND_DOUBLE_QUOTED = 2;
public const KIND_HEREDOC = 3;
public const KI... | PHP | {
"end_line": 88,
"name": "parse",
"signature": "public static function parse(string $str, bool $parseUnicodeEscape = true): string {",
"start_line": 71
} | {
"class_name": "String_",
"class_signature": "class String_",
"namespace": "PhpParser\\Node\\Scalar"
} |
parseEscapeSequences | PHP-Parser/lib/PhpParser/Node/Scalar/String_.php | public static function parseEscapeSequences(string $str, ?string $quote, bool $parseUnicodeEscape = true): string {
if (null !== $quote) {
$str = str_replace('\\' . $quote, $quote, $str);
}
$extra = '';
if ($parseUnicodeEscape) {
$extra = '|u\{([0-9a-fA-F]+)\}';
... | <?php declare(strict_types=1);
namespace PhpParser\Node\Scalar;
use PhpParser\Error;
use PhpParser\Node\Scalar;
class String_ extends Scalar {
/* For use in "kind" attribute */
public const KIND_SINGLE_QUOTED = 1;
public const KIND_DOUBLE_QUOTED = 2;
public const KIND_HEREDOC = 3;
public const KI... | PHP | {
"end_line": 132,
"name": "parseEscapeSequences",
"signature": "public static function parseEscapeSequences(string $str, ?string $quote, bool $parseUnicodeEscape = true): string {",
"start_line": 101
} | {
"class_name": "String_",
"class_signature": "class String_",
"namespace": "PhpParser\\Node\\Scalar"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.