PHP code example of good-php / reflection
1. Go to this page and download the library: Download good-php/reflection library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
good-php / reflection example snippets
$reflector = new ReflectorBuilder()
->withFileCache()
->withMemoryCache()
->build();
// Reflect a Collection class with generic types: Collection<int, \DateTime>
$reflection = $reflector->forType(\Illuminate\Support\Collection::class, [
PrimitiveType::integer(), // TKey
\DateTime::class, // TValue
]);
// array<int, \DateTime>
$reflection->property('items')->type();
// \DateTime
$reflection->method('prepend')->parameter('value')->type();
// \Traversable<int, \DateTime>
$reflection->method('getIterator')->returnType();