Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 266a6bb

Browse filesBrowse files
Merge branch '5.2' into 5.x
* 5.2: [PhpUnitBridge] CS fix [Notifier] Only use sprintf instead of sprintf and string concat [PhpUnitBridge] Fix PHP 5.5 compatibility Fix exception thrown by Form when converting UUID [Notifier] Remove trailing argument in tests [Serializer] Make fabbot happy with 5.2 tests CS Add missing param annotation abouts $fileLinkFormat [HttpClient] Use decoration instead of class replacement for mock factory [Form] Fixed StringUtil::trim() to trim ZERO WIDTH SPACE (U+200B) and SOFT HYPHEN (U+00AD) 23412 Stop treating multiline resources as globs
2 parents fda67f5 + 20cd8c6 commit 266a6bb
Copy full SHA for 266a6bb

File tree

Expand file treeCollapse file tree

31 files changed

+154
-81
lines changed
Filter options
Expand file treeCollapse file tree

31 files changed

+154
-81
lines changed

‎src/Symfony/Bridge/Doctrine/Form/ChoiceList/ORMQueryBuilderLoader.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Form/ChoiceList/ORMQueryBuilderLoader.php
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
namespace Symfony\Bridge\Doctrine\Form\ChoiceList;
1313

1414
use Doctrine\DBAL\Connection;
15+
use Doctrine\DBAL\Types\ConversionException;
1516
use Doctrine\DBAL\Types\Type;
1617
use Doctrine\ORM\QueryBuilder;
18+
use Symfony\Component\Form\Exception\TransformationFailedException;
1719

1820
/**
1921
* Loads entities using a {@link QueryBuilder} instance.
@@ -96,7 +98,11 @@ public function getEntitiesByIds(string $identifier, array $values)
9698
$doctrineType = Type::getType($type);
9799
$platform = $qb->getEntityManager()->getConnection()->getDatabasePlatform();
98100
foreach ($values as &$value) {
99-
$value = $doctrineType->convertToDatabaseValue($value, $platform);
101+
try {
102+
$value = $doctrineType->convertToDatabaseValue($value, $platform);
103+
} catch (ConversionException $e) {
104+
throw new TransformationFailedException(sprintf('Failed to transform "%s" into "%s".', $value, $type), 0, $e);
105+
}
100106
}
101107
unset($value);
102108
}

‎src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/ORMQueryBuilderLoaderTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Tests/Form/ChoiceList/ORMQueryBuilderLoaderTest.php
+36Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper;
2121
use Symfony\Bridge\Doctrine\Types\UlidType;
2222
use Symfony\Bridge\Doctrine\Types\UuidType;
23+
use Symfony\Component\Form\Exception\TransformationFailedException;
2324
use Symfony\Component\Uid\Uuid;
2425

2526
class ORMQueryBuilderLoaderTest extends TestCase
@@ -188,6 +189,41 @@ public function testFilterUid($entityClass)
188189
$loader->getEntitiesByIds('id', ['71c5fd46-3f16-4abb-bad7-90ac1e654a2d', '', 'b98e8e11-2897-44df-ad24-d2627eb7f499']);
189190
}
190191

192+
/**
193+
* @dataProvider provideUidEntityClasses
194+
*/
195+
public function testUidThrowProperException($entityClass)
196+
{
197+
if (Type::hasType('uuid')) {
198+
Type::overrideType('uuid', UuidType::class);
199+
} else {
200+
Type::addType('uuid', UuidType::class);
201+
}
202+
if (!Type::hasType('ulid')) {
203+
Type::addType('ulid', UlidType::class);
204+
}
205+
206+
$em = DoctrineTestHelper::createTestEntityManager();
207+
208+
$qb = $this->getMockBuilder('Doctrine\ORM\QueryBuilder')
209+
->setConstructorArgs([$em])
210+
->setMethods(['getQuery'])
211+
->getMock();
212+
213+
$qb->expects($this->never())
214+
->method('getQuery');
215+
216+
$qb->select('e')
217+
->from($entityClass, 'e');
218+
219+
$loader = new ORMQueryBuilderLoader($qb);
220+
221+
$this->expectException(TransformationFailedException::class);
222+
$this->expectExceptionMessageMatches('/^Failed to transform "hello" into "(uuid|ulid)"\.$/');
223+
224+
$loader->getEntitiesByIds('id', ['hello']);
225+
}
226+
191227
public function testEmbeddedIdentifierName()
192228
{
193229
if (Version::compare('2.5.0') > 0) {

‎src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Deprecation
4141

4242
/**
4343
* @var string[] Absolute paths to source or tests of the project, cache
44-
* directories exlcuded because it is based on autoloading
44+
* directories excluded because it is based on autoloading
4545
* rules and cache systems typically do not use those
4646
*/
4747
private static $internalPaths = [];
@@ -61,10 +61,10 @@ public function __construct($message, array $trace, $file)
6161

6262
$this->trace = $trace;
6363

64-
if ('trigger_error' === ($trace[1]['function'] ?? null)
65-
&& (DebugClassLoader::class === ($class = $trace[2]['class'] ?? null) || LegacyDebugClassLoader::class === $class)
66-
&& 'checkClass' === ($trace[2]['function'] ?? null)
67-
&& null !== ($extraFile = $trace[2]['args'][1] ?? null)
64+
if ('trigger_error' === (isset($trace[1]['function']) ? $trace[1]['function'] : null)
65+
&& (DebugClassLoader::class === ($class = (isset($trace[2]['class']) ? $trace[2]['class'] : null)) || LegacyDebugClassLoader::class === $class)
66+
&& 'checkClass' === (isset($trace[2]['function']) ? $trace[2]['function'] : null)
67+
&& null !== ($extraFile = (isset($trace[2]['args'][1]) ? $trace[2]['args'][1] : null))
6868
&& '' !== $extraFile
6969
&& false !== $extraFile = realpath($extraFile)
7070
) {

‎src/Symfony/Bridge/PhpUnit/DnsMock.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/PhpUnit/DnsMock.php
+15-15Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ class DnsMock
1818
{
1919
private static $hosts = [];
2020
private static $dnsTypes = [
21-
'A' => DNS_A,
22-
'MX' => DNS_MX,
23-
'NS' => DNS_NS,
24-
'SOA' => DNS_SOA,
25-
'PTR' => DNS_PTR,
26-
'CNAME' => DNS_CNAME,
27-
'AAAA' => DNS_AAAA,
28-
'A6' => DNS_A6,
29-
'SRV' => DNS_SRV,
30-
'NAPTR' => DNS_NAPTR,
31-
'TXT' => DNS_TXT,
32-
'HINFO' => DNS_HINFO,
21+
'A' => \DNS_A,
22+
'MX' => \DNS_MX,
23+
'NS' => \DNS_NS,
24+
'SOA' => \DNS_SOA,
25+
'PTR' => \DNS_PTR,
26+
'CNAME' => \DNS_CNAME,
27+
'AAAA' => \DNS_AAAA,
28+
'A6' => \DNS_A6,
29+
'SRV' => \DNS_SRV,
30+
'NAPTR' => \DNS_NAPTR,
31+
'TXT' => \DNS_TXT,
32+
'HINFO' => \DNS_HINFO,
3333
];
3434

3535
/**
@@ -137,7 +137,7 @@ public static function gethostbynamel($hostname)
137137
return $ips;
138138
}
139139

140-
public static function dns_get_record($hostname, $type = DNS_ANY, &$authns = null, &$addtl = null, $raw = false)
140+
public static function dns_get_record($hostname, $type = \DNS_ANY, &$authns = null, &$addtl = null, $raw = false)
141141
{
142142
if (!self::$hosts) {
143143
return \dns_get_record($hostname, $type, $authns, $addtl, $raw);
@@ -146,8 +146,8 @@ public static function dns_get_record($hostname, $type = DNS_ANY, &$authns = nul
146146
$records = false;
147147

148148
if (isset(self::$hosts[$hostname])) {
149-
if (DNS_ANY === $type) {
150-
$type = DNS_ALL;
149+
if (\DNS_ANY === $type) {
150+
$type = \DNS_ALL;
151151
}
152152
$records = [];
153153

‎src/Symfony/Bridge/PhpUnit/Legacy/ExpectDeprecationTraitForV8_4.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/PhpUnit/Legacy/ExpectDeprecationTraitForV8_4.php
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Symfony\Bridge\PhpUnit\Legacy;
1313

1414
/**
15-
* @internal use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait instead.
15+
* @internal use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait instead
1616
*/
1717
trait ExpectDeprecationTraitForV8_4
1818
{
@@ -21,7 +21,7 @@ trait ExpectDeprecationTraitForV8_4
2121
*/
2222
public function expectDeprecation(): void
2323
{
24-
if (1 > func_num_args() || !\is_string($message = func_get_arg(0))) {
24+
if (1 > \func_num_args() || !\is_string($message = func_get_arg(0))) {
2525
throw new \InvalidArgumentException(sprintf('The "%s()" method requires the string $message argument.', __FUNCTION__));
2626
}
2727

@@ -48,15 +48,15 @@ public function expectDeprecation(): void
4848
}
4949

5050
/**
51-
* @internal use expectDeprecation() instead.
51+
* @internal use expectDeprecation() instead
5252
*/
5353
public function expectDeprecationMessage(string $message): void
5454
{
5555
throw new \BadMethodCallException(sprintf('The "%s()" method is not supported by Symfony\'s PHPUnit Bridge ExpectDeprecationTrait, pass the message to expectDeprecation() instead.', __FUNCTION__));
5656
}
5757

5858
/**
59-
* @internal use expectDeprecation() instead.
59+
* @internal use expectDeprecation() instead
6060
*/
6161
public function expectDeprecationMessageMatches(string $regularExpression): void
6262
{

‎src/Symfony/Bridge/PhpUnit/Legacy/PolyfillAssertTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/PhpUnit/Legacy/PolyfillAssertTrait.php
+11-12Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use PHPUnit\Framework\Constraint\IsEqual;
1515
use PHPUnit\Framework\Constraint\LogicalNot;
16-
use PHPUnit\Framework\Constraint\RegularExpression;
1716
use PHPUnit\Framework\Constraint\StringContains;
1817
use PHPUnit\Framework\Constraint\TraversableContains;
1918

@@ -228,7 +227,7 @@ public static function assertStringNotContainsStringIgnoringCase($needle, $hayst
228227
public static function assertFinite($actual, $message = '')
229228
{
230229
static::assertInternalType('float', $actual, $message);
231-
static::assertTrue(is_finite($actual), $message ? $message : "Failed asserting that $actual is finite.");
230+
static::assertTrue(is_finite($actual), $message ?: "Failed asserting that $actual is finite.");
232231
}
233232

234233
/**
@@ -239,7 +238,7 @@ public static function assertFinite($actual, $message = '')
239238
public static function assertInfinite($actual, $message = '')
240239
{
241240
static::assertInternalType('float', $actual, $message);
242-
static::assertTrue(is_infinite($actual), $message ? $message : "Failed asserting that $actual is infinite.");
241+
static::assertTrue(is_infinite($actual), $message ?: "Failed asserting that $actual is infinite.");
243242
}
244243

245244
/**
@@ -250,7 +249,7 @@ public static function assertInfinite($actual, $message = '')
250249
public static function assertNan($actual, $message = '')
251250
{
252251
static::assertInternalType('float', $actual, $message);
253-
static::assertTrue(is_nan($actual), $message ? $message : "Failed asserting that $actual is nan.");
252+
static::assertTrue(is_nan($actual), $message ?: "Failed asserting that $actual is nan.");
254253
}
255254

256255
/**
@@ -262,7 +261,7 @@ public static function assertNan($actual, $message = '')
262261
public static function assertIsReadable($filename, $message = '')
263262
{
264263
static::assertInternalType('string', $filename, $message);
265-
static::assertTrue(is_readable($filename), $message ? $message : "Failed asserting that $filename is readable.");
264+
static::assertTrue(is_readable($filename), $message ?: "Failed asserting that $filename is readable.");
266265
}
267266

268267
/**
@@ -274,7 +273,7 @@ public static function assertIsReadable($filename, $message = '')
274273
public static function assertNotIsReadable($filename, $message = '')
275274
{
276275
static::assertInternalType('string', $filename, $message);
277-
static::assertFalse(is_readable($filename), $message ? $message : "Failed asserting that $filename is not readable.");
276+
static::assertFalse(is_readable($filename), $message ?: "Failed asserting that $filename is not readable.");
278277
}
279278

280279
/**
@@ -297,7 +296,7 @@ public static function assertIsNotReadable($filename, $message = '')
297296
public static function assertIsWritable($filename, $message = '')
298297
{
299298
static::assertInternalType('string', $filename, $message);
300-
static::assertTrue(is_writable($filename), $message ? $message : "Failed asserting that $filename is writable.");
299+
static::assertTrue(is_writable($filename), $message ?: "Failed asserting that $filename is writable.");
301300
}
302301

303302
/**
@@ -309,7 +308,7 @@ public static function assertIsWritable($filename, $message = '')
309308
public static function assertNotIsWritable($filename, $message = '')
310309
{
311310
static::assertInternalType('string', $filename, $message);
312-
static::assertFalse(is_writable($filename), $message ? $message : "Failed asserting that $filename is not writable.");
311+
static::assertFalse(is_writable($filename), $message ?: "Failed asserting that $filename is not writable.");
313312
}
314313

315314
/**
@@ -332,7 +331,7 @@ public static function assertIsNotWritable($filename, $message = '')
332331
public static function assertDirectoryExists($directory, $message = '')
333332
{
334333
static::assertInternalType('string', $directory, $message);
335-
static::assertTrue(is_dir($directory), $message ? $message : "Failed asserting that $directory exists.");
334+
static::assertTrue(is_dir($directory), $message ?: "Failed asserting that $directory exists.");
336335
}
337336

338337
/**
@@ -344,7 +343,7 @@ public static function assertDirectoryExists($directory, $message = '')
344343
public static function assertDirectoryNotExists($directory, $message = '')
345344
{
346345
static::assertInternalType('string', $directory, $message);
347-
static::assertFalse(is_dir($directory), $message ? $message : "Failed asserting that $directory does not exist.");
346+
static::assertFalse(is_dir($directory), $message ?: "Failed asserting that $directory does not exist.");
348347
}
349348

350349
/**
@@ -437,7 +436,7 @@ public static function assertDirectoryIsNotWritable($directory, $message = '')
437436
public static function assertFileExists($filename, $message = '')
438437
{
439438
static::assertInternalType('string', $filename, $message);
440-
static::assertTrue(file_exists($filename), $message ? $message : "Failed asserting that $filename exists.");
439+
static::assertTrue(file_exists($filename), $message ?: "Failed asserting that $filename exists.");
441440
}
442441

443442
/**
@@ -449,7 +448,7 @@ public static function assertFileExists($filename, $message = '')
449448
public static function assertFileNotExists($filename, $message = '')
450449
{
451450
static::assertInternalType('string', $filename, $message);
452-
static::assertFalse(file_exists($filename), $message ? $message : "Failed asserting that $filename does not exist.");
451+
static::assertFalse(file_exists($filename), $message ?: "Failed asserting that $filename does not exist.");
453452
}
454453

455454
/**

‎src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ public function startTest($test)
235235
if (isset($annotations['method']['expectedDeprecation'])) {
236236
self::$expectedDeprecations = $annotations['method']['expectedDeprecation'];
237237
self::$previousErrorHandler = set_error_handler([self::class, 'handleError']);
238-
@trigger_error('Since symfony/phpunit-bridge 5.1: Using "@expectedDeprecation" annotations in tests is deprecated, use the "ExpectDeprecationTrait::expectDeprecation()" method instead.', E_USER_DEPRECATED);
238+
@trigger_error('Since symfony/phpunit-bridge 5.1: Using "@expectedDeprecation" annotations in tests is deprecated, use the "ExpectDeprecationTrait::expectDeprecation()" method instead.', \E_USER_DEPRECATED);
239239
}
240240

241241
if ($this->checkNumAssertions) {
@@ -283,9 +283,9 @@ public function endTest($test, $time)
283283
$error = serialize(['deprecation' => $deprecation[1], 'class' => $className, 'method' => $test->getName(false), 'triggering_file' => isset($deprecation[2]) ? $deprecation[2] : null]);
284284
if ($deprecation[0]) {
285285
// unsilenced on purpose
286-
trigger_error($error, E_USER_DEPRECATED);
286+
trigger_error($error, \E_USER_DEPRECATED);
287287
} else {
288-
@trigger_error($error, E_USER_DEPRECATED);
288+
@trigger_error($error, \E_USER_DEPRECATED);
289289
}
290290
}
291291
$this->runsInSeparateProcess = false;
@@ -324,7 +324,7 @@ public function endTest($test, $time)
324324

325325
public static function handleError($type, $msg, $file, $line, $context = [])
326326
{
327-
if (E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) {
327+
if (\E_USER_DEPRECATED !== $type && \E_DEPRECATED !== $type) {
328328
$h = self::$previousErrorHandler;
329329

330330
return $h ? $h($type, $msg, $file, $line, $context) : false;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.