Skip to content

Commit 07b0201

Browse files
authored
Merge pull request #79 from sunrise-php/release/v2.10.2
v2.10.2
2 parents 90cce9a + 83662b7 commit 07b0201

File tree

6 files changed

+6
-76
lines changed

6 files changed

+6
-76
lines changed

src/Annotation/Route.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
* Import classes
1616
*/
1717
use Attribute;
18-
use ReflectionClass;
19-
use ReflectionMethod;
2018

2119
/**
2220
* @Annotation
@@ -48,11 +46,11 @@ final class Route
4846
*
4947
* Don't use the property outside of the package.
5048
*
51-
* @var ReflectionClass|ReflectionMethod|null
49+
* @var mixed
5250
*
5351
* @internal
5452
*/
55-
public $holder = null;
53+
public $holder;
5654

5755
/**
5856
* A route name

src/Loader/DescriptorLoader.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,7 @@ public function load() : RouteCollectionInterface
251251
->setHost($descriptor->host)
252252
->setSummary($descriptor->summary)
253253
->setDescription($descriptor->description)
254-
->setTags(...$descriptor->tags)
255-
->setHolder($descriptor->holder);
254+
->setTags(...$descriptor->tags);
256255
}
257256

258257
return $this->collectionFactory->createCollection(...$routes);
@@ -317,7 +316,7 @@ private function getDescriptorsFromClass(ReflectionClass $class) : array
317316
if ($class->isSubclassOf(RequestHandlerInterface::class)) {
318317
$descriptor = $this->getDescriptorFromClassOrMethod($class);
319318
if (isset($descriptor)) {
320-
$descriptor->holder = $class;
319+
$descriptor->holder = $class->getName();
321320
$result[] = $descriptor;
322321
}
323322
}
@@ -332,7 +331,7 @@ private function getDescriptorsFromClass(ReflectionClass $class) : array
332331

333332
$descriptor = $this->getDescriptorFromClassOrMethod($method);
334333
if (isset($descriptor)) {
335-
$descriptor->holder = $method;
334+
$descriptor->holder = [$method->getDeclaringClass()->getName(), $method->getName()];
336335
$result[] = $descriptor;
337336
}
338337
}

src/Route.php

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
use Psr\Http\Server\MiddlewareInterface;
2020
use Psr\Http\Server\RequestHandlerInterface;
2121
use Sunrise\Http\Router\RequestHandler\QueueableRequestHandler;
22-
use ReflectionClass;
23-
use ReflectionMethod;
24-
use Reflector;
2522

2623
/**
2724
* Import functions
@@ -123,13 +120,6 @@ class Route implements RouteInterface
123120
*/
124121
private $tags = [];
125122

126-
/**
127-
* The route holder
128-
*
129-
* @var ReflectionClass|ReflectionMethod|null
130-
*/
131-
private $holder = null;
132-
133123
/**
134124
* Constructor of the class
135125
*
@@ -236,14 +226,6 @@ public function getTags() : array
236226
return $this->tags;
237227
}
238228

239-
/**
240-
* {@inheritdoc}
241-
*/
242-
public function getHolder() : ?Reflector
243-
{
244-
return $this->holder;
245-
}
246-
247229
/**
248230
* {@inheritdoc}
249231
*/
@@ -348,16 +330,6 @@ public function setTags(string ...$tags) : RouteInterface
348330
return $this;
349331
}
350332

351-
/**
352-
* {@inheritdoc}
353-
*/
354-
public function setHolder(?Reflector $holder) : RouteInterface
355-
{
356-
$this->holder = $holder;
357-
358-
return $this;
359-
}
360-
361333
/**
362334
* {@inheritdoc}
363335
*/

src/RouteInterface.php

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
*/
1717
use Psr\Http\Server\MiddlewareInterface;
1818
use Psr\Http\Server\RequestHandlerInterface;
19-
use ReflectionClass;
20-
use ReflectionMethod;
21-
use Reflector;
2219

2320
/**
2421
* RouteInterface
@@ -104,15 +101,6 @@ public function getDescription() : string;
104101
*/
105102
public function getTags() : array;
106103

107-
/**
108-
* Gets the route holder
109-
*
110-
* @return ReflectionClass|ReflectionMethod|null
111-
*
112-
* @since 2.10.0
113-
*/
114-
public function getHolder() : ?Reflector;
115-
116104
/**
117105
* Sets the given name to the route
118106
*
@@ -211,17 +199,6 @@ public function setDescription(string $description) : RouteInterface;
211199
*/
212200
public function setTags(string ...$tags) : RouteInterface;
213201

214-
/**
215-
* Sets the given holder to the route
216-
*
217-
* @param ReflectionClass|ReflectionMethod|null $holder
218-
*
219-
* @return RouteInterface
220-
*
221-
* @since 2.10.0
222-
*/
223-
public function setHolder(?Reflector $holder) : RouteInterface;
224-
225202
/**
226203
* Adds the given prefix to the route path
227204
*

tests/Loader/DescriptorLoaderTest.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function testCache() : void
9191
$this->assertSame('foo', $loader->getCacheKey());
9292

9393
$descriptor = new Route('controller-from-cached-descriptor', null, '/');
94-
$descriptor->holder = new ReflectionClass(Fixtures\Controllers\BlankController::class);
94+
$descriptor->holder = Fixtures\Controllers\BlankController::class;
9595

9696
$cache->storage[$loader->getCacheKey()][0] = $descriptor;
9797

@@ -148,8 +148,6 @@ public function testLoadMinimallyAnnotatedClass() : void
148148
$this->assertSame('minimally-annotated-controller', $route->getName());
149149
$this->assertSame('/', $route->getPath());
150150
$this->assertSame(['GET'], $route->getMethods());
151-
$this->assertNotNull($route->getHolder());
152-
$this->assertSame($class, $route->getHolder()->getName());
153151
}
154152

155153
/**
@@ -174,8 +172,6 @@ public function testLoadMinimallyAttributedClass() : void
174172
$this->assertSame('minimally-attributed-controller', $route->getName());
175173
$this->assertSame('/', $route->getPath());
176174
$this->assertSame(['GET'], $route->getMethods());
177-
$this->assertNotNull($route->getHolder());
178-
$this->assertSame($class, $route->getHolder()->getName());
179175
}
180176

181177
/**

tests/RouteTest.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -177,18 +177,6 @@ public function testSetTags() : void
177177
$this->assertSame($tags, $route->getTags());
178178
}
179179

180-
/**
181-
* @return void
182-
*/
183-
public function testSetHolder() : void
184-
{
185-
$route = new Fixtures\Route();
186-
$holder = new \ReflectionClass(__CLASS__);
187-
$this->assertNull($route->getHolder());
188-
$this->assertSame($route, $route->setHolder($holder));
189-
$this->assertSame($holder, $route->getHolder());
190-
}
191-
192180
/**
193181
* @return void
194182
*/

0 commit comments

Comments
 (0)