Releases: php-type-language/parser
Releases · php-type-language/parser
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)
1.0.1
- A little codestyle improvements
- Actualize dev dependencies
- And other unimportant improvements...
1.0.0
Release! 🚀
1.0.0-RC1
- Add support of variable comparison in conditional expressions
$var1 is $var2 ? T : U
. - Add support or conditional
>
,>=
,<
and<=
comparisons. - Add
Identifier::isVirtual()
method for non-PHP type names. - Add support of
$this
variable reference in any statements. - Complete full support of PHPStorm, Psalm and PHPStan types (Using stubs in functional tests; More than 25000 tests).
- A little grammar improcements.
See https://typelang.dev/language.html for details on all the capabilities of the parser!
Full Changelog: 1.0.0-beta7...1.0.0-RC1
1.0.0-beta7
- Remove json serialization support and simplify code.
Note: Use external serializers instead.
Full Changelog: 1.0.0-beta6...1.0.0-beta7
1.0.0-beta6
- Improve description docblocks.
- Remove
Parser::$lexer
from public scope. - Allow negative offset/limit for
Name::slice()
method. - Remove array AST normalization and simplify nodes.
- Add MOAR unit tests.
Full Changelog: 1.0.0-beta5...1.0.0-beta6