Skip to content

Commit 16f1379

Browse files
Merge branch '6.4' into 7.0
* 6.4: [DependencyInjection] Remove inaccurate `@throws` on `Container::get()` Add annotation -> attribute aliases
2 parents ed3e3df + 0ef6850 commit 16f1379

39 files changed

+238
-210
lines changed

Annotation/Route.php

Lines changed: 5 additions & 174 deletions
Original file line numberDiff line numberDiff line change
@@ -11,182 +11,13 @@
1111

1212
namespace Symfony\Component\Routing\Annotation;
1313

14-
/**
15-
* @author Fabien Potencier <fabien@symfony.com>
16-
* @author Alexander M. Turek <me@derrabus.de>
17-
*/
18-
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD)]
19-
class Route
20-
{
21-
private ?string $path = null;
22-
private array $localizedPaths = [];
23-
private array $methods;
24-
private array $schemes;
25-
26-
/**
27-
* @param array<string|\Stringable> $requirements
28-
* @param string[]|string $methods
29-
* @param string[]|string $schemes
30-
*/
31-
public function __construct(
32-
string|array $path = null,
33-
private ?string $name = null,
34-
private array $requirements = [],
35-
private array $options = [],
36-
private array $defaults = [],
37-
private ?string $host = null,
38-
array|string $methods = [],
39-
array|string $schemes = [],
40-
private ?string $condition = null,
41-
private ?int $priority = null,
42-
string $locale = null,
43-
string $format = null,
44-
bool $utf8 = null,
45-
bool $stateless = null,
46-
private ?string $env = null
47-
) {
48-
if (\is_array($path)) {
49-
$this->localizedPaths = $path;
50-
} else {
51-
$this->path = $path;
52-
}
53-
$this->setMethods($methods);
54-
$this->setSchemes($schemes);
55-
56-
if (null !== $locale) {
57-
$this->defaults['_locale'] = $locale;
58-
}
59-
60-
if (null !== $format) {
61-
$this->defaults['_format'] = $format;
62-
}
63-
64-
if (null !== $utf8) {
65-
$this->options['utf8'] = $utf8;
66-
}
67-
68-
if (null !== $stateless) {
69-
$this->defaults['_stateless'] = $stateless;
70-
}
71-
}
72-
73-
public function setPath(string $path): void
74-
{
75-
$this->path = $path;
76-
}
77-
78-
public function getPath(): ?string
79-
{
80-
return $this->path;
81-
}
82-
83-
public function setLocalizedPaths(array $localizedPaths): void
84-
{
85-
$this->localizedPaths = $localizedPaths;
86-
}
87-
88-
public function getLocalizedPaths(): array
89-
{
90-
return $this->localizedPaths;
91-
}
14+
// 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
9215

93-
public function setHost(string $pattern): void
94-
{
95-
$this->host = $pattern;
96-
}
97-
98-
public function getHost(): ?string
99-
{
100-
return $this->host;
101-
}
102-
103-
public function setName(string $name): void
104-
{
105-
$this->name = $name;
106-
}
107-
108-
public function getName(): ?string
109-
{
110-
return $this->name;
111-
}
112-
113-
public function setRequirements(array $requirements): void
114-
{
115-
$this->requirements = $requirements;
116-
}
117-
118-
public function getRequirements(): array
119-
{
120-
return $this->requirements;
121-
}
122-
123-
public function setOptions(array $options): void
124-
{
125-
$this->options = $options;
126-
}
127-
128-
public function getOptions(): array
129-
{
130-
return $this->options;
131-
}
132-
133-
public function setDefaults(array $defaults): void
134-
{
135-
$this->defaults = $defaults;
136-
}
137-
138-
public function getDefaults(): array
139-
{
140-
return $this->defaults;
141-
}
142-
143-
public function setSchemes(array|string $schemes): void
144-
{
145-
$this->schemes = (array) $schemes;
146-
}
147-
148-
public function getSchemes(): array
149-
{
150-
return $this->schemes;
151-
}
152-
153-
public function setMethods(array|string $methods): void
154-
{
155-
$this->methods = (array) $methods;
156-
}
157-
158-
public function getMethods(): array
159-
{
160-
return $this->methods;
161-
}
162-
163-
public function setCondition(?string $condition): void
164-
{
165-
$this->condition = $condition;
166-
}
167-
168-
public function getCondition(): ?string
169-
{
170-
return $this->condition;
171-
}
172-
173-
public function setPriority(int $priority): void
174-
{
175-
$this->priority = $priority;
176-
}
177-
178-
public function getPriority(): ?int
179-
{
180-
return $this->priority;
181-
}
182-
183-
public function setEnv(?string $env): void
184-
{
185-
$this->env = $env;
186-
}
16+
class_exists(\Symfony\Component\Routing\Attribute\Route::class);
18717

188-
public function getEnv(): ?string
18+
if (false) {
19+
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD)]
20+
class Route
18921
{
190-
return $this->env;
19122
}
19223
}

Attribute/Route.php

Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Routing\Attribute;
13+
14+
/**
15+
* @author Fabien Potencier <fabien@symfony.com>
16+
* @author Alexander M. Turek <me@derrabus.de>
17+
*/
18+
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD)]
19+
class Route
20+
{
21+
private ?string $path = null;
22+
private array $localizedPaths = [];
23+
private array $methods;
24+
private array $schemes;
25+
26+
/**
27+
* @param array<string|\Stringable> $requirements
28+
* @param string[]|string $methods
29+
* @param string[]|string $schemes
30+
*/
31+
public function __construct(
32+
string|array $path = null,
33+
private ?string $name = null,
34+
private array $requirements = [],
35+
private array $options = [],
36+
private array $defaults = [],
37+
private ?string $host = null,
38+
array|string $methods = [],
39+
array|string $schemes = [],
40+
private ?string $condition = null,
41+
private ?int $priority = null,
42+
string $locale = null,
43+
string $format = null,
44+
bool $utf8 = null,
45+
bool $stateless = null,
46+
private ?string $env = null
47+
) {
48+
if (\is_array($path)) {
49+
$this->localizedPaths = $path;
50+
} else {
51+
$this->path = $path;
52+
}
53+
$this->setMethods($methods);
54+
$this->setSchemes($schemes);
55+
56+
if (null !== $locale) {
57+
$this->defaults['_locale'] = $locale;
58+
}
59+
60+
if (null !== $format) {
61+
$this->defaults['_format'] = $format;
62+
}
63+
64+
if (null !== $utf8) {
65+
$this->options['utf8'] = $utf8;
66+
}
67+
68+
if (null !== $stateless) {
69+
$this->defaults['_stateless'] = $stateless;
70+
}
71+
}
72+
73+
public function setPath(string $path): void
74+
{
75+
$this->path = $path;
76+
}
77+
78+
public function getPath(): ?string
79+
{
80+
return $this->path;
81+
}
82+
83+
public function setLocalizedPaths(array $localizedPaths): void
84+
{
85+
$this->localizedPaths = $localizedPaths;
86+
}
87+
88+
public function getLocalizedPaths(): array
89+
{
90+
return $this->localizedPaths;
91+
}
92+
93+
public function setHost(string $pattern): void
94+
{
95+
$this->host = $pattern;
96+
}
97+
98+
public function getHost(): ?string
99+
{
100+
return $this->host;
101+
}
102+
103+
public function setName(string $name): void
104+
{
105+
$this->name = $name;
106+
}
107+
108+
public function getName(): ?string
109+
{
110+
return $this->name;
111+
}
112+
113+
public function setRequirements(array $requirements): void
114+
{
115+
$this->requirements = $requirements;
116+
}
117+
118+
public function getRequirements(): array
119+
{
120+
return $this->requirements;
121+
}
122+
123+
public function setOptions(array $options): void
124+
{
125+
$this->options = $options;
126+
}
127+
128+
public function getOptions(): array
129+
{
130+
return $this->options;
131+
}
132+
133+
public function setDefaults(array $defaults): void
134+
{
135+
$this->defaults = $defaults;
136+
}
137+
138+
public function getDefaults(): array
139+
{
140+
return $this->defaults;
141+
}
142+
143+
public function setSchemes(array|string $schemes): void
144+
{
145+
$this->schemes = (array) $schemes;
146+
}
147+
148+
public function getSchemes(): array
149+
{
150+
return $this->schemes;
151+
}
152+
153+
public function setMethods(array|string $methods): void
154+
{
155+
$this->methods = (array) $methods;
156+
}
157+
158+
public function getMethods(): array
159+
{
160+
return $this->methods;
161+
}
162+
163+
public function setCondition(?string $condition): void
164+
{
165+
$this->condition = $condition;
166+
}
167+
168+
public function getCondition(): ?string
169+
{
170+
return $this->condition;
171+
}
172+
173+
public function setPriority(int $priority): void
174+
{
175+
$this->priority = $priority;
176+
}
177+
178+
public function getPriority(): ?int
179+
{
180+
return $this->priority;
181+
}
182+
183+
public function setEnv(?string $env): void
184+
{
185+
$this->env = $env;
186+
}
187+
188+
public function getEnv(): ?string
189+
{
190+
return $this->env;
191+
}
192+
}
193+
194+
if (!class_exists(\Symfony\Component\Routing\Annotation\Route::class, false)) {
195+
class_alias(Route::class, \Symfony\Component\Routing\Annotation\Route::class);
196+
}

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ CHANGELOG
2121
* Deprecate `AnnotationDirectoryLoader`, use `AttributeDirectoryLoader` instead
2222
* Deprecate `AnnotationFileLoader`, use `AttributeFileLoader` instead
2323
* Add `AddExpressionLanguageProvidersPass` (moved from `FrameworkBundle`)
24+
* Add aliases for all classes in the `Annotation` namespace to `Attribute`
2425

2526
6.2
2627
---

0 commit comments

Comments
 (0)