Commit Graph

75 Commits

Author SHA1 Message Date
Romain Canon
0b507c9b33 misc: change Composer scripts calls 2021-12-15 13:19:24 +01:00
Romain Canon
231c276021 release: version 0.2.0 2021-12-07 18:59:46 +01:00
Romain Canon
ce3dfb0ced misc: use marcocesarato/php-conventional-changelog for changelog 2021-12-07 18:59:46 +01:00
Romain Canon
9f99a2a1ef feat: handle integer range type
Integer range can be used as follows:

```php
final class SomeClass
{
    /** @var int<42, 1337> */
    public int $intRange; // accepts any int between 42 and 1337

    /** @var int<-1337, 1337> */
    public int $negativeIntRange; // also works with negative values

    /** @var int<min, 1337> */
    public int $minIntRange; // `min` can be used…

    /** @var int<0, max> */
    public int $maxIntRange; // …as well as `max`
}
```

Note that `min` and `max` will check the range with PHP's internal
constants `PHP_INT_MIN` and `PHP_INT_MAX`.
2021-12-07 18:20:25 +01:00
Romain Canon
185edf6053 misc: move exceptions to more specific folder 2021-12-07 18:20:25 +01:00
Romain Canon
9ee2cc471e fix: handle integer value match properly 2021-12-07 18:20:25 +01:00
Romain Canon
fa3ce50dfb feat: handle type alias import in class definition
Type aliases can now be imported from another class definition.

Both PHPStan and Psalm syntax are handled.

```php
/**
 * @phpstan-type SomeTypeAlias = array{foo: string}
 */
final class SomeClass
{
    /** @var SomeTypeAlias */
    public array $someTypeAlias;
}

/**
 * @phpstan-import-type SomeTypeAlias from SomeClass
 */
final class SomeOtherClass
{
    /** @var SomeTypeAlias */
    public array $someTypeAlias;
}
```
2021-12-07 18:20:04 +01:00
Romain Canon
56142dea5b feat: handle local type aliasing in class definition
Type aliases can now be added to a class definition.

Both PHPStan and Psalm syntax are handled.

```php
/**
 * @phpstan-type SomeTypeAlias = array{foo: string}
 * @psalm-type SomeOtherTypeAlias = array{bar: int}
 */
final class SomeClass
{
    /** @var SomeTypeAlias */
    public array $someTypeAlias;

    /** @var SomeOtherTypeAlias */
    public array $someOtherTypeAlias;
}
```
2021-12-07 18:20:04 +01:00
Romain Canon
99b4f4f7aa refactor: extract reflection type resolving to class 2021-12-07 18:20:04 +01:00
Romain Canon
680941687b misc: rename GenericAssignerLexer to TypeAliasLexer 2021-12-07 18:20:04 +01:00
Romain Canon
4f561290b1 misc: delete commented code 2021-12-02 22:35:34 +01:00
Romain Canon
5a578ea4c2 fix: do not accept shaped array with excessive key(s)
The mapper will now delete the excessive keys given as input to a shaped
 array.
2021-12-02 22:35:34 +01:00
Romain Canon
710c7a925c release: version 0.1.1 2021-12-01 13:28:25 +01:00
Romain Canon
d99c59dfb5 feat: handle multiline type declaration
The following type will now be handled:

```php
/**
 * @var array{
 *     foo: string,
 *     bar: int
 * }
 */
public array $foo;
```
2021-12-01 09:45:33 +01:00
Romain Canon
dd4624c5e0 fix: handle correctly iterable source during mapping 2021-11-30 13:04:09 +01:00
Romain Canon
a77b28c5c2 misc!: change license from GPL 3 to MIT
See https://twitter.com/binEinfachNurDa/status/1465282745563856901
2021-11-30 13:01:20 +01:00
Romain Canon
e3e169fb3c misc: delete unwanted code 2021-11-30 12:57:31 +01:00
Viktor Szépe
ea842e2efb
ci: fix CI config (#10) 2021-11-29 13:24:11 +01:00
Romain Canon
1f754a7e77 misc: use composer runtime API 2021-11-29 12:36:00 +01:00
Romain Canon
5561d018ab fix: handle shaped array integer key 2021-11-29 12:17:19 +01:00
Viktor Szépe
9ea95f43f3
misc: syntax highlight stub files (#9) 2021-11-29 12:00:21 +01:00
Romain Canon
8fc6af283c misc: change PHPStan stub file extension 2021-11-29 11:59:29 +01:00
Romain Canon
1c628b6675 fix: resolve single/double quotes when parsing doc-block type 2021-11-29 11:36:11 +01:00
Romain Canon
6cdea31bc2 fix: filter type symbols with strict string comparison
Previously, `array_filter` would remove the integer value `0` from the
array.

See #1
2021-11-29 11:27:29 +01:00
Romain Canon
396f64a524 feat: initial release
🎉
2021-11-28 18:21:56 +01:00