8000 [Routing][Serializer] Add annotation -> attribute aliases by wouterj · Pull Request #52294 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Routing][Serializer] Add annotation -> attribute aliases #52294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
519 changes: 246 additions & 273 deletions .github/expected-missing-return-types.diff

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Symfony\Bridge\Twig\Tests\Extension\Fixtures;

use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Attribute\Groups;

/**
* @author Jesse Rushlow <jr@rushlow.dev>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\RoutingConditionServiceBundle\Controller;

use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Attribute\Route;

class DefaultController
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Attribute\Route;

class AnnotatedController
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller;

use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Uid\Ulid;
use Symfony\Component\Uid\UuidV1;

Expand Down
10000
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

class FlexStyleMicroKernel extends Kernel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Symfony\Component\PropertyInfo\Tests\Fixtures;

use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Attribute\Groups;

/**
* @author Kévin Dunglas <dunglas@gmail.com>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

namespace Symfony\Component\PropertyInfo\Tests\Fixtures;

use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Serializer\Annotation\Ignore;
use Symfony\Component\Serializer\Attribute\Groups;
use Symfony\Component\Serializer\Attribute\Ignore;

/**
* @author Vadim Borodavko <vadim.borodavko@gmail.com>
Expand Down
242 changes: 5 additions & 237 deletions src/Symfony/Component/Routing/Annotation/Route.php
10000
Original file line number Diff line number Diff line change
Expand Up @@ -11,245 +11,13 @@

namespace Symfony\Component\Routing\Annotation;

/**
* Annotation class for @Route().
*
* @Annotation
* @NamedArgumentConstructor
* @Target({"CLASS", "METHOD"})
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Alexander M. Turek <me@derrabus.de>
*/
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD)]
class Route
{
private ?string $path = null;
private array $localizedPaths = [];
private array $methods;
private array $schemes;

/**
* @param array<string|\Stringable> $requirements
* @param string[]|string $methods
* @param string[]|string $schemes
*/
public function __construct(
string|array $path = null,
private ?string $name = null,
private array $requirements = [],
private array $options = [],
private array $defaults = [],
private ?string $host = null,
array|string $methods = [],
array|string $schemes = [],
private ?string $condition = null,
private ?int $priority = null,
string $locale = null,
string $format = null,
bool $utf8 = null,
bool $stateless = null,
private ?string $env = null
) {
if (\is_array($path)) {
$this->localizedPaths = $path;
} else {
$this->path = $path;
}
$this->setMethods($methods);
$this->setSchemes($schemes);

if (null !== $locale) {
$this->defaults['_locale'] = $locale;
}

if (null !== $format) {
$this->defaults['_format'] = $format;
}

if (null !== $utf8) {
$this->options['utf8'] = $utf8;
}

if (null !== $stateless) {
$this->defaults['_stateless'] = $stateless;
}
}

/**
* @return void
*/
public function setPath(string $path)
{
$this->path = $path;
}

/**
* @return string|null
*/
public function getPath()
{
return $this->path;
}

/**
* @return void
*/
public function setLocalizedPaths(array $localizedPaths)
{
$this->localizedPaths = $localizedPaths;
}

public function getLocalizedPaths(): array
{
return $this->localizedPaths;
}

/**
* @return void
*/
public function setHost(string $pattern)
{
$this->host = $pattern;
}

/**
* @return string|null
*/
public function getHost()
{
return $this->host;
}

/**
* @return void
*/
public function setName(string $name)
{
$this->name = $name;
}

/**
* @return string|null
*/
public function getName()
{
return $this->name;
}

/**
* @return void
*/
public function setRequirements(array $requirements)
{
$this->requirements = $requirements;
}

/**
* @return array
*/
public function getRequirements()
{
return $this->requirements;
}
// do not deprecate in 6.4/7.0, to make it easier for the ecosystem to support 6.4, 7.4 and 8.0 simultaneously

/**
* @return void
*/
public function setOptions(array $options)
{
$this->options = $options;
}

/**
* @return array
*/
public function getOptions()
{
return $this->options;
}

/**
* @return void
*/
public function setDefaults(array $defaults)
{
$this->defaults = $defaults;
}

/**
* @return array
*/
public function getDefaults()
{
return $this->defaults;
}

/**
* @return void
*/
public function setSchemes(array|string $schemes)
{
$this->schemes = (array) $schemes;
}

/**
* @return array
*/
public function getSchemes()
{
return $this->schemes;
}

/**
* @return void
*/
public function setMethods(array|string $methods)
{
$this->methods = (array) $methods;
}

/**
* @return array
*/
public function getMethods()
{
return $this->methods;
}

/**
* @return void
*/
public function setCondition(?string $condition)
{
$this->condition = $condition;
}

/**
* @return string|null
*/
public function getCondition()
{
return $this->condition;
}

public function setPriority(int $priority): void
{
$this->priority = $priority;
}

public function getPriority(): ?int
{
return $this->priority;
}

public function setEnv(?string $env): void
{
$this->env = $env;
}
class_exists(\Symfony\Component\Routing\Attribute\Route::class);

public function getEnv(): ?string
if (false) {
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD)]
class Route
{
return $this->env;
}
}
Loading
0