Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Releases: php-type-language/parser

1.5.0

10 Mar 12:15
@SerafimArts SerafimArts

Choose a tag to compare

Optimize and improve parameters grammar

  • Added support of untyped/named parameters.
    • The following formats are now available:
      • callable($var) - Only named parameter
      • callable(...$var) - Variadic named parameter
      • callable($var...) - Variadic named parameter
      • callable(&$var...) - Output variadic named parameter
      • callable(&...$var) - Output variadic named parameter
      • callable(...&$var) - Output variadic named parameter
      • callable($var=) - Named parameter with default
      • callable(&$var=) - Output named parameter with default
  • Improve typed parameters syntax.
    • The following formats are now available:
      • callable(T) - Typed parameter
      • callable(...T) - Variadic typed parameter
      • callable(...T&) - Output variadic typed parameter
      • callable(T...) - Variadic typed parameter
      • callable(T&...) - Output variadic typed parameter
      • callable(T...&) - Output variadic typed parameter
  • Improve typed named parameters syntax.
    • The following formats are now available:
      • callable(...T &$var) - Output variadic typed named parameter
      • callable(T &$var) - Output typed parameter
      • callable(T &$var=) - Output typed named parameter with default
      • callable(T ...&$var) - Output variadic typed named parameter
      • callable(T &...$var) - Output variadic typed named parameter
Assets 2
Loading

1.4.3

06 Mar 21:50
@SerafimArts SerafimArts

Choose a tag to compare

  • Fix TypeOffsetAccessNode serialization
  • Rename (and deprecate) GenericTypeStmt to GenericTypeNode
  • Replace TypeLang\Parser\Builder to anonymous class (make it private)
  • Add MetaStorm support
Loading

1.4.2

05 Feb 14:09
@SerafimArts SerafimArts

Choose a tag to compare

  • AttributeNode is no longer a Statement
Loading

1.4.1

11 Jan 00:40
@SerafimArts SerafimArts

Choose a tag to compare

  • Upgraded phpstan from 1.x to 2.x
    • Upgraded phpstan level from 9 to max
    • Fixed linter errors
  • Removed unused rector dev-depenendency

Full Changelog: 1.4.0...1.4.1

Loading

1.4.0

10 Jan 23:24
@SerafimArts SerafimArts

Choose a tag to compare

Full Changelog: 1.3.0...1.4.0

Loading

1.3.0

09 Nov 03:56
@SerafimArts SerafimArts

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.

Loading

1.2.1

27 Sep 03:39
@SerafimArts SerafimArts

Choose a tag to compare

  • Fix Node\Identifier traversing inside Node\Name class node.
Loading

1.2.0

27 Sep 01:34
@SerafimArts SerafimArts

Choose a tag to compare

  • Added callable parameter attributes:
Example\Functor(#[example_attr] Type $var): void
Loading

1.1.0

26 Sep 22:41
@SerafimArts SerafimArts

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
Loading

1.0.2

11 Sep 01:06
@SerafimArts SerafimArts

Choose a tag to compare

  • Bump parser runtime version (phplrt 3.6 -> 3.7)
Loading
Previous 1
Previous

AltStyle によって変換されたページ (->オリジナル) /