本文整理汇总了PHP中ReflectionObject::getShortName方法的典型用法代码示例。如果您正苦于以下问题:PHP ReflectionObject::getShortName方法的具体用法?PHP ReflectionObject::getShortName怎么用?PHP ReflectionObject::getShortName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReflectionObject
的用法示例。
在下文中一共展示了ReflectionObject::getShortName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: convert
/**
* {@inheritDoc}
*/
public function convert(ReplyInterface $reply)
{
$headers = $statusCode = $content = null;
if ($reply instanceof SymfonyHttpResponse) {
$response = $reply->getResponse();
$statusCode = $response->getStatusCode();
$headers = $response->headers->all();
$content = $response->getContent();
} else {
if ($reply instanceof HttpPostRedirect) {
$statusCode = $reply->getStatusCode();
$headers = $reply->getHeaders();
$content = $this->preparePostRedirectContent($reply);
} else {
if ($reply instanceof HttpResponse) {
$statusCode = $reply->getStatusCode();
$headers = $reply->getHeaders();
$content = $reply->getContent();
} else {
$ro = new \ReflectionObject($reply);
throw new LogicException(sprintf('Cannot convert reply %s to http response.', $ro->getShortName()), null, $reply);
}
}
}
$fixedHeaders = [];
foreach ($headers as $name => $value) {
$fixedHeaders[str_replace('- ', '-', ucwords(str_replace('-', '- ', $name)))] = $value;
}
$fixedHeaders['Content-Type'] = 'application/vnd.payum+json';
return new JsonResponse(['status' => $statusCode, 'headers' => $fixedHeaders, 'content' => $content], $statusCode, ['X-Status-Code' => $statusCode]);
}
示例2: getFactoryByRequest
/**
* @param \Wehup\AMI\Request\RequestInterface $request
* @return \Wehup\AMI\Factory\FactoryInterface
*/
public static function getFactoryByRequest(Request\RequestInterface $request)
{
$reflection = new \ReflectionObject($request);
$classname = substr($reflection->getShortName(), 0, -7);
// remove "Request" suffix
$fqcn = "\\Wehup\\AMI\\Factory\\{$classname}Factory";
if (!class_exists($fqcn)) {
throw new Exception\NoFactoryClassAvailableException("There is no available Factory class for \"{$classname}\"", $fqcn);
}
return new $fqcn($request);
}
示例3: value
/**
* @param mixed $value
* @param bool $shortClass
*
* @return string
*/
public static function value($value, $shortClass = true)
{
if (is_object($value)) {
if ($shortClass) {
$ro = new \ReflectionObject($value);
return $ro->getShortName();
}
return get_class($value);
}
return gettype($value);
}
示例4: resolveHandlerClass
/**
* Resolves an instance of the handler class
* corresponding to $command.
*
* @param Command $command
*
* @return CommandHandler
* @throws \Exception
*/
private function resolveHandlerClass(Command $command)
{
$reflectionObject = new \ReflectionObject($command);
$shortName = $reflectionObject->getShortName();
$className = $reflectionObject->getNamespaceName() . '\\Handlers\\' . $shortName . 'Handler';
if (!class_exists($className)) {
throw new \Exception("Command handler {$className} not found.");
}
// Let the container resolve the instance and inject the required dependencies.
return $this->container->get($className);
}
示例5: convert
/**
* @param ReplyInterface $reply
*
* @return Response
*/
public function convert(ReplyInterface $reply)
{
if ($reply instanceof SymfonyHttpResponse) {
return $reply->getResponse();
} elseif ($reply instanceof HttpResponse) {
$headers = $reply->getHeaders();
$headers['X-Status-Code'] = $reply->getStatusCode();
return new Response($reply->getContent(), $reply->getStatusCode(), $headers);
}
$ro = new \ReflectionObject($reply);
throw new LogicException(sprintf('Cannot convert reply %s to http response.', $ro->getShortName()), null, $reply);
}
示例6: convert
/**
* @param ReplyInterface $reply
*
* @return Response
*/
public function convert(ReplyInterface $reply)
{
if ($reply instanceof SymfonyHttpResponse) {
return $reply->getResponse();
} elseif ($reply instanceof HttpResponse) {
return new Response($reply->getContent());
} elseif ($reply instanceof HttpRedirect) {
return new RedirectResponse($reply->getUrl());
}
$ro = new \ReflectionObject($reply);
throw new LogicException(sprintf('Cannot convert reply %s to http response.', $ro->getShortName()), null, $reply);
}
示例7: handleException
public function handleException(\CExceptionEvent $event)
{
if (false == $event->exception instanceof ReplyInterface) {
return;
}
$reply = $event->exception;
if ($reply instanceof HttpRedirect) {
$this->redirect($reply->getUrl(), true);
$event->handled = true;
return;
}
$ro = new \ReflectionObject($reply);
$event->exception = new LogicException(sprintf('Cannot convert reply %s to Yii response.', $ro->getShortName()), null, $reply);
}
示例8: registersMappingFilesInTheSpecifiedDirectories
/**
* @test
*/
public function registersMappingFilesInTheSpecifiedDirectories()
{
$container = new ContainerBuilder(new ParameterBag(array('kernel.debug' => false, 'kernel.bundles' => array('FrameworkBundle' => 'Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle', 'PieceValidationDirectoryLoaderBundle' => 'Piece\\Bundle\\ValidationDirectoryLoaderBundle\\PieceValidationDirectoryLoaderBundle'), 'kernel.cache_dir' => __DIR__)));
$container->registerExtension(new FrameworkExtension());
$container->registerExtension(new PieceValidationDirectoryLoaderExtension());
$container->loadFromExtension('framework', array('secret' => '154F520832A9BC66316C259EEC70E4FA671A12F5', 'validation' => array('enable_annotations' => false)));
$container->loadFromExtension('piece_validationdirectoryloader', array('mapping_dirs' => array(__DIR__ . '/Fixtures/validation/a', __DIR__ . '/Fixtures/validation/b')));
$container->getCompilerPassConfig()->setOptimizationPasses(array());
$container->getCompilerPassConfig()->setRemovingPasses(array());
$container->compile();
foreach (array(new Foo(), new Bar(), new Baz()) as $entity) {
$violations = $container->get('validator')->validate($entity);
$this->assertEquals(1, count($violations));
$this->assertSame($entity, $violations[0]->getRoot());
$entityClass = new \ReflectionObject($entity);
$this->assertEquals(strtolower($entityClass->getShortName()), $violations[0]->getPropertyPath());
}
}
开发者ID:piece,项目名称:piece-validationdirectoryloader-bundle,代码行数:21,代码来源:PieceValidationDirectoryLoaderExtensionTest.php
示例9: exportProperties
/**
* Extract and map properties for the metadata
*
* @param ClassMetadata $metadata
*/
protected function exportProperties(ClassMetadata $metadata)
{
$map = array();
foreach ($metadata->getFields() as $name => $field) {
$ref = new \ReflectionObject($field);
$class = $ref->getShortName();
$method = sprintf('exportField%s', $class);
$map[$name] = $this->$method($field);
}
foreach ($metadata->getEmbeds() as $name => $embed) {
$embedMetadata = $metadata->getEmbeddedMetadata($name);
$map[$name]['type'] = 'object';
$map[$name]['properties'] = $this->exportProperties($embedMetadata);
}
return $map;
}
示例10: boot
/**
* {@inheritDoc}
*/
public function boot()
{
$this->package('payum/payum-laravel-package');
\View::addNamespace('payum/payum', __DIR__ . '/../../views');
$this->app->error(function (ReplyInterface $reply) {
$response = null;
if ($reply instanceof SymfonyHttpResponse) {
$response = $reply->getResponse();
} elseif ($reply instanceof HttpResponse) {
$response = new Response($reply->getContent());
} elseif ($reply instanceof HttpRedirect) {
$response = new RedirectResponse($reply->getUrl());
}
if ($response) {
return $response;
}
$ro = new \ReflectionObject($reply);
throw new LogicException(sprintf('Cannot convert reply %s to Laravel response.', $ro->getShortName()), null, $reply);
});
\Route::any('/payment/authorize/{payum_token}', array('as' => 'payum_authorize_do', 'uses' => 'Payum\\LaravelPackage\\Controller\\AuthorizeController@doAction'));
\Route::any('/payment/capture/{payum_token}', array('as' => 'payum_capture_do', 'uses' => 'Payum\\LaravelPackage\\Controller\\CaptureController@doAction'));
\Route::any('/payment/refund/{payum_token}', array('as' => 'payum_refund_do', 'uses' => 'Payum\\LaravelPackage\\Controller\\RefundController@doAction'));
\Route::get('/payment/notify/{payum_token}', array('as' => 'payum_notify_do', 'uses' => 'Payum\\LaravelPackage\\Controller\\NotifyController@doAction'));
\Route::get('/payment/notify/unsafe/{payment_name}', array('as' => 'payum_notify_do_unsafe', 'uses' => 'Payum\\LaravelPackage\\Controller\\NotifyController@doUnsafeAction'));
$this->app['payum'] = $this->app->share(function ($app) {
//TODO add exceptions if invalid payments and storages options set.
$payum = new ContainerAwareRegistry(\Config::get('payum-laravel-package::payments'), \Config::get('payum-laravel-package::storages'));
$payum->setContainer($app);
return $payum;
});
$this->app['payum.security.token_storage'] = $this->app->share(function ($app) {
//TODO add exceptions if invalid payments and storages options set.
$tokenStorage = \Config::get('payum-laravel-package::token_storage');
return is_object($tokenStorage) ? $tokenStorage : $app[$tokenStorage];
});
$this->app['payum.security.token_factory'] = $this->app->share(function ($app) {
return new TokenFactory($app['payum.security.token_storage'], $app['payum'], 'payum_capture_do', 'payum_notify_do', 'payum_authorize_do', 'payum_refund_do');
});
$this->app['payum.security.http_request_verifier'] = $this->app->share(function ($app) {
return new HttpRequestVerifier($app['payum.security.token_storage']);
});
}
示例11: onKernelException
/**
* @param GetResponseForExceptionEvent $event
*/
public function onKernelException(GetResponseForExceptionEvent $event)
{
if (false == $event->getException() instanceof InteractiveRequestInterface) {
return;
}
$interactiveRequest = $event->getException();
if ($interactiveRequest instanceof SymfonyResponseInteractiveRequest) {
$event->setResponse($interactiveRequest->getResponse());
} elseif ($interactiveRequest instanceof ResponseInteractiveRequest) {
$event->setResponse(new Response($interactiveRequest->getContent()));
} elseif ($interactiveRequest instanceof RedirectUrlInteractiveRequest) {
$event->setResponse(new RedirectResponse($interactiveRequest->getUrl()));
}
if ($event->getResponse()) {
if (false == $event->getResponse()->headers->has('X-Status-Code')) {
$event->getResponse()->headers->set('X-Status-Code', $event->getResponse()->getStatusCode());
}
return;
}
$ro = new \ReflectionObject($interactiveRequest);
$event->setException(new LogicException(sprintf('Cannot convert interactive request %s to symfony response.', $ro->getShortName()), null, $interactiveRequest));
}
示例12: shouldLogReplyWhenSetOnPostExecute
/**
* @test
*/
public function shouldLogReplyWhenSetOnPostExecute()
{
$action = new FooAction();
$replyMock = $this->createReplyMock();
$ro = new \ReflectionObject($replyMock);
$logger = $this->createLoggerMock();
$logger->expects($this->at(0))->method('debug')->with('[Payum] 1# FooAction::execute(string) throws reply ' . $ro->getShortName());
$context = new Context($this->createGatewayMock(), 'string', array());
$context->setAction($action);
$context->setReply($replyMock);
$extension = new LogExecutedActionsExtension($logger);
$extension->onPostExecute($context);
}
示例13: getAnalyzeHtml_Object
private function getAnalyzeHtml_Object($obj, $index)
{
$reflector = new \ReflectionObject($obj);
$result = '';
$result .= '<h4>About</h4>';
$result .= '<table class="aboutTable">';
$result .= '<tbody>';
$result .= '<tr>';
$result .= '<td class="colLeft"><strong>Name</strong></td>';
$result .= '<td class="colRight">' . htmlentities($reflector->getShortName()) . '</td>';
$result .= '</tr>';
$result .= '<tr>';
$result .= '<td class="colLeft"><strong>Namespace</strong></td>';
$result .= '<td class="colRight">' . htmlentities($reflector->getNamespaceName()) . '</td>';
$result .= '</tr>';
$result .= '</tbody>';
$result .= '<tr>';
$result .= '<td class="colLeft"><strong>File</strong></td>';
$result .= '<td class="colRight">' . htmlentities($reflector->getFileName()) . '</td>';
$result .= '</tr>';
$result .= '</tbody>';
$result .= '</table>';
$result .= '<h4>Members</h4>';
$result .= '<ul class="accordion" data-accordion>';
$accId = "objConstants{$index}";
$constants = $reflector->getConstants();
uksort($constants, function ($x, $y) {
return strcmp(trim(strtolower($x)), trim(strtolower($y)));
});
$content = 'No constants found.';
if (!empty($constants)) {
$content = '<table class="memberTable">';
$content .= '<thead>';
$content .= '<tr>';
$content .= '<th class="memberName">Name</th>';
$content .= '<th>Value</th>';
$content .= '</tr>';
$content .= '</thead>';
$content .= '<tbody>';
foreach ($constants as $name => $value) {
$content .= '<tr>';
$content .= '<td>' . htmlentities($name) . '</td>';
$content .= '<td>' . htmlentities(var_export($value, true)) . '</td>';
$content .= '</tr>';
}
$content .= '</tbody>';
$content .= '</table>';
}
$result .= '<li class="accordion-navigation">';
$result .= '<a href="#' . $accId . '" aria-expanded="false">Constants (' . trim(count($constants)) . ')</a>';
$result .= '<div id="' . $accId . '" class="content">' . $content . '</div>';
$result .= '</li>';
$accId = "objMethods{$index}";
$methods = $reflector->getMethods();
usort($methods, function (\ReflectionMethod $x, \ReflectionMethod $y) {
return strcmp(trim(strtolower($x->getName())), trim(strtolower($y->getName())));
});
foreach ($methods as $i => $m) {
if (!$m->isPublic()) {
unset($methods[$i]);
}
}
$content = 'No methods found.';
if (!empty($methods)) {
$content = '<table class="memberTable">';
$content .= '<thead>';
$content .= '<tr>';
$content .= '<th class="memberName">Name</th>';
$content .= '</tr>';
$content .= '</thead>';
$content .= '<tbody>';
foreach ($methods as $m) {
$content .= '<tr>';
$content .= '<td>' . htmlentities($m->getName()) . '</td>';
$content .= '</tr>';
}
$content .= '</tbody>';
$content .= '</table>';
}
$result .= '<li class="accordion-navigation">';
$result .= '<a href="#' . $accId . '" aria-expanded="false">Methods (' . trim(count($methods)) . ')</a>';
$result .= '<div id="' . $accId . '" class="content">' . $content . '</div>';
$result .= '</li>';
$accId = "objProperties{$index}";
$properties = $reflector->getProperties();
usort($properties, function (\ReflectionProperty $x, \ReflectionProperty $y) {
return strcmp(trim(strtolower($x->getName())), trim(strtolower($y->getName())));
});
foreach ($properties as $i => $p) {
if (!$p->isPublic()) {
unset($properties[$i]);
}
}
$content = 'No properties found.';
if (!empty($properties)) {
$content = '<table class="memberTable">';
$content .= '<thead>';
$content .= '<tr>';
$content .= '<th class="memberName">Name</th>';
$content .= '<th>Current value</th>';
//.........这里部分代码省略.........
示例14: get_tracking_file_name
protected final function get_tracking_file_name()
{
$obj = new ReflectionObject($this);
return "test-results/" . $obj->getShortName() . ".json";
}
示例15: shouldLogOnInteractiveRequest
/**
* @test
*/
public function shouldLogOnInteractiveRequest()
{
$action = new FooAction();
$interactiveRequest = $this->createInteractiveRequestMock();
$ro = new \ReflectionObject($interactiveRequest);
$logger = $this->createLoggerMock();
$logger->expects($this->at(0))->method('debug')->with('[Payum] 1# FooAction::execute(string) throws interactive ' . $ro->getShortName());
$extension = new LogExecutedActionsExtension($logger);
$extension->onPreExecute('string');
$extension->onInteractiveRequest($interactiveRequest, 'string', $action);
}