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

820 Коммитов

Автор SHA1 Сообщение Дата
Rob Lourens ff5dda4b8f
Merge pull request #298 from TysonAndre/fix-ternary-precedence
Fix associativity of ternary operation parsing
2019-08-02 15:31:26 -07:00
Tyson Andre 75189fd29b Fix associativity of ternary operation parsing
Fixes #297
2019-07-28 10:09:01 -04:00
Rob Lourens e255aa978b
Merge pull request #295 from TysonAndre/fix-namespace-expr-in-arglist
Fix namespace expression usage in arg list
2019-06-30 19:21:00 -07:00
Rob Lourens 0cf8b8450a
Merge pull request #294 from TysonAndre/arrow-spread-operator
Support the array spread operator
2019-06-30 18:56:09 -07:00
Rob Lourens 5457e822b2
Merge pull request #293 from TysonAndre/parse-arrow-function
Support parsing PHP 7.4's arrow functions
2019-06-30 18:55:17 -07:00
Tyson Andre d0786c4f66 Fix namespace expression usage in arg list
Fixes #292
2019-06-11 10:08:53 -04:00
Tyson Andre 3f4f381cf3 Support the array spread operator
- An alternate approach would be to make arrayElementList contain a class
  that is either an ArrayElement or an UnpackExpression (new Node used
  only for this).

  That would also work for me,
  but changing ArrayElement seemed simpler and less likely to cause crashes in
  other existing applications.

Add tests of this operator and error handling.

See https://wiki.php.net/rfc/spread_operator_for_array
2019-05-20 12:27:59 -04:00
Tyson Andre 2836a80f87 Support parsing PHP 7.4's arrow functions
This requires PHP 7.4-dev from May 2nd or later.

Add various test cases of this working,
as well as tests of error tolerance.

Fixes #291
2019-05-11 21:26:58 -04:00
Rob Lourens c74eb57ee5
Merge pull request #289 from TysonAndre/fix-typo-var
nit: Fix a typo in a variable name
2019-03-24 20:06:24 -07:00
Rob Lourens 8e6d4a3550
Merge pull request #287 from TysonAndre/optimize-tokenizing
Optimizations to PhpTokenizer
2019-03-24 20:05:54 -07:00
Tyson Andre 77cc4df2d0 Fix a typo in a variable name 2019-03-24 22:51:49 -04:00
Rob Lourens ffeaf03e0a
Fix #288 2019-03-14 08:44:05 -07:00
Tyson Andre 23cdc01ee5 Optimizations to PhpTokenizer
Speeds up parsing speed by a few percentage points.

- Move skipping prefix out of the loop.
  It isn't used except when getting doc comments, which is much less
  common than getting all tokens
- Handle strings separately from arrays in token_get_all.
- Move `if` within a switch to its own case.
2019-03-11 09:03:59 -04:00
Rob Lourens 51b16ef0d5
Merge pull request #286 from TysonAndre/parse-optimize
Minor optimizations to Parser
2019-03-10 21:14:53 -07:00
Tyson Andre b1377e238a Minor optimizations to Parser 2019-03-10 14:02:11 -04:00
Rob Lourens 89386de8de
Merge pull request #282 from TysonAndre/force-assignment-expression
Properly parse @$x += $y as @($x += $y)
2019-03-09 11:24:59 -08:00
Tyson Andre 0a96f2e931 Properly parse @$x += $y as @($x += $y)
Fixes one edge case in #19

Also, fix parsing of `@$x instanceof $y`.
My earlier PR fixed `!$x instanceof $y` but broke that.
2019-03-09 14:10:34 -05:00
Rob Lourens 97bc57e7a3
Merge pull request #284 from TysonAndre/annotate-token-type
Annotate the types on Token
2019-03-09 10:53:27 -08:00
Tyson Andre 9917efeeac Annotate the types on Token
This makes static analyzers of this code and code using it more
effective at catching bugs.
2019-03-08 17:12:51 -05:00
Rob Lourens 27aec73adf
Merge pull request #281 from TysonAndre/questionquestionequals
Support parsing `??=` (only supports php 7.4)
2019-02-24 12:47:38 -08:00
Rob Lourens d3e6a0ed2c
Merge pull request #283 from TysonAndre/micro-optimize
Add micro-optimizations
2019-02-23 20:17:26 -08:00
Tyson Andre 2c62c5cfd5 Add micro-optimizations 2019-02-23 13:28:30 -05:00
Tyson Andre f74cd0c685 Support parsing `??=` (only supports php 7.4)
This is due to limitations of the lexer and token_get_all().
It's possible to manually add compatibility
by joining adjacent `??` and `=` tokens if `??=`
occurs anywhere in the file contents.

- I'm not sure if this project would choose to do that.
  Right now, it doesn't have a way to provide the target PHP version.
- T_COALESCE_EQUAL is a new constant; add a substitute for older PHP
  versions

Fixes #277
2019-02-19 20:24:01 -05:00
Rob Lourens 2676462484
Merge pull request #279 from TysonAndre/misc-nits
Fix typo, remove unused 'use' statement
2019-02-17 10:30:57 -08:00
Rob Lourens c2d332e25b
Merge pull request #280 from TysonAndre/patch-1
Use fully qualified substr in Token.php
2019-02-17 10:30:29 -08:00
Rob Lourens db476e97f3
Merge pull request #278 from TysonAndre/parse-property-declaration
Implement support for parsing php 7.4 typed properties
2019-02-17 10:28:53 -08:00
Tyson Andre aeaf4f8fdb
Use fully qualified substr in Token.php
Token->getText() will probably be called frequently in some applications.

This is slightly more efficient; the php interpreter can cache the address of the C implementation when the function is unambiguous.
2019-02-10 18:19:58 -05:00
Tyson Andre 9d7f8aef2e Implement support for parsing php 7.4 typed properties
Add tests of typed properties and tolerating errors in edge cases.

To maintain invariants
(and to avoid creating PropertyDeclaration without a name),
the questionToken and type were added to MissingMemberDeclaration.

Fixes #276
2019-02-07 20:22:15 -05:00
Tyson Andre 4058fa7a3b Fix typo, remove unused 'use' statement 2019-02-07 20:14:49 -05:00
Rob Lourens b662587eb7
Merge pull request #268 from TysonAndre/parsing-precedence-fixes
Bug fixes for parsing associativity
2018-12-28 18:31:32 -06:00
Tyson Andre c64dbb20af Bug fixes for parsing associativity
This fixes the most common cases for #19
(there may be other edge cases I haven't considered yet)

This also fixes incorrect precedence for `<=>`.
It has the same precedence as `==` -
https://secure.php.net/manual/en/language.operators.precedence.php
has correct information for the `<=>` operator.
2018-12-04 21:46:31 -05:00
Rob Lourens a266248840
Merge pull request #265 from carusogabriel/in_array
Use in_array instead of array_search + comparison
2018-10-31 09:19:47 -07:00
Rob Lourens 9f13272e85
Merge pull request #264 from carusogabriel/phpstan-file
Move PHPStan configuration to its file
2018-10-31 09:18:55 -07:00
Gabriel Caruso b20df05d62
Use in_array instead of array_search + comparison 2018-10-31 10:09:18 -03:00
Gabriel Caruso 57e84c07f2
Move PHPStan configuration to its file 2018-10-31 09:50:59 -03:00
Rob Lourens 0818b70edd
Merge pull request #263 from WyriHaximus/patch-1
Test against (upcoming) PHP 7.3 on Travis
2018-10-30 13:43:09 -07:00
Cees-Jan Kiewiet 3b098b3313
Ignore phpenv error when xdebug.ini doesn't exists 2018-10-30 20:13:55 +01:00
Cees-Jan Kiewiet 88c0fd80cd
Test against (upcoming) PHP 7.3 on Travis 2018-10-30 19:52:38 +01:00
Rob Lourens 54a84f1250
Merge pull request #260 from TysonAndre/fix-trait-use-notice
Fix a PHP notice generating a scoped property access expression
2018-09-25 22:43:26 -07:00
Rob Lourens 4580d0ea89
Merge pull request #261 from TysonAndre/unset-not-subexpression
Only allow parsing unset() as a top-level statement
2018-09-25 18:49:33 -07:00
Tyson Andre c9a8793682 Only allow parsing unset() as a top-level statement
E.g. `unset($x)/2` is a syntax error.
Previously, this parser would not treat that as a syntax error.

This is similar to how `echo` can only be used as a top level statement.

- Tools using this parser may expect `unset` only as a top level statement

See
https://secure.php.net/manual/en/function.unset.php#refsect1-function.unset-notes
2018-09-23 23:16:34 -04:00
Tyson Andre 9463cfc86b Fix a PHP notice generating a scoped property access expression
And add a unit test
2018-09-23 14:55:54 -04:00
Rob Lourens 7ea773435b
Merge pull request #259 from TysonAndre/fix-typo
Fix typos
2018-09-09 18:10:27 -07:00
Tyson Andre 40d1b6e8e6 Fix typos 2018-09-09 16:27:49 -04:00
Rob Lourens ed2aaa1325
Merge pull request #258 from TysonAndre/fix-ternary-notice
Fix a notice in Parser->parseTernaryExpression()
2018-09-02 19:59:17 -07:00
Tyson Andre 4155326431 Fix a notice in Parser->parseTernaryExpression()
Fixes #257
2018-09-02 18:09:40 -04:00
Rob Lourens 89ade271e6
Merge pull request #253 from TysonAndre/fix-inline-html-edge-case
Fix parsing of edge case involving inline HTML
2018-08-06 21:52:21 -07:00
Rob Lourens e88881b2b7
Merge pull request #252 from dantleech/phpstan
RFC: Static analysis fixes
2018-08-02 11:03:33 -07:00
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