Skip to content

Commit a1527cb

Browse files
Merge branch '7.2' into 7.3
* 7.2: Fix php.net links fix version number in deprecation [DoctrineBridge] Restore compatibility with Doctrine ODM by validating $class object type chore: Increase minimum version of type-info component [FrameworkBundle] Add functional tests for the `ContainerLintCommand` command Fix precision loss when rounding large integers in `NumberToLocalizedStringTransformer`
2 parents 777e91a + 4c9430c commit a1527cb

File tree

19 files changed

+115
-28
lines changed

19 files changed

+115
-28
lines changed

src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Bridge\Doctrine\Validator\Constraints;
1313

14-
use Doctrine\ORM\Mapping\ClassMetadata as OrmClassMetadata;
1514
use Doctrine\ORM\Mapping\MappingException as ORMMappingException;
1615
use Doctrine\Persistence\ManagerRegistry;
1716
use Doctrine\Persistence\Mapping\ClassMetadata;
@@ -294,7 +293,7 @@ private function getFieldValues(mixed $object, ClassMetadata $class, array $fiel
294293
throw new ConstraintDefinitionException(\sprintf('The field "%s" is not a property of class "%s".', $fieldName, $objectClass));
295294
}
296295

297-
if ($isValueEntity && $object instanceof ($class->getName()) && property_exists(OrmClassMetadata::class, 'propertyAccessors')) {
296+
if ($isValueEntity && $object instanceof ($class->getName()) && property_exists($class, 'propertyAccessors')) {
298297
$fieldValues[$entityFieldName] = $class->propertyAccessors[$fieldName]->getValue($object);
299298
} elseif ($isValueEntity && $object instanceof ($class->getName())) {
300299
$fieldValues[$entityFieldName] = $class->reflFields[$fieldName]->getValue($object);

src/Symfony/Bridge/Doctrine/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"symfony/security-core": "^6.4|^7.0",
4040
"symfony/stopwatch": "^6.4|^7.0",
4141
"symfony/translation": "^6.4|^7.0",
42-
"symfony/type-info": "^7.1",
42+
"symfony/type-info": "^7.1.8",
4343
"symfony/uid": "^6.4|^7.0",
4444
"symfony/validator": "^6.4|^7.0",
4545
"symfony/var-dumper": "^6.4|^7.0",

src/Symfony/Bridge/Twig/Node/FormThemeNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ final class FormThemeNode extends Node
2828
public function __construct(Node $form, Node $resources, int $lineno, $only = false)
2929
{
3030
if (null === $only || \is_string($only)) {
31-
trigger_deprecation('symfony/twig-bridge', '3.12', 'Passing a tag to %s() is deprecated.', __METHOD__);
31+
trigger_deprecation('symfony/twig-bridge', '7.2', 'Passing a tag to %s() is deprecated.', __METHOD__);
3232
$only = \func_num_args() > 4 ? func_get_arg(4) : true;
3333
} elseif (!\is_bool($only)) {
3434
throw new \TypeError(\sprintf('Argument 4 passed to "%s()" must be a boolean, "%s" given.', __METHOD__, get_debug_type($only)));
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
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\Bundle\FrameworkBundle\Tests\Functional;
13+
14+
use Symfony\Bundle\FrameworkBundle\Console\Application;
15+
use Symfony\Component\Console\Tester\CommandTester;
16+
17+
/**
18+
* @group functional
19+
*/
20+
class ContainerLintCommandTest extends AbstractWebTestCase
21+
{
22+
private Application $application;
23+
24+
/**
25+
* @dataProvider containerLintProvider
26+
*/
27+
public function testLintContainer(string $configFile, string $expectedOutput)
28+
{
29+
$kernel = static::createKernel([
30+
'test_case' => 'ContainerDebug',
31+
'root_config' => $configFile,
32+
'debug' => true,
33+
]);
34+
$this->application = new Application($kernel);
35+
36+
$tester = $this->createCommandTester();
37+
$exitCode = $tester->execute([]);
38+
39+
$this->assertSame(0, $exitCode);
40+
$this->assertStringContainsString($expectedOutput, $tester->getDisplay());
41+
}
42+
43+
public static function containerLintProvider(): array
44+
{
45+
return [
46+
'default container' => ['config.yml', 'The container was linted successfully'],
47+
'missing dump file' => ['no_dump.yml', 'The container was linted successfully'],
48+
];
49+
}
50+
51+
private function createCommandTester(): CommandTester
52+
{
53+
return new CommandTester($this->application->get('lint:container'));
54+
}
55+
}

src/Symfony/Bundle/FrameworkBundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"symfony/string": "^6.4|^7.0",
6666
"symfony/translation": "^7.3",
6767
"symfony/twig-bundle": "^6.4|^7.0",
68-
"symfony/type-info": "^7.1",
68+
"symfony/type-info": "^7.1.8",
6969
"symfony/validator": "^6.4|^7.0",
7070
"symfony/workflow": "^7.3",
7171
"symfony/yaml": "^6.4|^7.0",

src/Symfony/Component/ErrorHandler/Tests/ErrorRenderer/HtmlErrorRendererTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public static function provideFileLinkFormats(): iterable
100100

101101
public function testRendersStackWithoutBinaryStrings()
102102
{
103-
// make sure method arguments are available in stack traces (see https://www.php.net/manual/en/ini.core.php)
103+
// make sure method arguments are available in stack traces (see https://php.net/ini.core)
104104
ini_set('zend.exception_ignore_args', false);
105105

106106
$binaryData = file_get_contents(__DIR__.'/../Fixtures/pixel.png');

src/Symfony/Component/Filesystem/Filesystem.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ public function chmod(string|iterable $files, int $mode, int $umask = 0000, bool
225225
*
226226
* This method always throws on Windows, as the underlying PHP function is not supported.
227227
*
228-
* @see https://www.php.net/chown
228+
* @see https://php.net/chown
229229
*
230230
* @param string|int $user A user name or number
231231
* @param bool $recursive Whether change the owner recursively or not
@@ -255,7 +255,7 @@ public function chown(string|iterable $files, string|int $user, bool $recursive
255255
*
256256
* This method always throws on Windows, as the underlying PHP function is not supported.
257257
*
258-
* @see https://www.php.net/chgrp
258+
* @see https://php.net/chgrp
259259
*
260260
* @param string|int $group A group name or number
261261
* @param bool $recursive Whether change the group recursively or not

src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ protected function castParsedValue(int|float $value): int|float
185185
*/
186186
private function round(int|float $number): int|float
187187
{
188+
if (\is_int($number)) {
189+
return $number;
190+
}
191+
188192
if (null !== $this->scale) {
189193
// shift number to maintain the correct scale during rounding
190194
$roundingCoef = 10 ** $this->scale;

src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,4 +726,33 @@ public static function eNotationProvider(): array
726726
[1232.0, '1.232e3'],
727727
];
728728
}
729+
730+
public function testReverseTransformDoesNotCauseIntegerPrecisionLoss()
731+
{
732+
$transformer = new NumberToLocalizedStringTransformer();
733+
734+
// Test a large integer that causes actual precision loss when cast to float
735+
$largeInt = \PHP_INT_MAX - 1; // This value loses precision when cast to float
736+
$result = $transformer->reverseTransform((string) $largeInt);
737+
738+
$this->assertSame($largeInt, $result);
739+
$this->assertIsInt($result);
740+
}
741+
742+
public function testRoundMethodKeepsIntegersAsIntegers()
743+
{
744+
$transformer = new NumberToLocalizedStringTransformer(2); // scale=2 triggers rounding
745+
746+
// Use reflection to test the private round() method directly
747+
$reflection = new \ReflectionClass($transformer);
748+
$roundMethod = $reflection->getMethod('round');
749+
$roundMethod->setAccessible(true);
750+
751+
$int = \PHP_INT_MAX - 1;
752+
$result = $roundMethod->invoke($transformer, $int);
753+
754+
// With the fix, integers should stay as integers, not be converted to floats
755+
$this->assertSame($int, $result);
756+
$this->assertIsInt($result);
757+
}
729758
}

src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public function start(): bool
123123
* ---------- Part 1
124124
*
125125
* The part `[a-zA-Z0-9,-]` is related to the PHP ini directive `session.sid_bits_per_character` defined as 6.
126-
* See https://www.php.net/manual/en/session.configuration.php#ini.session.sid-bits-per-character.
126+
* See https://php.net/session.configuration#ini.session.sid-bits-per-character
127127
* Allowed values are integers such as:
128128
* - 4 for range `a-f0-9`
129129
* - 5 for range `a-v0-9` (@deprecated since Symfony 7.2, it will default to 4 and the option will be ignored in Symfony 8.0)
@@ -132,7 +132,7 @@ public function start(): bool
132132
* ---------- Part 2
133133
*
134134
* The part `{22,250}` is related to the PHP ini directive `session.sid_length`.
135-
* See https://www.php.net/manual/en/session.configuration.php#ini.session.sid-length.
135+
* See https://php.net/session.configuration#ini.session.sid-length
136136
* Allowed values are integers between 22 and 256, but we use 250 for the max.
137137
*
138138
* Where does the 250 come from?

0 commit comments

Comments
 (0)