Skip to content

Commit 4036357

Browse files
Merge branch '4.4'
* 4.4: some backports from master Add return types to internal|final|private methods [HttpFoundation] Precalculate session expiry timestamp
2 parents 322da9d + 8073b8a commit 4036357

File tree

83 files changed

+257
-428
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+257
-428
lines changed

UPGRADE-4.4.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ HttpFoundation
109109

110110
* `ApacheRequest` is deprecated, use `Request` class instead.
111111
* Passing a third argument to `HeaderBag::get()` is deprecated since Symfony 4.4, use method `all()` instead
112+
* `PdoSessionHandler` now precalculates the expiry timestamp in the lifetime column,
113+
make sure to run `CREATE INDEX EXPIRY ON sessions (sess_lifetime)` to update your database
114+
to speed up garbage collection of expired sessions.
112115

113116
HttpKernel
114117
----------

src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,11 @@ abstract class DoctrineType extends AbstractType implements ResetInterface
5050
*
5151
* For backwards compatibility, objects are cast to strings by default.
5252
*
53-
* @return string The string representation of the object
5453
*
5554
* @internal This method is public to be usable as callback. It should not
5655
* be used in user code.
5756
*/
58-
public static function createChoiceLabel(object $choice)
57+
public static function createChoiceLabel(object $choice): string
5958
{
6059
return (string) $choice;
6160
}
@@ -71,12 +70,10 @@ public static function createChoiceLabel(object $choice)
7170
* @param string $value The choice value. Corresponds to the object's
7271
* ID here.
7372
*
74-
* @return string The field name
75-
*
7673
* @internal This method is public to be usable as callback. It should not
7774
* be used in user code.
7875
*/
79-
public static function createChoiceName(object $choice, $key, string $value)
76+
public static function createChoiceName(object $choice, $key, string $value): string
8077
{
8178
return str_replace('-', '_', (string) $value);
8279
}
@@ -86,15 +83,15 @@ public static function createChoiceName(object $choice, $key, string $value)
8683
* For instance in ORM two query builders with an equal SQL string and
8784
* equal parameters are considered to be equal.
8885
*
89-
* @return array|false Array with important QueryBuilder parts or false if
90-
* they can't be determined
86+
* @return array|null Array with important QueryBuilder parts or null if
87+
* they can't be determined
9188
*
9289
* @internal This method is public to be usable as callback. It should not
9390
* be used in user code.
9491
*/
95-
public function getQueryBuilderPartsForCachingHash(QueryBuilder $queryBuilder)
92+
public function getQueryBuilderPartsForCachingHash(QueryBuilder $queryBuilder): ?array
9693
{
97-
return false;
94+
return null;
9895
}
9996

10097
public function __construct(ManagerRegistry $registry)
@@ -123,7 +120,7 @@ public function configureOptions(OptionsResolver $resolver)
123120
// If there is no QueryBuilder we can safely cache DoctrineChoiceLoader,
124121
// also if concrete Type can return important QueryBuilder parts to generate
125122
// hash key we go for it as well
126-
if (!$options['query_builder'] || false !== ($qbParts = $this->getQueryBuilderPartsForCachingHash($options['query_builder']))) {
123+
if (!$options['query_builder'] || null !== $qbParts = $this->getQueryBuilderPartsForCachingHash($options['query_builder'])) {
127124
$hash = CachingFactoryDecorator::generateHash([
128125
$options['em'],
129126
$options['class'],

src/Symfony/Bridge/Doctrine/Form/Type/EntityType.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,10 @@ public function getBlockPrefix()
6565
* We consider two query builders with an equal SQL string and
6666
* equal parameters to be equal.
6767
*
68-
* @return array
69-
*
7068
* @internal This method is public to be usable as callback. It should not
7169
* be used in user code.
7270
*/
73-
public function getQueryBuilderPartsForCachingHash(QueryBuilder $queryBuilder)
71+
public function getQueryBuilderPartsForCachingHash(QueryBuilder $queryBuilder): ?array
7472
{
7573
return [
7674
$queryBuilder->getQuery()->getSQL(),

src/Symfony/Bridge/ProxyManager/LazyProxy/PhpDumper/LazyLoadingValueHolderGenerator.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,8 @@ public function setFluentSafe(bool $fluentSafe)
2929

3030
/**
3131
* {@inheritdoc}
32-
*
33-
* @return void
3432
*/
35-
public function generate(\ReflectionClass $originalClass, ClassGenerator $classGenerator)
33+
public function generate(\ReflectionClass $originalClass, ClassGenerator $classGenerator): void
3634
{
3735
parent::generate($originalClass, $classGenerator);
3836

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,11 @@ public function describe(OutputInterface $output, $object, array $options = [])
8484
}
8585
}
8686

87-
/**
88-
* Returns the output.
89-
*
90-
* @return OutputInterface The output
91-
*/
92-
protected function getOutput()
87+
protected function getOutput(): OutputInterface
9388
{
9489
return $this->output;
9590
}
9691

97-
/**
98-
* Writes content to output.
99-
*/
10092
protected function write(string $content, bool $decorated = false)
10193
{
10294
$this->output->write($content, false, $decorated ? OutputInterface::OUTPUT_NORMAL : OutputInterface::OUTPUT_RAW);
@@ -179,10 +171,8 @@ abstract protected function describeCallable($callable, array $options = []);
179171
* Formats a value as string.
180172
*
181173
* @param mixed $value
182-
*
183-
* @return string
184174
*/
185-
protected function formatValue($value)
175+
protected function formatValue($value): string
186176
{
187177
if (\is_object($value)) {
188178
return sprintf('object(%s)', \get_class($value));
@@ -199,10 +189,8 @@ protected function formatValue($value)
199189
* Formats a parameter.
200190
*
201191
* @param mixed $value
202-
*
203-
* @return string
204192
*/
205-
protected function formatParameter($value)
193+
protected function formatParameter($value): string
206194
{
207195
if (\is_bool($value) || \is_array($value) || (null === $value)) {
208196
$jsonString = json_encode($value);
@@ -239,10 +227,7 @@ protected function resolveServiceDefinition(ContainerBuilder $builder, string $s
239227
return $builder->get($serviceId);
240228
}
241229

242-
/**
243-
* @return array
244-
*/
245-
protected function findDefinitionsByTag(ContainerBuilder $builder, bool $showHidden)
230+
protected function findDefinitionsByTag(ContainerBuilder $builder, bool $showHidden): array
246231
{
247232
$definitions = [];
248233
$tags = $builder->findTags();

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,7 @@ private function writeData(array $data, array $options)
198198
$this->write(json_encode($data, $flags | JSON_PRETTY_PRINT)."\n");
199199
}
200200

201-
/**
202-
* @return array
203-
*/
204-
protected function getRouteData(Route $route)
201+
protected function getRouteData(Route $route): array
205202
{
206203
$data = [
207204
'path' => $route->getPath(),

src/Symfony/Bundle/FrameworkBundle/Routing/RedirectableCompiledUrlMatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class RedirectableCompiledUrlMatcher extends CompiledUrlMatcher implements Redir
2424
/**
2525
* {@inheritdoc}
2626
*/
27-
public function redirect(string $path, string $route, string $scheme = null)
27+
public function redirect(string $path, string $route, string $scheme = null): array
2828
{
2929
return [
3030
'_controller' => 'Symfony\\Bundle\\FrameworkBundle\\Controller\\RedirectController::urlRedirectAction',

src/Symfony/Bundle/FrameworkBundle/Test/TestContainer.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bundle\FrameworkBundle\Test;
1313

1414
use Symfony\Component\DependencyInjection\Container;
15+
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
1516
use Symfony\Component\HttpKernel\KernelInterface;
1617

1718
/**
@@ -41,15 +42,15 @@ public function compile()
4142
/**
4243
* {@inheritdoc}
4344
*/
44-
public function isCompiled()
45+
public function isCompiled(): bool
4546
{
4647
return $this->getPublicContainer()->isCompiled();
4748
}
4849

4950
/**
5051
* {@inheritdoc}
5152
*/
52-
public function getParameterBag()
53+
public function getParameterBag(): ParameterBagInterface
5354
{
5455
return $this->getPublicContainer()->getParameterBag();
5556
}
@@ -65,7 +66,7 @@ public function getParameter(string $name)
6566
/**
6667
* {@inheritdoc}
6768
*/
68-
public function hasParameter(string $name)
69+
public function hasParameter(string $name): bool
6970
{
7071
return $this->getPublicContainer()->hasParameter($name);
7172
}
@@ -89,7 +90,7 @@ public function set(string $id, $service)
8990
/**
9091
* {@inheritdoc}
9192
*/
92-
public function has($id)
93+
public function has($id): bool
9394
{
9495
return $this->getPublicContainer()->has($id) || $this->getPrivateContainer()->has($id);
9596
}
@@ -105,7 +106,7 @@ public function get($id, int $invalidBehavior = /* self::EXCEPTION_ON_INVALID_RE
105106
/**
106107
* {@inheritdoc}
107108
*/
108-
public function initialized(string $id)
109+
public function initialized(string $id): bool
109110
{
110111
return $this->getPublicContainer()->initialized($id);
111112
}
@@ -121,15 +122,15 @@ public function reset()
121122
/**
122123
* {@inheritdoc}
123124
*/
124-
public function getServiceIds()
125+
public function getServiceIds(): array
125126
{
126127
return $this->getPublicContainer()->getServiceIds();
127128
}
128129

129130
/**
130131
* {@inheritdoc}
131132
*/
132-
public function getRemovedIds()
133+
public function getRemovedIds(): array
133134
{
134135
return $this->getPublicContainer()->getRemovedIds();
135136
}

src/Symfony/Bundle/SecurityBundle/EventListener/VoteListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function onVoterVote(VoteEvent $event)
3939
$this->traceableAccessDecisionManager->addVoterVote($event->getVoter(), $event->getAttributes(), $event->getVote());
4040
}
4141

42-
public static function getSubscribedEvents()
42+
public static function getSubscribedEvents(): array
4343
{
4444
return ['debug.security.authorization.vote' => 'onVoterVote'];
4545
}

src/Symfony/Bundle/WebProfilerBundle/Csp/ContentSecurityPolicyHandler.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,8 @@ public function __construct(NonceGenerator $nonceGenerator)
3838
* - The request - In case HTML content is fetched via AJAX and inserted in DOM, it must use the same nonce as origin
3939
* - The response - A call to getNonces() has already been done previously. Same nonce are returned
4040
* - They are otherwise randomly generated
41-
*
42-
* @return array
4341
*/
44-
public function getNonces(Request $request, Response $response)
42+
public function getNonces(Request $request, Response $response): array
4543
{
4644
if ($request->headers->has('X-SymfonyProfiler-Script-Nonce') && $request->headers->has('X-SymfonyProfiler-Style-Nonce')) {
4745
return [
@@ -83,7 +81,7 @@ public function disableCsp()
8381
*
8482
* @return array Nonces used by the bundle in Content-Security-Policy header
8583
*/
86-
public function updateResponseHeaders(Request $request, Response $response)
84+
public function updateResponseHeaders(Request $request, Response $response): array
8785
{
8886
if ($this->cspDisabled) {
8987
$this->removeCspHeaders($response);

0 commit comments

Comments
 (0)