Skip to content

Commit

Permalink
Merged NativeTypeReflector and PHPDocTypeReflector into type-reflecti…
Browse files Browse the repository at this point in the history
…on package
  • Loading branch information
vudaltsov committed Mar 1, 2023
1 parent 112301c commit 2292da0
Show file tree
Hide file tree
Showing 26 changed files with 5,348 additions and 1,378 deletions.
43 changes: 42 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,46 @@
## Installation

```
composer require php-extended-type-system/type-reflection
composer require extended-type-system/type-reflection
```

## Usage

```php
use ExtendedTypeSystem\TypeReflector;

/**
* @template-covariant T of non-empty-list
*/
final class A
{
/**
* @param T $a
*/
public function __construct(
public readonly array $a,
) {
}
}

$reflector = new TypeReflector();

// object(ExtendedTypeSystem\Type\TemplateT) {
// name => string(1) "T"
// declaredAt => object(ExtendedTypeSystem\Type\AtClass) {
// class => string(7) "A"
// }
// }
var_dump($reflector->reflectPropertyType(A::class, 'a'));

// array(1) {
// 0 => object(ExtendedTypeSystem\Template) {
// name => string(1) "T"
// constraint => object(ExtendedTypeSystem\Type\NonEmptyListT) {
// valueType => object(ExtendedTypeSystem\Type\MixedT) {}
// }
// variance => enum(ExtendedTypeSystem\Variance::COVARIANT)
// }
// }
var_dump($reflector->reflectClassTemplates(A::class));
```
22 changes: 18 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "php-extended-type-system/type-reflection",
"name": "extended-type-system/type-reflection",
"description": "PHP Extended Type System • Type Reflection",
"license": "MIT",
"type": "library",
Expand All @@ -11,17 +11,30 @@
],
"require": {
"php": "^8.1",
"php-extended-type-system/type": "^0.1@dev"
"extended-type-system/type": "^0.1@dev",
"extended-type-system/type-stringifier": "^0.1@dev",
"phpdocumentor/reflection-docblock": "^5.2",
"phpdocumentor/type-resolver": "^1.3",
"phpstan/phpdoc-parser": "^1.0",
"phpyh/lru-memoizer": "^0.2"
},
"require-dev": {
"ergebnis/composer-normalize": "^2.30",
"friendsofphp/php-cs-fixer": "^3.14.4",
"phpunit/phpunit": "^9.6.3",
"phpyh/coding-standard": "^2.0.0",
"psalm/plugin-phpunit": "^0.18.4",
"symfony/finder": "^6.2.5",
"vimeo/psalm": "^5.7.7"
},
"autoload": {
"psr-4": {
"PHP\\ExtendedTypeSystem\\TypeReflection\\": "src/"
"ExtendedTypeSystem\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"ExtendedTypeSystem\\": "tests/"
}
},
"config": {
Expand All @@ -33,6 +46,7 @@
"scripts": {
"cleanup": "find var ! -path var ! -path var/.gitignore -exec rm -rf {} +",
"fixcs": "PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer fix -v",
"psalm": "vendor/bin/psalm --show-info"
"psalm": "psalm --show-info",
"test": "phpunit"
}
}
Loading

0 comments on commit 2292da0

Please sign in to comment.