Skip to content

Releases: php-type-language/parser

1.3.0

09 Nov 03:56
Compare
Choose a tag to compare
  • 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 and ext-gmp libraries.
    • Added method TypeLang\Parser\Node\Literal\IntLiteralNode::getValueAsDecimalString()
    • Added similar public readonly property TypeLang\Parser\Node\Literal\IntLiteralNode::$decimal
  • 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

  1. parse 9223372036854775808
  2. overflow
  3. cast 9223372036854775808 to float 9.2233720368548E+18
  4. apply unary minus to 9.2233720368548E+18
  5. 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

  1. parse -9223372036854775808
  2. fetch sign (minus "-" and value "9223372036854775808")
  3. apply base conversion (16, 8 or 2 to 10)
  4. compare sign and 10-base number to PHP_INT_MIN
  5. return PHP_INT_MIN as parsed value
  6. 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 or ext-bcmath) are not required to recognize such numbers.

1.2.1

27 Sep 03:39
Compare
Choose a tag to compare
  • Fix Node\Identifier traversing inside Node\Name class node.

1.2.0

27 Sep 01:34
Compare
Choose a tag to compare
  • Added callable parameter attributes:
Example\Functor(#[example_attr] Type $var): void

1.1.0

26 Sep 22:41
Compare
Choose a tag to compare
  • 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 to TypeLang\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

11 Sep 01:06
Compare
Choose a tag to compare
  • Bump parser runtime version (phplrt 3.6 -> 3.7)

1.0.1

01 Jul 08:48
Compare
Choose a tag to compare
  • A little codestyle improvements
  • Actualize dev dependencies
  • And other unimportant improvements...

1.0.0

15 Apr 19:23
Compare
Choose a tag to compare

Release! 🚀

1.0.0-RC1

12 Apr 19:57
Compare
Choose a tag to compare
  • 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

07 Apr 16:37
Compare
Choose a tag to compare
  • 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

06 Apr 10:17
Compare
Choose a tag to compare
  • 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