8000 Turn `@method` annotations into real method declarations · symfony/symfony@666e911 · GitHub
[go: up one dir, main page]

Skip to content

Commit 666e911

Browse files
Turn @method annotations into real method declarations
1 parent 290a97a commit 666e911

File tree

9 files changed

+25
-54
lines changed

9 files changed

+25
-54
lines changed

src/Symfony/Bundle/FrameworkBundle/Kernel/MicroKernelTrait.php

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,13 @@
2020
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
2121
use Symfony\Component\Routing\Loader\PhpFileLoader as RoutingPhpFileLoader;
2222
use Symfony\Component\Routing\RouteCollection;
23-
use Symfony\Component\Routing\RouteCollectionBuilder;
2423

2524
/**
2625
* A Kernel that provides configuration hooks.
2726
*
2827
* @author Ryan Weaver <ryan@knpuniversity.com>
2928
* @author Fabien Potencier <fabien@symfony.com>
3029
*
31-
* @method void configureRoutes(RoutingConfigurator $routes)
3230
* @method void configureContainer(ContainerConfigurator $container)
3331
*/
3432
trait MicroKernelTrait
@@ -42,7 +40,7 @@ trait MicroKernelTrait
4240
* ->controller('App\Controller\AdminController::dashboard')
4341
* ;
4442
*/
45-
//abstract protected function configureRoutes(RoutingConfigurator $routes): void;
43+
abstract protected function configureRoutes(RoutingConfigurator $routes): void;
4644

4745
/**
4846
* Configures the container.
@@ -174,23 +172,6 @@ public function loadRoutes(LoaderInterface $loader): RouteCollection
174172
$kernelLoader->setCurrentDir(\dirname($file));
175173
$collection = new RouteCollection();
176174

177-
try {
178-
$configureRoutes = new \ReflectionMethod($this, 'configureRoutes');
179-
} catch (\ReflectionException $e) {
180-
throw new \LogicException(sprintf('"%s" uses "%s", but does not implement the required method "protected function configureRoutes(RoutingConfigurator $routes): void".', get_debug_type($this), MicroKernelTrait::class), 0, $e);
181-
}
182-
183-
$configuratorClass = $configureRoutes->getNumberOfParameters() > 0 && ($type = $configureRoutes->getParameters()[0]->getType()) instanceof \ReflectionNamedType && !$type->isBuiltin() ? $type->getName() : null;
184-
185-
if ($configuratorClass && !is_a(RoutingConfigurator::class, $configuratorClass, true)) {
186-
trigger_deprecation('symfony/framework-bundle', '5.1', 'Using type "%s" for argument 1 of method "%s:configureRoutes()" is deprecated, use "%s" instead.', RouteCollectionBuilder::class, self::class, RoutingConfigurator::class);
187-
188-
$routes = new RouteCollectionBuilder($loader);
189-
$this->configureRoutes($routes);
190-
191-
return $routes->build();
192-
}
193-
194175
$this->configureRoutes(new RoutingConfigurator($collection, $kernelLoader, $file, $file, $this->getEnvironment()));
195176

196177
foreach ($collection as $route) {

src/Symfony/Bundle/FrameworkBundle/Tests/Kernel/MicroKernelTraitTest.php

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -140,24 +140,6 @@ protected function configureRoutes(RoutingConfigurator $routes): void
140140

141141
$kernel->boot();
142142
}
143-
144-
public function testMissingConfigureRoutes()
145-
{
146-
$kernel = new class('missing_configure_routes') extends MinimalKernel {
147-
protected function configureContainer(ContainerConfigurator $c): void
148-
{
149-
$c->extension('framework', [
150-
'router' => ['utf8' => true],
151-
]);
152-
}
153-
};
154-
155-
$this->expectException(\LogicException::class);
156-
$this->expectExceptionMessage('"Symfony\Bundle\FrameworkBundle\Tests\Kernel\MinimalKernel@anonymous" uses "Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait", but does not implement the required method "protected function configureRoutes(RoutingConfigurator $routes): void".');
157-
158-
$request = Request::create('/');
159-
$kernel->handle($request, HttpKernelInterface::MAIN_REQUEST, false);
160-
}
161143
}
162144

163145
abstract class MinimalKernel extends Kernel

src/Symfony/Component/HttpClient/MockHttpClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function getRequestsCount(): int
100100
/**
101101
* {@inheritdoc}
102102
*/
103-
public function withOptions(array $options): self
103+
public function withOptions(array $options): static
104104
{
105105
$clone = clone $this;
106106
$clone->defaultOptions = self::mergeDefaultOptions($options, $this->defaultOptions, true);

src/Symfony/Component/HttpClient/ScopingHttpClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public function setLogger(LoggerInterface $logger): void
121121
/**
122122
* {@inheritdoc}
123123
*/
124-
public function withOptions(array $options): self
124+
public function withOptions(array $options): static
125125
{
126126
$clone = clone $this;
127127
$clone->client = $this->client->withOptions($options);

src/Symfony/Component/Security/Core/Authentication/Token/TokenInterface.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
/**
1717
* TokenInterface is the interface for the user authentication information.
1818
*
19-
* @method string getUserIdentifier() returns the user identifier used during authentication (e.g. a user's email address or username)
20-
*
2119
* @author Fabien Potencier <fabien@symfony.com>
2220
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
2321
*/
@@ -30,6 +28,11 @@ interface TokenInterface
3028
*/
3129
public function __toString(): string;
3230

31+
/**
32+
* Returns the user identifier used during authentication (e.g. a user's email address or username).
33+
*/
34+
public function getUserIdentifier(): string;
35+
3336
/**
3437
* Returns the user roles.
3538
*

src/Symfony/Component/Security/Core/User/UserProviderInterface.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@
2727
* configuration, web service). This is totally independent of how the authentication
2828
* information is submitted or what the UserInterface object looks like.
2929
*
30-
* @see UserInterface
31-
*
32-
* @method UserInterface loadUserByIdentifier(string $identifier)
33-
*
3430
* @author Fabien Potencier <fabien@symfony.com>
3531
*/
3632
interface UserProviderInterface

src/Symfony/Component/Translation/TranslatorBagInterface.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
1414
use Symfony\Component\Translation\Exception\InvalidArgumentException;
1515

1616
/**
17-
* TranslatorBagInterface.
18-
*
19-
* @method MessageCatalogueInterface[] getCatalogues() Returns all catalogues of the instance
20-
*
2117
* @author Abdellatif Ait boudad <a.aitboudad@gmail.com>
2218
*/
2319
interface TranslatorBagInterface
@@ -30,4 +26,11 @@ interface TranslatorBagInterface
3026
* @throws InvalidArgumentException If the locale contains invalid characters
3127
*/
3228
public function getCatalogue(string $locale = null): MessageCatalogueInterface;
29+
30+
/**
31+
* Returns all catalogues of the instance.
32+
*
33+
* @return MessageCatalogueInterface[]
34+
*/
35+
public function getCatalogues(): array;
3336
}

src/Symfony/Contracts/HttpClient/HttpClientInterface.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
*
2020
* @see HttpClientTestCase for a reference test suite
2121
*
22-
* @method static withOptions(array $options) Returns a new instance of the client with new default options
23-
*
2422
* @author Nicolas Grekas <p@tchwork.com>
2523
*/
2624
interface HttpClientInterface
@@ -92,4 +90,9 @@ public function request(string $method, string $url, array $options = []): Respo
9290
* @param float|null $timeout The idle timeout before yielding timeout chunks
9391
*/
9492
public function stream(ResponseInterface|iterable $responses, float $timeout = null): ResponseStreamInterface;
93+
94+
/**
95+
* Returns a new instance of the client with new default options.
96+
*/
97+
public function withOptions(array $options): static;
9598
}

src/Symfony/Contracts/Translation/TranslatorInterface.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313

1414
/**
1515
* @author Fabien Potencier <fabien@symfony.com>
16-
*
17-
* @method string getLocale() Returns the default locale
1816
*/
1917
interface TranslatorInterface
2018
{
@@ -62,4 +60,9 @@ interface TranslatorInterface
6260
* @throws \InvalidArgumentException If the locale contains invalid characters
6361
*/
6462
public function trans(string $id, array $parameters = [], string $domain = null, string $locale = null): string;
63+
64+
/**
65+
* Returns the default locale.
66+
*/
67+
public function getLocale(): string;
6568
}

0 commit comments

Comments
 (0)
0