Home
last modified time | relevance | path

Searched refs:is (Results 1 – 25 of 36) sorted by relevance

12

/PHP-Parser/test/PhpParser/
H A DTokenTest.php15 $this->assertTrue($token->is(\ord(',')));
16 $this->assertFalse($token->is(\ord(';')));
17 $this->assertTrue($token->is(','));
18 $this->assertFalse($token->is(';'));
19 $this->assertTrue($token->is([\ord(','), \ord(';')]));
20 $this->assertFalse($token->is([\ord('!'), \ord(';')]));
21 $this->assertTrue($token->is([',', ';']));
22 $this->assertFalse($token->is(['!', ';']));
/PHP-Parser/test/code/parser/expr/
H A DexprInIsset.test4 // This is legal.
6 // This is illegal, but not a syntax error.
22 0: // This is legal.
39 0: // This is illegal, but not a syntax error.
H A DexprInList.test5 // This is legal.
7 // This is illegal, but not a syntax error.
38 0: // This is legal.
65 0: // This is illegal, but not a syntax error.
/PHP-Parser/doc/component/
H A DError_handling.markdown7 How much location information is available depends on the origin of the error. At a minimum the sta…
8 is usually available.
34 …r behavior of the parser (and other components) is controlled by an `ErrorHandler`. Whenever an er…
35 encountered, `ErrorHandler::handleError()` is invoked. The default error handling strategy is `Erro…
36 which will immediately throw when an error is encountered.
49 // $error is an ordinary PhpParser\Error
54 // $stmts is a best-effort partial AST
H A DWalking_the_AST.markdown4 The most common way to work with the AST is by using a node traverser and one or more node visitors.
54 The `enterNode()` method is called when a node is first encountered, before its children are
91 A common pattern is that `enterNode` is used to collect some information and then `leaveNode`
103 and simplest is to simply change AST properties inside the visitor:
114 The second is to replace a node entirely by returning a new node:
143 Finally, there are three special replacement types. The first is removal of a node:
189 This is only safe to do if the subnode the node is stored in is nullable. `Node\Stmt\Else_` only
190 occurs inside `Node\Stmt\If_::$else`, which is nullable, so this particular replacement is safe.
193 only works if the parent structure is an array.
231 leaveNode is reached.
[all …]
H A DPretty_printing.markdown4 Pretty printing is the process of converting a syntax tree back to PHP code. In its basic mode of
7 to be rather picky about their code formatting, this mode of operation is not very suitable for
8 refactoring code, but can be used for automatically generated code, which is usually only read for
24 `prettyPrintExpr()`. The one that is most commonly useful is `prettyPrintFile()`, which takes an
27 `prettyPrint()` also takes a statement array, but produces code which is valid inside an already
37 * `phpVersion` (defaults to 7.4) allows opting into formatting that is not supported by older PHP
41 * `shortArraySyntax` determines the used array syntax if the `kind` attribute is not set. This is
51 * For PHP >= 7.3, a newline is no longer forced after heredoc/nowdoc strings, as the requirement
62 If you want to have more fine-grained formatting control, the recommended method is to combine the
70 portion of the code and leave the remainder alone. The basic pretty printer is not suitable for
[all …]
H A DPerformance.markdown4 Parsing is computationally expensive task, to which the PHP language is not very well suited.
15 As such, you should make sure that Xdebug is not loaded when using this library. Note that setting
17 Xdebug is to not load the extension in the first place.
25 higher level, such as 3000. While the parser itself is recursion free, most other code working on
26 the AST uses recursion and will generate an error if the value of this option is too low.
43 is not reused. (Currently two objects with particularly expensive setup are parsers and pretty
H A DLexer.markdown4 The lexer is responsible for providing tokens to the parser. Typical use of the library does not re…
5 interaction with the lexer, as an appropriate lexer is created by `PhpParser\ParserFactory`. The to…
23 …This means that certain code that is legal on older versions (namespaced names including whitespac…
27 `T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG` or `T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG`. This is req…
30 Finally, `PhpParser\Lexer\Emulative` performs other, optional emulations. This lexer is parameteriz…
31 and will try to emulate `ext/tokenizer` output for that version. This is done using separate `Token…
34 Emulation is usually used to support newer PHP versions, but there is also very limited support for…
55 public function is($kind): bool;
59 Unlike PHP's own `PhpToken::tokenize()` output, the token array is terminated by a sentinel token w…
61 The lexer is normally invoked implicitly by the parser. In that case, the tokens for the last parse…
[all …]
H A DName_resolution.markdown5 relatively complex name resolution process, which is based on the current namespace, the current
14 to their fully-qualified form, to the degree that this is possible.
29 namespace prefix. For historic reasons this is a **property** rather than an attribute.
35 such names are left unresolved. Additionally, a `namespacedName` **attribute** is added to the
47 If the `preserveOriginalNames` option is enabled, then the resolved (fully qualified) name will have
50 If the `replaceNodes` option is disabled, then names will no longer be resolved in-place. Instead, a
53 `resolvedName` attribute will not be present, and instead a `namespacedName` attribute is added.
55 The `replaceNodes` attribute is useful if you wish to perform modifications on the AST, as you
61 The actual name resolution logic is implemented in the `NameContext` class, which has the following
84 The name context is intended to be used for name resolution operations outside the AST itself, such
H A DAST_builders.markdown4 When PHP-Parser is used to generate (or modify) code by first creating an Abstract Syntax Tree and
13 interface. Builders are created using the `BuilderFactory` and the final constructed node is
23 Here is an example:
63 // it is possible to add manually created nodes
141 operation is missing.
/PHP-Parser/test/code/parser/stmt/class/
H A Dname.test5 Cannot use 'self' as class name as it is reserved from 1:13 to 1:16
24 Cannot use 'PARENT' as class name as it is reserved from 1:13 to 1:18
53 Cannot use 'self' as class name as it is reserved from 1:23 to 1:26
74 Cannot use 'PARENT' as class name as it is reserved from 1:23 to 1:28
95 Cannot use 'static' as class name as it is reserved from 1:23 to 1:28
116 Cannot use 'self' as interface name as it is reserved from 1:26 to 1:29
138 Cannot use 'PARENT' as interface name as it is reserved from 1:26 to 1:31
160 Cannot use 'static' as interface name as it is reserved from 1:26 to 1:31
182 Cannot use 'self' as class name as it is reserved from 1:17 to 1:20
199 Cannot use 'PARENT' as class name as it is reserved from 1:17 to 1:22
[all …]
/PHP-Parser/doc/
H A D0_Introduction.markdown4 This project is a PHP parser **written in PHP itself**.
6 What is this for?
9 A parser is useful for [static analysis][0], manipulation of code and basically any other
13 There are other ways of processing source code. One that PHP supports natively is using the
14 token stream generated by [`token_get_all`][2]. The token stream is much more low level than
16 a file. On the other hand, the token stream is much harder to deal with for more complex analysis.
21 Another question is: Why would I want to have a PHP parser *written in PHP*? Well, PHP might not be
42 error. In error recovery mode, it is possible to continue parsing after such declarations.
44 As the parser is based on the tokens returned by `token_get_all` (which is only able to lex the PHP
46 This allows to parse PHP 8.4 source code running on PHP 7.4, for example. This emulation is not
[all …]
H A D2_Usage_of_basic_components.markdown73 // $stmts is an array of statement nodes
173 The additional `_` at the end of the first class name is necessary, because `Function` is a
194 and "expression". This node distinguishes `expr`, which is a `Node\Expr`, from `expr;`, which is
339 The `beforeTraverse()` method is called once before the traversal begins and is passed the nodes the
344 it is called once after the traversal.
347 i.e. before its subnodes are traversed, the latter when it is left.
350 case the current node is not changed.
373 One visitor that is already bundled with the package is `PhpParser\NodeVisitor\NameResolver`. This …
451 is convert `A\\B` style names to `A_B` style ones.
500 The last thing we need to do is remove the `namespace` and `use` statements:
[all …]
/PHP-Parser/
H A DUPGRADE-4.0.md6 PHP-Parser now requires PHP 7.0 or newer to run. It is however still possible to *parse* PHP 5.2-5.6
9 HHVM is no longer actively supported.
17 comparisons or strict-mode may require adjustment. The following is an exhaustive list of all
52 * The `alias` subnode of `UseUse` is now `null` if no explicit alias is given. As such,
54 can be used to get the effective alias, even if it is not explicitly given.
58 * The indentation handling in the pretty printer has been changed (this is only relevant if you
60 `pNoindent()`. Now no-indent is the default and newlines that require indentation should use
75 * The `BuilderAbstract` class has been removed. It's functionality is moved into `BuilderHelpers`.
76 However, this is an internal class and should not be used directly.
H A DUPGRADE-5.0.md12 In particular, if an older `PhpVersion` is specified, then:
55 # After (this is roughly equivalent to PREFER_PHP7 behavior)
280 * `Node\Scalar\LNumber` is now `Node\Scalar\Int_`.
281 * `Node\Scalar\DNumber` is now `Node\Scalar\Float_`.
282 * `Node\Scalar\Encapsed` is now `Node\Scalar\InterpolatedString`.
290 * `Node\Stmt\UseUse` is now `Node\UseItem` and no longer extends `Node\Stmt`.
352 A space is now printed between `use` and the following `(` for closures:
404 …support these changes, precedence is now handled differently in the pretty printer. The internal `…
412is the precedence of the direct parent operator (if any), while `$lhsPrecedence` is that precedenc…
484 public function is(int|string|array $kind): bool;
[all …]
H A DCHANGELOG.md132 `addVisitor()` is no longer required.
136 * The minimum host PHP version is now PHP 7.4. It is still possible to parse code from older
217 version is set to older than PHP 7.0.
241 * PHP 7.1 is now required to run PHP-Parser.
326 argument is a `VariadicPlaceholder`. The representation is intended to be forward-compatible with
501 in namespaced names is not yet present.
805 * The `alias` subnode of `UseUse` is now `null` if no explicit alias is given. As such,
886 * `Name::$parts` is no longer deprecated.
912 * Name resolution of `NullableType`s is now performed earlier, so that a fully resolved signature is
913 available when a function is entered. (#360)
[all …]
H A DUPGRADE-3.0.md14 PHP-Parser now requires PHP 5.5 or newer to run. It is however still possible to *parse* PHP 5.2,
23 * The `Catch` subnode `type` has been renamed to `types` and is now an array of `Name`s.
27 `type` subnode has retained for backwards compatibility and is populated to the same value as
28 `flags`. However, writes to `type` will not update `flags` and use of `type` is discouraged.
36 * `void` and `iterable` types are now stored as strings if the PHP 7 parser is used. Previously
75 As a result of this change, if a `Multiple` parser is used (e.g. through the `ParserFactory` using
80 The PHP 7 parser is a superset of the PHP 5 parser, with the exceptions that `=& new` and
85 It is possible to restore the precise previous behavior with the following code:
149 `\foo()`. For names where no static resolution is possible, a `namespacedName` attribute is
H A DUPGRADE-2.0.md6 PHP-Parser now requires PHP 5.4 or newer to run. It is however still possible to *parse* PHP 5.2 and
36 For most practical purposes the difference between `PREFER_PHP7` and `PREFER_PHP5` is mainly whether
50 `PhpParser\Parser` is now an interface, which is implemented by `Parser\Php5`, `Parser\Php7` and
H A DUPGRADE-1.0.md6 PHP-Parser now requires PHP 5.3 or newer to run. It is however still possible to *parse* PHP 5.2 so…
33 is now `PhpParser\Node\Stmt\Class_`. (But as usual, the old name is still available.)
100 …tyPrinterAbstract::pStmts()` method now emits a leading newline if the statement list is not empty.
H A DCONTRIBUTING.md3 This project uses PSR-12 with consistent brace placement. This means that the opening brace is
28 6. Add support for formatting-preserving pretty-printing. This is done by modifying the data tables
/PHP-Parser/lib/PhpParser/Internal/
H A DTokenStream.php66 if ($token->is($expectedTokenType)) {
91 if ($token->is($expectedTokenType)) {
110 if (!$tokens[$pos]->is($skipTokenType)) {
128 if (!$tokens[$pos]->is($skipTokenType)) {
173 if ($tokens[$pos]->is($findTokenType)) {
191 if ($tokens[$pos]->is($tokenType)) {
/PHP-Parser/test/code/parser/stmt/namespace/
H A DinvalidName.test5 Cannot use A as self because 'self' is a special class name from 1:16 to 1:19
25 Cannot use B as PARENT because 'PARENT' is a special class name from 1:16 to 1:21
/PHP-Parser/lib/PhpParser/
H A DLexer.php61 return $token->is([\T_COMMENT, \T_DOC_COMMENT])
95 $tokens[$next]->is([\T_VARIABLE, \T_ELLIPSIS]);
/PHP-Parser/grammar/
H A DREADME.md11 The `.y` file is a normal grammar in `kmyacc` (`yacc`) style, with some transformations
14 * Nodes are created using the syntax `Name[..., ...]`. This is transformed into
/PHP-Parser/test/code/parser/errorHandling/
H A Drecovery.test259 // is always required.
572 A trailing comma is not allowed here from 5:6 to 5:6
573 A trailing comma is not allowed here from 6:13 to 6:13
574 A trailing comma is not allowed here from 8:21 to 8:21
575 A trailing comma is not allowed here from 9:10 to 9:10
576 A trailing comma is not allowed here from 10:10 to 10:10
577 A trailing comma is not allowed here from 11:25 to 11:25
578 A trailing comma is not allowed here from 13:17 to 13:17
579 A trailing comma is not allowed here from 14:14 to 14:14
584 A trailing comma is not allowed here from 25:8 to 25:8
[all …]

Completed in 46 milliseconds

12