Releases: php-type-language/parser
Releases · php-type-language/parser
1.5.0
Optimize and improve parameters grammar
- Added support of untyped/named parameters.
- The following formats are now available:
callable($var)
- Only named parametercallable(...$var)
- Variadic named parametercallable($var...)
- Variadic named parametercallable(&$var...)
- Output variadic named parametercallable(&...$var)
- Output variadic named parametercallable(...&$var)
- Output variadic named parametercallable($var=)
- Named parameter with defaultcallable(&$var=)
- Output named parameter with default
- The following formats are now available:
- Improve typed parameters syntax.
- The following formats are now available:
callable(T)
- Typed parametercallable(...T)
- Variadic typed parametercallable(...T&)
- Output variadic typed parametercallable(T...)
- Variadic typed parametercallable(T&...)
- Output variadic typed parametercallable(T...&)
- Output variadic typed parameter
- The following formats are now available:
- Improve typed named parameters syntax.
- The following formats are now available:
callable(...T &$var)
- Output variadic typed named parametercallable(T &$var)
- Output typed parametercallable(T &$var=)
- Output typed named parameter with defaultcallable(T ...&$var)
- Output variadic typed named parametercallable(T &...$var)
- Output variadic typed named parameter
- The following formats are now available:
1.4.3
1.4.2
- AttributeNode is no longer a Statement
1.4.1
- Upgraded phpstan from 1.x to 2.x
- Upgraded phpstan level from
9
tomax
- Fixed linter errors
- Upgraded phpstan level from
- Removed unused rector dev-depenendency
Full Changelog: 1.4.0...1.4.1
1.4.0
- Added type offsets (see: https://typelang.dev/offset-access.html)
- Added type offsets feature toggling (see: https://typelang.dev/features.html#offsets)
- Renamed
ParameterXxx
AST node toCallableParameterXxx
(using soft deprecation). - Fixed PHP 8.4 deprections in unit tests.
- Fixed "decimal" value representation in
IntLiteralNode
.
Full Changelog: 1.3.0...1.4.0
1.3.0
- Added support for correct recognition and conversion of arbitrary int numbers to the decimal base.
- Also added getting the original (string) decimal value for more convenient use in
ext-bcmath
andext-gmp
libraries.- Added method
TypeLang\Parser\Node\Literal\IntLiteralNode::getValueAsDecimalString()
- Added similar public readonly property
TypeLang\Parser\Node\Literal\IntLiteralNode::$decimal
- Added method
- Fix recognition of negative
-9223372036854775808
(and-2147483648
) integer linteral.- Similar behavior applies to octal, binary, and hexadecimal values.
This behavior differs from PHP
PHP
PHP Example (int64 min)
-9223372036854775808;
// Result:
// -9.2233720368548E+18
PHP Behaviour
- parse
9223372036854775808
- overflow
- cast
9223372036854775808
to float9.2233720368548E+18
- apply unary minus to
9.2233720368548E+18
- result is
-9.2233720368548E+18
See: php/doc-en#2400
TypeLang
TypeLang Example 1 (int64 min)
$parser->parse('-9223372036854775808');
// Result:
// TypeLang\Parser\Node\Literal\IntLiteralNode {
// +offset: 0
// +raw: '-9223372036854775808'
// +decimal: '-9223372036854775808'
// +value: -9223372036854775808
// }
TypeLang Behaviour
- parse
-9223372036854775808
- fetch sign (minus "
-
" and value "9223372036854775808
") - apply base conversion (
16
,8
or2
to10
) - compare sign and 10-base number to
PHP_INT_MIN
- return
PHP_INT_MIN
as parsed value - cast value to
int
instead. Loss of precision may occur, in such cases the user should use the original value.
TypeLang Example 2 (int128 hexadecimal min)
$parser->parse('-0xFFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF');
// Result:
// TypeLang\Parser\Node\Literal\IntLiteralNode {
// +offset: 0
// +raw: '-0xFFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF_FFFF'
// +decimal: '-340282366920938586008062602462446642046'
// +value: -9223372036854775808
// }
Note that large number extensions (like
ext-gmp
orext-bcmath
) are not required to recognize such numbers.
1.2.1
- Fix
Node\Identifier
traversing insideNode\Name
class node.
1.2.0
- Added callable parameter attributes:
Example\Functor(#[example_attr] Type $var): void
1.1.0
- Added shape field attributes:
array { #[example_attr] key: Type }
- Added template argument attributes:
Example\Type<#[example_attr] Type, #[out] U>
- Rename
TypeLang\Parser\Node\Stmt\Template\ArgumentXxxx
toTypeLang\Parser\Node\Stmt\Template\TemplateArgumentXxxx
Don't worry, the old name will still work. The renaming is done to avoid class conflicts (it's more convenient for autocomplete) of names in the future.
- Upgrade phplrt version to
^3.7
1.0.2
- Bump parser runtime version (phplrt 3.6 -> 3.7)