forked from microsoft/tolerant-php-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
Phpstan Level 4 (depends PHPStan Level 3) #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dantleech
wants to merge
328
commits into
master
Choose a base branch
from
phpstan-level-4
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Previously, the fallback case when something beginning with the token `$` wasn't a simple variable would be to assume it would be a complex variable such as `$$x` Check that the first token would be valid before recursing.
I wasn't using some of those APIs for Node/Token, and didn't notice the incorrect phpdoc/code.
Fixes microsoft#188: Fix parsing empty variables
Fix bugs and docs of FilePositionMap
Fixes microsoft#224: Use DIRECTORY_SEPARATOR instead
Update tests diagnostics and expected generated ASTs For backwards compatibility, continue to make `yield from expr` have an ArrayElement as a child node. To maintain the invariant that all Nodes must have at least one child, make $yieldExpression->arrayElement be null when parsing `yield;` Aside: `yield &$a;` is (and should be) parsed as the binary operator `(yield) & ($a)`. This is surprising, but makes sense, being the only sane parse tree. - Add a unit test that `yield & &$a;` is invalid. There is no way to parse that. Verified with the PHP module nikic/php-ast ```php var_export(ast_dump( ast\parse_code('<?php function test() { yield & $x; }', 50) )); ```
…atement Remove unused use statements
Fixes microsoft#189 : Fix parsing edge cases in yield statements
For microsoft#19: Fix an edge case parsing `=` and `instanceof`
Typo on microsoft#162 & 283
The homebrew/php repository has been deprecated, and php formulae have been moved to [homebrew-core](https://github.com/Homebrew/homebrew-core)
…stallation-instructions Update Mac OS PHP installation instructions
Said it could return null, when that was not possible.
…n_null Fixed docblock
Do this in a way that makes it less likely that applications already using targetName will throw an exception or error. This should be revisited in a future backwards incompatible release. Add remainingTargetNames as a new property. NOTE: traits16.php is invalid php 7 code, so traits16.php.diag should be non-empty. However, tolerant-php-parser emits a slightly different error message than `php -l` would.
Add a test of parsing an empty `insteadof` clause Make remainingTargetNames consistently be an empty array instead of null
Fixes microsoft#190: `insteadof` should be able to accept a name list
Add a new array `otherQualifiedNameList` alongside qualifiedName to `CatchClause`. (Contains remaining `Token`s and `QualifiedName`s) (This design breaks backwards compatibility as little as possible) - A future backwards incompatible release should merge the two properties into `qualifiedNameList`, or something along those lines. Add a new helper method to parse the catch list. - The new helper is required because `tests/cases/php-langspec/exception_handling/odds_and_ends.php` should not fail because `catch (int $e)` is **syntactically** valid php (in 7.x), i.e. `php --syntax-check` doesn't reject it.
Fixes microsoft#103: Support parsing multiple exception types
Before, tolerant-php-parser parsed the tokens after `<?=` and `<?php` the same way. Fixes microsoft#220 (This commit and subsequent commits in this PR) This adds `TokenKind::ScriptSectionStartWithEchoTag` and handles the subsequent tokens differently if that token kind is seen instead of `ScriptSectionStartTag`. This reuses `ExpressionStatement` with an `EchoExpression` for simplicity. The resulting expression will have no `echoKeyword` because `<?=` was part of the preceding `InlineHTML` Node. - In all cases that I'm aware of, the ExpressionStatement with the EchoExpression will be moved into the outer statement list. NOTE: echo is a statement, not an expression. It must be followed by `?>` or `;` - `echo exprList` can't be used as an expression. - Contrast with `print expr`, (`PrintIntrinsicExpression`), which is correctly treated as an expression. Update documentation Add a test that the Parser will warn about `<?= 'expr'<EOF>`. - Fixing that bug got rid of an incorrect EmptyExpression in another test (programStructure5.php.tree)
Fixes microsoft#220 : Properly parse expression lists passed to `<?=`
vendor/microsoft/tolerant-php-parser/src/Parser.php:1037 [2] "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"
Fix notices seen in PHP 7.3.0alpha4 (but not alpha3)
https://www.php.net/manual/en/function.halt-compiler.php can be used to embed data in php scripts from the outermost scope. In inner scope, it is parsed in php-src only for the sake of error messages about it needing to be in the outermost scope, so treat it as an unexpected token in other contexts. (In an inner `{...}` scope, the call to `token_get_all()` will still stop after `__halt_compiler();`, returning T_INLINE_HTML, so the remaining statements can't be parsed, anyway) Additionally, `__halt_compiler` can't be used as a name, a member name (e.g. method name), etc, so calling it `TokenKind::Name` seems incorrect. (`__COMPILER_HALT_OFFSET__` is already properly a Name) Closes microsoft#381
`Parser::parseSourceFile()` accepts a nullable string $uri. Avoid a potential type error
The `string` is the type of each argument. The `...` indicates that it is an array of that type, like `function (string ...$classNames)` also would indicate.
…izer Update example ast output to latest version's output
…suite Speed up running the framework validation test suite
Add MissingToken for missing QualifiedName
Support `__halt_compiler` statement
Change getUri return type to nullable string
Use PHPDoc `@param string ...$classNames`
Added ReturnTypeWillChange Fix return type for Expression Add type hints for returned variables Add generic parameter for delimted list Fixing type hints Ignore co-variance error Remove TODO - it already must always be a Node Ignore error Add missing types Update phpstan to level 3 Add phpstan to dev reqs No need to install phpstan independently Do not override unary expression operand It seems to me that the operand can be any expression Added token to operand types -- should this be MissingToken? Include tokens in return types ExpressionStatement => EchoStatement It seems this is always an EchoStatement not an ExpressionStatement unaryExpressionOrHigher can return a ThrowExpression Remove overridden property Add Token to union Remove QualifiedName and rename local variable Remove unused import Add return types Remove trailing whitespace Add MissingToken type
... then it MUST be true in the right hand side of ||
0145399
to
937564f
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Depends on microsoft#385