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

872 Коммитов

Автор SHA1 Сообщение Дата
Tyson Andre ce5acf3186 Use PHPDoc `@param string ...$classNames`
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.

Update code to PHPStan Level 3

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

Ignore "should not happen" statement

Bump to level 4

Remove !is_null conditional branch - it always returns Node

NamespaceUseDeclaration#useClauses is technically nullable

NamespaceUseGroupCluase#functionOrConst can be NULL

Add TODO

Removed redundant condition (check)

Add return type

Add retutn type, remove inaccurate docblock

Fix bug with get string literal text, as it returned the quotes

Ignore assumed false-positive from PHPStan

If allowEmptyElements if `false`...

... then it MUST be true in the right hand side of ||

backslash can be NULL

BinaryExpresionOrHigher can return MIssingToken

Ignoring error to be safe (as commented) and more type hints

Set level to 4

Add explanation
2023-01-05 23:50:26 +00:00
Rob Lourens 6bd3e3ba00
Merge pull request #385 from dantleech/phpstan-level-3
PHPStan Level 3
2022-11-21 14:14:04 -08:00
Daniel Leech 937564f03f Update code to PHPStan Level 3
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
2022-10-08 10:49:43 +02:00
Rob Lourens 3eccfd2733
Merge pull request #387 from TysonAndre/exclude-github-directory
Exclude phpstan.neon and .github directories from packages
2022-10-05 10:30:19 -07:00
Rob Lourens 2e6da2eb8a
Merge pull request #389 from TysonAndre/halt-compiler-fix
Fix handling of HaltCompilerStatement
2022-10-05 10:29:34 -07:00
Rob Lourens e966047bed
Merge pull request #391 from dantleech/gh-390
Fix regression with getNamespacedName()
2022-10-05 10:21:19 -07:00
Daniel Leech ec763b3641 Fix regression 2022-10-03 19:06:18 +02:00
Tyson Andre 8d3d0bbf59 Put opening brace on the same line as the method 2022-09-26 09:09:01 -04:00
Tyson Andre d9e3877127 Make HaltCompilerStatement inline html start=fullStart
Include whitespace before the data as part of the data for invalid ASTs.
2022-09-25 19:05:27 -04:00
Tyson Andre 2218a406a9 Add test of invalid __halt_compiler without args
All properties should be MissingTokens and non-null
2022-09-25 15:20:50 -04:00
Tyson Andre 91435773f8 Rename local variable to $haltCompilerStatement 2022-09-25 15:16:12 -04:00
Tyson Andre 525acedf12 Fix handling of HaltCompilerStatement
Make it easier to calculate `__COMPILER_HALT_OFFSET__`.
Related to #381

Address other edge cases
2022-09-25 15:15:27 -04:00
Tyson Andre d0a5548012 Exclude phpstan.neon and .github directories from packages
Exclude these files/directories when publishing releases to composer.
.github only contains files for GitHub workflows (CI) right now.
2022-09-25 09:01:51 -04:00
Rob Lourens a35ec03ed3
Merge pull request #384 from TysonAndre/classNames-nit
Use PHPDoc `@param string ...$classNames`
2022-09-24 19:22:28 -07:00
Rob Lourens 101689060f
Merge pull request #383 from TysonAndre/source-file-node-nit
Change getUri return type to nullable string
2022-09-24 19:17:21 -07:00
Rob Lourens ba1f1e804b
Merge pull request #382 from TysonAndre/halt-compiler-support
Support `__halt_compiler` statement
2022-09-24 19:16:25 -07:00
Rob Lourens 6f49c640c0
Merge pull request #379 from TysonAndre/fix-base-clause
Add MissingToken for missing QualifiedName
2022-09-24 19:03:22 -07:00
Rob Lourens 9d9b602dc0
Merge pull request #380 from TysonAndre/speed-up-validation-suite
Speed up running the framework validation test suite
2022-09-24 18:43:16 -07:00
Rob Lourens 735ce08380
Merge pull request #378 from TysonAndre/update-syntax-visualizer
Update example ast output to latest version's output
2022-09-24 18:35:28 -07:00
Tyson Andre 107ac4aded Use PHPDoc `@param string ...$classNames`
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.
2022-09-22 08:52:08 -04:00
Tyson Andre 8ed21ce428 Change getUri return type to nullable string
`Parser::parseSourceFile()` accepts a nullable string $uri.
Avoid a potential type error
2022-09-22 08:44:13 -04:00
Tyson Andre 8e63602b22 Remove unused use statement 2022-09-22 08:40:02 -04:00
Tyson Andre a036846945 Support `__halt_compiler` statement
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 #381
2022-08-27 08:41:01 -04:00
Tyson Andre da1f15e5e1 Speed up running the framework validation test suite
1. We're parsing thousands of files and there are many tokens per file.
   The overhead of all the assert statements is noticeable.
   Optimizing out the check speeds this up 3x from 90 seconds to 30 seconds.
2. Don't write files only to unlink them later.
   Instead, save the failed file only on test suite failure
2022-08-26 18:59:33 -04:00
Tyson Andre 7e6cb20fec Add MissingToken for missing QualifiedName
And emit a diagnostic - these would be parse errors in php
2022-08-26 18:37:16 -04:00
Tyson Andre ca842b44ba Update example syntax-visualizer output to latest version 2022-08-25 21:09:24 -04:00
Rob Lourens a60544ed0a
Merge pull request #375 from TysonAndre/8.2-union-of-intersection
Support php 8.2 `A|(B&C)` dnf types
2022-08-25 16:22:39 -05:00
Rob Lourens 49058c4146
Merge pull request #374 from TysonAndre/support-never
Support php 'never' type, change parsing of 'void'
2022-08-25 14:05:12 -05:00
Tyson Andre 15362b1e8f Remove impossible check for empty list
AmpersandToken would only occur on odd numbered offsets
2022-08-23 08:27:01 -04:00
Tyson Andre 0d46605f06 Add test cases of void/never in parameter types 2022-08-23 08:11:51 -04:00
Tyson Andre c940402c01 Support php 'never' type, change parsing of 'void'
Similar to 'void', it's a compile time error to use void as a
parameter/property type, not a parse time error.
But `static` is a parse error.
(It can also be used in union types)

Remove redundant tokens added to merged returnTypeDeclarationTokens

Closes #373
Closes #372
2022-08-23 08:09:44 -04:00
Tyson Andre ca256f14d9 Remove inapplicable TODOs 2022-08-23 08:06:18 -04:00
Tyson Andre 3b81f38fee Fix parent node set when parsing union types 2022-08-23 08:06:18 -04:00
Tyson Andre 81790cde8b Stricten error checking in parsing union types/intersection types 2022-08-23 08:06:18 -04:00
Tyson Andre 18d7801aa3 Support php 8.2 `A|(B&C)` dnf types
Support php 8.2's Disjunctive Normal Form Types
(allowing parenthesized intersection types of 2 or more types in union types)
https://wiki.php.net/rfc/dnf_types

Closes #372
2022-08-23 08:06:17 -04:00
Rob Lourens 12612753fb
Merge pull request #370 from TysonAndre/test-8.1
Set up github workflows for multiple php versions
2022-08-22 23:06:17 -05:00
Tyson Andre dd25257480 Add .sh extension to run_tests files 2022-08-18 18:57:24 -04:00
Tyson Andre 6a89b5cab5 Set up github workflows for multiple php versions
Run this alongside Travis CI
2022-08-18 18:56:10 -04:00
Rob Lourens 9bf66371b9
Merge pull request #368 from TysonAndre/php8.2-features
Support php 8.2 readonly classes, constants in traits, `true` type
2022-08-18 12:08:00 -05:00
Rob Lourens e42180cb9a
Merge pull request #371 from TysonAndre/test-8.1-travis
Start testing in php 8.1 in travis
2022-08-18 11:37:39 -05:00
Rob Lourens a2f34af5f2
Merge pull request #369 from TysonAndre/remove-todo-230
Remove a TODO that no longer applies in php 8.0
2022-08-18 11:35:54 -05:00
Tyson Andre f08d13385e Start testing in php 8.1 in travis 2022-08-10 20:35:44 -04:00
Tyson Andre af944a3742 Remove a TODO that no longer applies in php 8.0
Any expression can be used as of 8.0 without an unexpected syntax error.

In encapsulated strings,
`"${a->prop}"` is equivalent to `"{${(a->prop)}}"` in php 8.0 and a
syntax error in previous php versions.

(Get the property `prop` of the global constant `a` (constants can be
objects in php 8.1), then get the variable with the name equal to that
string)
2022-08-10 19:35:18 -04:00
Tyson Andre 7ff8145300 Support php 8.2 true type
https://wiki.php.net/rfc/true-type
2022-08-08 20:26:50 -04:00
Tyson Andre 17a63a0e33 Add tests of php 8.2 constants in traits 2022-08-08 20:26:50 -04:00
Tyson Andre db0840e22b Update test expectations, test readonly class 2022-08-08 20:26:40 -04:00
Tyson Andre 2ba725bc6f Support PHP 8.2 features 2022-08-08 20:26:40 -04:00
Rob Lourens ecc2be15c1
Merge pull request #366 from zobo/fix-match-keyword
fix: add match to keywords
2022-06-24 09:16:11 -07:00
Damjan Cvetko 477b35899e
fix: add match to keywords 2022-06-24 11:04:59 +02:00
Rob Lourens f4f5e93032
Merge pull request #364 from dantleech/callable_function
callableExpression can also be a QualifiedName...
2022-01-03 16:54:28 -08:00