Skip to content

Instantly share code, notes, and snippets.

@erickcomp
Created April 19, 2018 13:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erickcomp/bb32e0b9ec1a7ad9c430a201a96d5c3f to your computer and use it in GitHub Desktop.
Save erickcomp/bb32e0b9ec1a7ad9c430a201a96d5c3f to your computer and use it in GitHub Desktop.
<?php
namespace ZendTest\Code\Reflection;
require_once(__DIR__ . '/zend-loader/src/StandardAutoloader.php');
use Zend\Loader\StandardAutoloader;
$zend_loader = new StandardAutoloader();
$zend_loader->registerNamespace('Zend\\Loader', __DIR__ . '/zend-loader/src/');
$zend_loader->registerNamespace('Zend\\Code', __DIR__ . '/zend-code/src/');
$zend_loader->register();
use Zend\Code\Annotation\AnnotationManager;
use Zend\Code\Reflection\DocBlock;
use Zend\Code\Reflection\DocBlock\TagManager;
use Zend\Code\Reflection\DocBlock\Tag;
use Zend\Code\Reflection\ClassReflection;
use Zend\Code\Reflection\MethodReflection;
use Zend\Code\Reflection\ParameterReflection;
use Zend\Code\Scanner\CachingFileScanner;
class MockTest
{
/**
* Short Desc 1
*
* Long Desc 1
*
* @param string $param1
* @return string
*/
public function myMethod1(string $param1)
{
return 'No problem';
}
/**
* Short Desc 2
*
* Long Desc 2
*
* @param string $param1
*/
public function myMethod2(string $param1)
{
}
}
$method1 = new MethodReflection('ZendTest\Code\Reflection\MockTest', 'myMethod1');
$prototype1 = $method1->getPrototype();
$ret_type1 = $method1->getReturnType();
var_dump([$method1, $prototype1, $ret_type1]);
//-------------------------------------------------
$method2 = new MethodReflection('ZendTest\Code\Reflection\MockTest', 'myMethod2');
// Crashes here
echo 'Crashing now!<br>';
$prototype2 = $method2->getPrototype();
$ret_type2 = $method2->getReturnType();
var_dump([$method2, $prototype2, $ret_type2]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment