mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 01:57:13 +00:00
Fix code style
This commit is contained in:
@@ -9,6 +9,13 @@ use phpDocumentor\Reflection\DocBlock\Tag;
|
||||
use ReflectionClass;
|
||||
use ReflectionFunction;
|
||||
use Throwable;
|
||||
use function array_map;
|
||||
use function array_walk_recursive;
|
||||
use function get_class;
|
||||
use function get_resource_type;
|
||||
use function is_object;
|
||||
use function is_resource;
|
||||
use function sprintf;
|
||||
|
||||
/**
|
||||
* This class represents an exception during the tag creation
|
||||
@@ -77,7 +84,9 @@ final class InvalidTag implements Tag
|
||||
$traceProperty = (new ReflectionClass('Exception'))->getProperty('trace');
|
||||
$traceProperty->setAccessible(true);
|
||||
|
||||
$flatten = static function (&$value) {
|
||||
$flatten =
|
||||
/** @param mixed $value */
|
||||
static function (&$value) : void {
|
||||
if ($value instanceof Closure) {
|
||||
$closureReflection = new ReflectionFunction($value);
|
||||
$value = sprintf(
|
||||
@@ -94,7 +103,7 @@ final class InvalidTag implements Tag
|
||||
|
||||
do {
|
||||
$trace = array_map(
|
||||
static function($call) use ($flatten) {
|
||||
static function (array $call) use ($flatten) : array {
|
||||
array_walk_recursive($call['args'], $flatten);
|
||||
|
||||
return $call;
|
||||
@@ -102,7 +111,8 @@ final class InvalidTag implements Tag
|
||||
$exception->getTrace()
|
||||
);
|
||||
$traceProperty->setValue($exception, $trace);
|
||||
} while ($exception = $exception->getPrevious());
|
||||
$exception = $exception->getPrevious();
|
||||
} while ($exception !== null);
|
||||
|
||||
$traceProperty->setAccessible(false);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,10 @@ namespace phpDocumentor\Reflection\DocBlock\Tags;
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Throwable;
|
||||
use function fopen;
|
||||
use function serialize;
|
||||
use function unserialize;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Tags\InvalidTag
|
||||
@@ -46,7 +50,7 @@ final class InvalidTagTest extends TestCase
|
||||
{
|
||||
try {
|
||||
$this->throwExceptionFromClosureWithClosureArgument();
|
||||
} catch (Exception $e) {
|
||||
} catch (Throwable $e) {
|
||||
$parentException = new Exception('test', 0, $e);
|
||||
$tag = InvalidTag::create('Body', 'name')->withError($parentException);
|
||||
self::assertSame('name', $tag->getName());
|
||||
@@ -58,20 +62,20 @@ final class InvalidTagTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
private function throwExceptionFromClosureWithClosureArgument()
|
||||
private function throwExceptionFromClosureWithClosureArgument() : void
|
||||
{
|
||||
$function = function() {
|
||||
$function = static function () : void {
|
||||
throw new InvalidArgumentException();
|
||||
};
|
||||
|
||||
$function($function);
|
||||
}
|
||||
|
||||
public function testCreationWithErrorContainingResource()
|
||||
public function testCreationWithErrorContainingResource() : void
|
||||
{
|
||||
try {
|
||||
$this->throwExceptionWithResourceArgument();
|
||||
} catch (Exception $e) {
|
||||
} catch (Throwable $e) {
|
||||
$parentException = new Exception('test', 0, $e);
|
||||
$tag = InvalidTag::create('Body', 'name')->withError($parentException);
|
||||
self::assertSame('name', $tag->getName());
|
||||
@@ -79,15 +83,15 @@ final class InvalidTagTest extends TestCase
|
||||
self::assertSame($parentException, $tag->getException());
|
||||
self::assertStringStartsWith(
|
||||
'resource(stream)',
|
||||
$tag->getException()->getPrevious()->getTrace()[0]['args'][0])
|
||||
;
|
||||
$tag->getException()->getPrevious()->getTrace()[0]['args'][0]
|
||||
);
|
||||
self::assertEquals($parentException, unserialize(serialize($parentException)));
|
||||
}
|
||||
}
|
||||
|
||||
private function throwExceptionWithResourceArgument()
|
||||
private function throwExceptionWithResourceArgument() : void
|
||||
{
|
||||
$function = function() {
|
||||
$function = static function () : void {
|
||||
throw new InvalidArgumentException();
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user