Граф коммитов

872 Коммитов

Автор SHA1 Сообщение Дата
Tyson Andre d3e28a76e1 Fix parsing of edge case involving inline HTML
The included test files can be executed.
They will always print the inline HTML,
indicating that PHP is doing the equivalent of inserting semicolons.

Fixes #246

Also, ignore temporary files created by vim
2018-07-28 13:34:16 -07:00
dantleech 6b5e32dae9 Removed hard dependency on phpstan 2018-07-28 09:16:45 +02:00
dantleech 9144a776ad Conditionally execute PHPStan 2018-07-28 09:12:18 +02:00
dantleech 91452da8c3 Made phpstan a dev dep 2018-07-28 08:56:43 +02:00
dantleech 7f0d68bdf0 Fixed type hint and added PHPStan to travis 2018-07-28 08:52:59 +02:00
dantleech 77043f0a09 Removed docblock type hints and added real type hints 2018-07-28 08:40:34 +02:00
dantleech 0ab36a5f67 Only set byRegToken on AssignmentExpression 2018-07-28 08:39:28 +02:00
dantleech 2932721cb2 Added doc-block type hints 2018-07-28 08:38:41 +02:00
dantleech 1362730919 Added param type hint 2018-07-28 08:29:31 +02:00
dantleech 602fb5244e Set parent property type on namespace definition 2018-07-28 08:29:17 +02:00
dantleech 7e57c194f4 Ignore false-positives from PHPStan 2018-07-28 08:20:47 +02:00
dantleech c28b34b5e5 Removed reference to potentially undefined variable 2018-07-28 07:58:50 +02:00
dantleech 531d8bd5a2 Added missing CHILD_NAMES constant from abstract class 2018-07-28 07:52:12 +02:00
dantleech 1bf3dbbbc6 Added PHPStan dep 2018-07-28 07:51:48 +02:00
Rob Lourens 58814f104f
Merge pull request #251 from dantleech/qualified_name_string_return
Added missing string return type for QualfiedName#getResolvedName
2018-07-27 09:59:32 -07:00
dantleech fc3373c203 Added missing string return type for QualfiedName#getResolvedName 2018-07-27 08:59:35 +02:00
Rob Lourens 5123f9c190
Merge pull request #250 from TysonAndre/fix-php7.3.0alpha4
Fix notices seen in PHP 7.3.0alpha4 (but not alpha3)
2018-07-22 19:40:41 -07:00
Tyson Andre f3fcb1f637 Fix notices seen in PHP 7.3.0alpha4
vendor/microsoft/tolerant-php-parser/src/Parser.php:1037 [2]
    "continue" targeting switch is equivalent to "break".
    Did you mean to use "continue 2"
2018-07-20 10:42:25 -07:00
Rob Lourens bce97ae2fc
Merge pull request #245 from TysonAndre/fix-short-echo
Fixes #220 : Properly parse expression lists passed to `<?=`
2018-06-11 16:33:48 -07:00
Tyson Andre 80071b4d1e Work on properly parsing the expression lists passed to `<?=`
Before, tolerant-php-parser parsed the tokens after `<?=` and `<?php`
the same way.

Fixes #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)
2018-06-08 19:56:53 -07:00
Rob Lourens 01479d7e0a
Merge pull request #244 from TysonAndre/multi-class-catch
Fixes #103: Support parsing multiple exception types
2018-05-26 12:42:09 -07:00
Tyson Andre 60d3fc5d25 Add a missing file 2018-05-12 19:25:35 -07:00
Tyson Andre 59b37a8d25 Fixes #103: Support parsing multiple exception types
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.
2018-05-12 19:25:35 -07:00
Rob Lourens 7647b60b13
Merge pull request #243 from TysonAndre/fix-trait-list
Fixes #190: `insteadof` should be able to accept a name list
2018-05-12 12:12:14 -07:00
Tyson Andre 797f79578d Make remainingTargetNames consistent, avoid php notice
Add a test of parsing an empty `insteadof` clause

Make remainingTargetNames consistently be an empty array instead of null
2018-05-12 12:01:19 -07:00
Tyson Andre f297043862 Fixes #190: `insteadof` should be able to accept a name list
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.
2018-05-12 11:59:13 -07:00
Rob Lourens 31cffdb9ab
Merge pull request #242 from dantleech/at_position_not_return_null
Fixed docblock
2018-04-22 13:45:12 -07:00
dantleech 7d369c2ada Fixed docblock
Said it could return null, when that was not possible.
2018-04-22 16:16:05 +02:00
Rob Lourens 3811d27e0b
Merge pull request #241 from MarTango/martango/update-mac-installation-instructions
Update Mac OS PHP installation instructions
2018-04-14 17:24:51 -07:00
Martin Tang 6d0ebb131c
Update Mac OS PHP installation instructions
The homebrew/php repository has been deprecated, and php formulae have been moved to [homebrew-core](https://github.com/Homebrew/homebrew-core)
2018-04-14 15:32:10 +01:00
Rob Lourens 967243e41d
Merge pull request #239 from kant/patch-1
Typo on #162 & 283
2018-03-18 17:03:45 -06:00
Darío Hereñú eca28485da
Typo on #162 & 283 2018-03-18 00:39:15 -03:00
Rob Lourens 694b1538bb
Merge pull request #228 from TysonAndre/fix-unary-lhs-binary
For #19: Fix an edge case parsing `=` and `instanceof`
2018-03-17 21:12:58 -06:00
Rob Lourens 90dc39fb00
Merge pull request #232 from TysonAndre/fix-empty-yield
Fixes #189 : Fix parsing edge cases in yield statements
2018-03-17 20:57:17 -06:00
Rob Lourens c8e067103f Remove unused TemplateExpression 2018-03-05 16:55:59 -08:00
Rob Lourens 2034b5d36d
Merge pull request #238 from TysonAndre/remove-unused-use-statement
Remove unused use statements
2018-03-05 16:52:19 -08:00
Tyson Andre 4bdd48ca26 Remove unused use statements 2018-03-03 10:24:03 -08:00
Tyson Andre 816ec34fb6 Fixes #189 : Fix parsing edge cases in yield statements
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)
));
```
2018-02-24 23:20:41 -08:00
Rob Lourens faca5af49c
Merge pull request #235 from TysonAndre/fix-backslashes-unix
Fixes #224: Use DIRECTORY_SEPARATOR instead
2018-02-19 15:50:21 +09:00
Rob Lourens 3040143ed6
Merge pull request #234 from TysonAndre/fix-FilePositionMap
Fix bugs and docs of FilePositionMap
2018-02-19 15:48:27 +09:00
Tyson Andre ca23cefc0b Rename unused method to getEndLineCharacterPosition 2018-02-18 22:36:39 -08:00
Tyson Andre dab357fd83 Fixes #224: Use DIRECTORY_SEPARATOR instead 2018-02-18 22:34:14 -08:00
Rob Lourens 1bfbd22a93
Merge pull request #233 from TysonAndre/fix-empty-var
Fixes #188: Fix parsing empty variables
2018-02-19 15:23:54 +09:00
Tyson Andre 8ed14c2f84 Fix bugs and docs of FilePositionMap
I wasn't using some of those APIs for Node/Token,
and didn't notice the incorrect phpdoc/code.
2018-02-15 21:14:54 -08:00
Tyson Andre 0360257ceb Fixes #188: Fix parsing empty variables
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.
2018-02-15 21:00:58 -08:00
Rob Lourens 59351ce2a6 Add license to FilePositionMapTest.php 2018-02-14 10:39:41 -08:00
Rob Lourens 8bbc9a7f81
Merge pull request #212 from TysonAndre/add-FilePositionMap
Efficiently look up lines/columns of many nodes
2018-02-14 10:38:07 -08:00
Rob Lourens cdac5b2405
Merge pull request #226 from TysonAndre/fix-varname
Improve parsing of `${` template strings
2018-02-14 10:16:52 -08:00
Tyson Andre d3deb113ea Address review comments. Add license block.
Also, put opening brace on the same line to be consistent
with pre-existing code
2018-02-11 22:29:57 -08:00
Rob Lourens d3477319ad
Merge pull request #223 from TysonAndre/support-nested-calls
Support parsing nested calls (#175)
2018-02-11 22:17:52 -08:00