Skip to content

Commit 85c4258

Browse files
Merge branch '4.4' into 5.1
* 4.4: Enable "native_constant_invocation" CS rule Make AbstractPhpFileCacheWarmer public
2 parents db6acf2 + ba48cc3 commit 85c4258

File tree

8 files changed

+44
-44
lines changed

8 files changed

+44
-44
lines changed

Constraints/FileValidator.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function validate($value, Constraint $constraint)
5353

5454
if ($value instanceof UploadedFile && !$value->isValid()) {
5555
switch ($value->getError()) {
56-
case UPLOAD_ERR_INI_SIZE:
56+
case \UPLOAD_ERR_INI_SIZE:
5757
$iniLimitSize = UploadedFile::getMaxFilesize();
5858
if ($constraint->maxSize && $constraint->maxSize < $iniLimitSize) {
5959
$limitInBytes = $constraint->maxSize;
@@ -67,43 +67,43 @@ public function validate($value, Constraint $constraint)
6767
$this->context->buildViolation($constraint->uploadIniSizeErrorMessage)
6868
->setParameter('{{ limit }}', $limitAsString)
6969
->setParameter('{{ suffix }}', $suffix)
70-
->setCode((string) UPLOAD_ERR_INI_SIZE)
70+
->setCode((string) \UPLOAD_ERR_INI_SIZE)
7171
->addViolation();
7272

7373
return;
74-
case UPLOAD_ERR_FORM_SIZE:
74+
case \UPLOAD_ERR_FORM_SIZE:
7575
$this->context->buildViolation($constraint->uploadFormSizeErrorMessage)
76-
->setCode((string) UPLOAD_ERR_FORM_SIZE)
76+
->setCode((string) \UPLOAD_ERR_FORM_SIZE)
7777
->addViolation();
7878

7979
return;
80-
case UPLOAD_ERR_PARTIAL:
80+
case \UPLOAD_ERR_PARTIAL:
8181
$this->context->buildViolation($constraint->uploadPartialErrorMessage)
82-
->setCode((string) UPLOAD_ERR_PARTIAL)
82+
->setCode((string) \UPLOAD_ERR_PARTIAL)
8383
->addViolation();
8484

8585
return;
86-
case UPLOAD_ERR_NO_FILE:
86+
case \UPLOAD_ERR_NO_FILE:
8787
$this->context->buildViolation($constraint->uploadNoFileErrorMessage)
88-
->setCode((string) UPLOAD_ERR_NO_FILE)
88+
->setCode((string) \UPLOAD_ERR_NO_FILE)
8989
->addViolation();
9090

9191
return;
92-
case UPLOAD_ERR_NO_TMP_DIR:
92+
case \UPLOAD_ERR_NO_TMP_DIR:
9393
$this->context->buildViolation($constraint->uploadNoTmpDirErrorMessage)
94-
->setCode((string) UPLOAD_ERR_NO_TMP_DIR)
94+
->setCode((string) \UPLOAD_ERR_NO_TMP_DIR)
9595
->addViolation();
9696

9797
return;
98-
case UPLOAD_ERR_CANT_WRITE:
98+
case \UPLOAD_ERR_CANT_WRITE:
9999
$this->context->buildViolation($constraint->uploadCantWriteErrorMessage)
100-
->setCode((string) UPLOAD_ERR_CANT_WRITE)
100+
->setCode((string) \UPLOAD_ERR_CANT_WRITE)
101101
->addViolation();
102102

103103
return;
104-
case UPLOAD_ERR_EXTENSION:
104+
case \UPLOAD_ERR_EXTENSION:
105105
$this->context->buildViolation($constraint->uploadExtensionErrorMessage)
106-
->setCode((string) UPLOAD_ERR_EXTENSION)
106+
->setCode((string) \UPLOAD_ERR_EXTENSION)
107107
->addViolation();
108108

109109
return;

Constraints/HostnameValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function validate($value, Constraint $constraint)
5959

6060
private function isValid(string $domain): bool
6161
{
62-
return false !== filter_var($domain, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME);
62+
return false !== filter_var($domain, \FILTER_VALIDATE_DOMAIN, \FILTER_FLAG_HOSTNAME);
6363
}
6464

6565
private function hasValidTld(string $domain): bool

Constraints/IpValidator.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,55 +49,55 @@ public function validate($value, Constraint $constraint)
4949

5050
switch ($constraint->version) {
5151
case Ip::V4:
52-
$flag = FILTER_FLAG_IPV4;
52+
$flag = \FILTER_FLAG_IPV4;
5353
break;
5454

5555
case Ip::V6:
56-
$flag = FILTER_FLAG_IPV6;
56+
$flag = \FILTER_FLAG_IPV6;
5757
break;
5858

5959
case Ip::V4_NO_PRIV:
60-
$flag = FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE;
60+
$flag = \FILTER_FLAG_IPV4 | \FILTER_FLAG_NO_PRIV_RANGE;
6161
break;
6262

6363
case Ip::V6_NO_PRIV:
64-
$flag = FILTER_FLAG_IPV6 | FILTER_FLAG_NO_PRIV_RANGE;
64+
$flag = \FILTER_FLAG_IPV6 | \FILTER_FLAG_NO_PRIV_RANGE;
6565
break;
6666

6767
case Ip::ALL_NO_PRIV:
68-
$flag = FILTER_FLAG_NO_PRIV_RANGE;
68+
$flag = \FILTER_FLAG_NO_PRIV_RANGE;
6969
break;
7070

7171
case Ip::V4_NO_RES:
72-
$flag = FILTER_FLAG_IPV4 | FILTER_FLAG_NO_RES_RANGE;
72+
$flag = \FILTER_FLAG_IPV4 | \FILTER_FLAG_NO_RES_RANGE;
7373
break;
7474

7575
case Ip::V6_NO_RES:
76-
$flag = FILTER_FLAG_IPV6 | FILTER_FLAG_NO_RES_RANGE;
76+
$flag = \FILTER_FLAG_IPV6 | \FILTER_FLAG_NO_RES_RANGE;
7777
break;
7878

7979
case Ip::ALL_NO_RES:
80-
$flag = FILTER_FLAG_NO_RES_RANGE;
80+
$flag = \FILTER_FLAG_NO_RES_RANGE;
8181
break;
8282

8383
case Ip::V4_ONLY_PUBLIC:
84-
$flag = FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE;
84+
$flag = \FILTER_FLAG_IPV4 | \FILTER_FLAG_NO_PRIV_RANGE | \FILTER_FLAG_NO_RES_RANGE;
8585
break;
8686

8787
case Ip::V6_ONLY_PUBLIC:
88-
$flag = FILTER_FLAG_IPV6 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE;
88+
$flag = \FILTER_FLAG_IPV6 | \FILTER_FLAG_NO_PRIV_RANGE | \FILTER_FLAG_NO_RES_RANGE;
8989
break;
9090

9191
case Ip::ALL_ONLY_PUBLIC:
92-
$flag = FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE;
92+
$flag = \FILTER_FLAG_NO_PRIV_RANGE | \FILTER_FLAG_NO_RES_RANGE;
9393
break;
9494

9595
default:
9696
$flag = null;
9797
break;
9898
}
9999

100-
if (!filter_var($value, FILTER_VALIDATE_IP, $flag)) {
100+
if (!filter_var($value, \FILTER_VALIDATE_IP, $flag)) {
101101
$this->context->buildViolation($constraint->message)
102102
->setParameter('{{ value }}', $this->formatValue($value))
103103
->setCode(Ip::INVALID_IP_ERROR)

Constraints/JsonValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function validate($value, Constraint $constraint)
4141

4242
json_decode($value);
4343

44-
if (JSON_ERROR_NONE !== json_last_error()) {
44+
if (\JSON_ERROR_NONE !== json_last_error()) {
4545
$this->context->buildViolation($constraint->message)
4646
->setParameter('{{ value }}', $this->formatValue($value))
4747
->setCode(Json::INVALID_JSON_ERROR)

Tests/Constraints/DivisibleByValidatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function provideInvalidComparisons(): array
7272
[1, '1', 2, '2', 'int'],
7373
[10, '10', 3, '3', 'int'],
7474
[10, '10', 0, '0', 'int'],
75-
[42, '42', INF, 'INF', 'float'],
75+
[42, '42', \INF, 'INF', 'float'],
7676
[4.15, '4.15', 0.1, '0.1', 'float'],
7777
['22', '"22"', '10', '"10"', 'string'],
7878
];

Tests/Constraints/FileValidatorTest.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public function provideMaxSizeExceededTests()
159159
*/
160160
public function testMaxSizeExceeded($bytesWritten, $limit, $sizeAsString, $limitAsString, $suffix)
161161
{
162-
fseek($this->file, $bytesWritten - 1, SEEK_SET);
162+
fseek($this->file, $bytesWritten - 1, \SEEK_SET);
163163
fwrite($this->file, '0');
164164
fclose($this->file);
165165

@@ -208,7 +208,7 @@ public function provideMaxSizeNotExceededTests()
208208
*/
209209
public function testMaxSizeNotExceeded($bytesWritten, $limit)
210210
{
211-
fseek($this->file, $bytesWritten - 1, SEEK_SET);
211+
fseek($this->file, $bytesWritten - 1, \SEEK_SET);
212212
fwrite($this->file, '0');
213213
fclose($this->file);
214214

@@ -259,7 +259,7 @@ public function provideBinaryFormatTests()
259259
*/
260260
public function testBinaryFormat($bytesWritten, $limit, $binaryFormat, $sizeAsString, $limitAsString, $suffix)
261261
{
262-
fseek($this->file, $bytesWritten - 1, SEEK_SET);
262+
fseek($this->file, $bytesWritten - 1, \SEEK_SET);
263263
fwrite($this->file, '0');
264264
fclose($this->file);
265265

@@ -431,23 +431,23 @@ public function testUploadedFileError($error, $message, array $params = [], $max
431431
public function uploadedFileErrorProvider()
432432
{
433433
$tests = [
434-
[(string) UPLOAD_ERR_FORM_SIZE, 'uploadFormSizeErrorMessage'],
435-
[(string) UPLOAD_ERR_PARTIAL, 'uploadPartialErrorMessage'],
436-
[(string) UPLOAD_ERR_NO_FILE, 'uploadNoFileErrorMessage'],
437-
[(string) UPLOAD_ERR_NO_TMP_DIR, 'uploadNoTmpDirErrorMessage'],
438-
[(string) UPLOAD_ERR_CANT_WRITE, 'uploadCantWriteErrorMessage'],
439-
[(string) UPLOAD_ERR_EXTENSION, 'uploadExtensionErrorMessage'],
434+
[(string) \UPLOAD_ERR_FORM_SIZE, 'uploadFormSizeErrorMessage'],
435+
[(string) \UPLOAD_ERR_PARTIAL, 'uploadPartialErrorMessage'],
436+
[(string) \UPLOAD_ERR_NO_FILE, 'uploadNoFileErrorMessage'],
437+
[(string) \UPLOAD_ERR_NO_TMP_DIR, 'uploadNoTmpDirErrorMessage'],
438+
[(string) \UPLOAD_ERR_CANT_WRITE, 'uploadCantWriteErrorMessage'],
439+
[(string) \UPLOAD_ERR_EXTENSION, 'uploadExtensionErrorMessage'],
440440
];
441441

442442
if (class_exists('Symfony\Component\HttpFoundation\File\UploadedFile')) {
443443
// when no maxSize is specified on constraint, it should use the ini value
444-
$tests[] = [(string) UPLOAD_ERR_INI_SIZE, 'uploadIniSizeErrorMessage', [
444+
$tests[] = [(string) \UPLOAD_ERR_INI_SIZE, 'uploadIniSizeErrorMessage', [
445445
'{{ limit }}' => UploadedFile::getMaxFilesize() / 1048576,
446446
'{{ suffix }}' => 'MiB',
447447
]];
448448

449449
// it should use the smaller limitation (maxSize option in this case)
450-
$tests[] = [(string) UPLOAD_ERR_INI_SIZE, 'uploadIniSizeErrorMessage', [
450+
$tests[] = [(string) \UPLOAD_ERR_INI_SIZE, 'uploadIniSizeErrorMessage', [
451451
'{{ limit }}' => 1,
452452
'{{ suffix }}' => 'bytes',
453453
], '1'];
@@ -460,14 +460,14 @@ public function uploadedFileErrorProvider()
460460

461461
// it correctly parses the maxSize option and not only uses simple string comparison
462462
// 1000M should be bigger than the ini value
463-
$tests[] = [(string) UPLOAD_ERR_INI_SIZE, 'uploadIniSizeErrorMessage', [
463+
$tests[] = [(string) \UPLOAD_ERR_INI_SIZE, 'uploadIniSizeErrorMessage', [
464464
'{{ limit }}' => $limit,
465465
'{{ suffix }}' => $suffix,
466466
], '1000M'];
467467

468468
// it correctly parses the maxSize option and not only uses simple string comparison
469469
// 1000M should be bigger than the ini value
470-
$tests[] = [(string) UPLOAD_ERR_INI_SIZE, 'uploadIniSizeErrorMessage', [
470+
$tests[] = [(string) \UPLOAD_ERR_INI_SIZE, 'uploadIniSizeErrorMessage', [
471471
'{{ limit }}' => '0.1',
472472
'{{ suffix }}' => 'MB',
473473
], '100K'];

Tests/Mapping/Loader/YamlFileLoaderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public function testLoadClassMetadataWithConstants()
132132
$loader->loadClassMetadata($metadata);
133133

134134
$expected = new ClassMetadata('Symfony\Component\Validator\Tests\Fixtures\Entity');
135-
$expected->addPropertyConstraint('firstName', new Range(['max' => PHP_INT_MAX]));
135+
$expected->addPropertyConstraint('firstName', new Range(['max' => \PHP_INT_MAX]));
136136

137137
$this->assertEquals($expected, $metadata);
138138
}

Validator/TraceableValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function validate($value, $constraints = null, $groups = null)
6565
{
6666
$violations = $this->validator->validate($value, $constraints, $groups);
6767

68-
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 7);
68+
$trace = debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 7);
6969

7070
$file = $trace[0]['file'];
7171
$line = $trace[0]['line'];

0 commit comments

Comments
 (0)