Skip to content

Commit 451ce73

Browse files
Enable "native_constant_invocation" CS rule
1 parent 0d493f9 commit 451ce73

File tree

8 files changed

+45
-45
lines changed

8 files changed

+45
-45
lines changed

Constraints/ChoiceValidator.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

6161
if (true !== $constraint->strict) {
62-
@trigger_error('Not setting the strict option of the Choice constraint to true is deprecated since Symfony 3.4 and will throw an exception in 4.0.', E_USER_DEPRECATED);
62+
@trigger_error('Not setting the strict option of the Choice constraint to true is deprecated since Symfony 3.4 and will throw an exception in 4.0.', \E_USER_DEPRECATED);
6363
}
6464

6565
if ($constraint->multiple) {

Constraints/FileValidator.php

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

5151
if ($value instanceof UploadedFile && !$value->isValid()) {
5252
switch ($value->getError()) {
53-
case UPLOAD_ERR_INI_SIZE:
53+
case \UPLOAD_ERR_INI_SIZE:
5454
$iniLimitSize = UploadedFile::getMaxFilesize();
5555
if ($constraint->maxSize && $constraint->maxSize < $iniLimitSize) {
5656
$limitInBytes = $constraint->maxSize;
@@ -64,43 +64,43 @@ public function validate($value, Constraint $constraint)
6464
$this->context->buildViolation($constraint->uploadIniSizeErrorMessage)
6565
->setParameter('{{ limit }}', $limitAsString)
6666
->setParameter('{{ suffix }}', $suffix)
67-
->setCode(UPLOAD_ERR_INI_SIZE)
67+
->setCode(\UPLOAD_ERR_INI_SIZE)
6868
->addViolation();
6969

7070
return;
71-
case UPLOAD_ERR_FORM_SIZE:
71+
case \UPLOAD_ERR_FORM_SIZE:
7272
$this->context->buildViolation($constraint->uploadFormSizeErrorMessage)
73-
->setCode(UPLOAD_ERR_FORM_SIZE)
73+
->setCode(\UPLOAD_ERR_FORM_SIZE)
7474
->addViolation();
7575

7676
return;
77-
case UPLOAD_ERR_PARTIAL:
77+
case \UPLOAD_ERR_PARTIAL:
7878
$this->context->buildViolation($constraint->uploadPartialErrorMessage)
79-
->setCode(UPLOAD_ERR_PARTIAL)
79+
->setCode(\UPLOAD_ERR_PARTIAL)
8080
->addViolation();
8181

8282
return;
83-
case UPLOAD_ERR_NO_FILE:
83+
case \UPLOAD_ERR_NO_FILE:
8484
$this->context->buildViolation($constraint->uploadNoFileErrorMessage)
85-
->setCode(UPLOAD_ERR_NO_FILE)
85+
->setCode(\UPLOAD_ERR_NO_FILE)
8686
->addViolation();
8787

8888
return;
89-
case UPLOAD_ERR_NO_TMP_DIR:
89+
case \UPLOAD_ERR_NO_TMP_DIR:
9090
$this->context->buildViolation($constraint->uploadNoTmpDirErrorMessage)
91-
->setCode(UPLOAD_ERR_NO_TMP_DIR)
91+
->setCode(\UPLOAD_ERR_NO_TMP_DIR)
9292
->addViolation();
9393

9494
return;
95-
case UPLOAD_ERR_CANT_WRITE:
95+
case \UPLOAD_ERR_CANT_WRITE:
9696
$this->context->buildViolation($constraint->uploadCantWriteErrorMessage)
97-
->setCode(UPLOAD_ERR_CANT_WRITE)
97+
->setCode(\UPLOAD_ERR_CANT_WRITE)
9898
->addViolation();
9999

100100
return;
101-
case UPLOAD_ERR_EXTENSION:
101+
case \UPLOAD_ERR_EXTENSION:
102102
$this->context->buildViolation($constraint->uploadExtensionErrorMessage)
103-
->setCode(UPLOAD_ERR_EXTENSION)
103+
->setCode(\UPLOAD_ERR_EXTENSION)
104104
->addViolation();
105105

106106
return;

Constraints/IpValidator.php

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

4545
switch ($constraint->version) {
4646
case Ip::V4:
47-
$flag = FILTER_FLAG_IPV4;
47+
$flag = \FILTER_FLAG_IPV4;
4848
break;
4949

5050
case Ip::V6:
51-
$flag = FILTER_FLAG_IPV6;
51+
$flag = \FILTER_FLAG_IPV6;
5252
break;
5353

5454
case Ip::V4_NO_PRIV:
55-
$flag = FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE;
55+
$flag = \FILTER_FLAG_IPV4 | \FILTER_FLAG_NO_PRIV_RANGE;
5656
break;
5757

5858
case Ip::V6_NO_PRIV:
59-
$flag = FILTER_FLAG_IPV6 | FILTER_FLAG_NO_PRIV_RANGE;
59+
$flag = \FILTER_FLAG_IPV6 | \FILTER_FLAG_NO_PRIV_RANGE;
6060
break;
6161

6262
case Ip::ALL_NO_PRIV:
63-
$flag = FILTER_FLAG_NO_PRIV_RANGE;
63+
$flag = \FILTER_FLAG_NO_PRIV_RANGE;
6464
break;
6565

6666
case Ip::V4_NO_RES:
67-
$flag = FILTER_FLAG_IPV4 | FILTER_FLAG_NO_RES_RANGE;
67+
$flag = \FILTER_FLAG_IPV4 | \FILTER_FLAG_NO_RES_RANGE;
6868
break;
6969

7070
case Ip::V6_NO_RES:
71-
$flag = FILTER_FLAG_IPV6 | FILTER_FLAG_NO_RES_RANGE;
71+
$flag = \FILTER_FLAG_IPV6 | \FILTER_FLAG_NO_RES_RANGE;
7272
break;
7373

7474
case Ip::ALL_NO_RES:
75-
$flag = FILTER_FLAG_NO_RES_RANGE;
75+
$flag = \FILTER_FLAG_NO_RES_RANGE;
7676
break;
7777

7878
case Ip::V4_ONLY_PUBLIC:
79-
$flag = FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE;
79+
$flag = \FILTER_FLAG_IPV4 | \FILTER_FLAG_NO_PRIV_RANGE | \FILTER_FLAG_NO_RES_RANGE;
8080
break;
8181

8282
case Ip::V6_ONLY_PUBLIC:
83-
$flag = FILTER_FLAG_IPV6 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE;
83+
$flag = \FILTER_FLAG_IPV6 | \FILTER_FLAG_NO_PRIV_RANGE | \FILTER_FLAG_NO_RES_RANGE;
8484
break;
8585

8686
case Ip::ALL_ONLY_PUBLIC:
87-
$flag = FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE;
87+
$flag = \FILTER_FLAG_NO_PRIV_RANGE | \FILTER_FLAG_NO_RES_RANGE;
8888
break;
8989

9090
default:
9191
$flag = null;
9292
break;
9393
}
9494

95-
if (!filter_var($value, FILTER_VALIDATE_IP, $flag)) {
95+
if (!filter_var($value, \FILTER_VALIDATE_IP, $flag)) {
9696
$this->context->buildViolation($constraint->message)
9797
->setParameter('{{ value }}', $this->formatValue($value))
9898
->setCode(Ip::INVALID_IP_ERROR)

Constraints/UrlValidator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function validate($value, Constraint $constraint)
7676
// backwards compatibility
7777
if (true === $constraint->checkDNS) {
7878
$constraint->checkDNS = Url::CHECK_DNS_TYPE_ANY;
79-
@trigger_error(sprintf('Use of the boolean TRUE for the "checkDNS" option in %s is deprecated. Use Url::CHECK_DNS_TYPE_ANY instead.', Url::class), E_USER_DEPRECATED);
79+
@trigger_error(sprintf('Use of the boolean TRUE for the "checkDNS" option in %s is deprecated. Use Url::CHECK_DNS_TYPE_ANY instead.', Url::class), \E_USER_DEPRECATED);
8080
}
8181

8282
if (!\in_array($constraint->checkDNS, [
@@ -96,7 +96,7 @@ public function validate($value, Constraint $constraint)
9696
throw new InvalidOptionsException(sprintf('Invalid value for option "checkDNS" in constraint "%s".', \get_class($constraint)), ['checkDNS']);
9797
}
9898

99-
$host = parse_url($value, PHP_URL_HOST);
99+
$host = parse_url($value, \PHP_URL_HOST);
100100

101101
if (!\is_string($host) || !checkdnsrr($host, $constraint->checkDNS)) {
102102
$this->context->buildViolation($constraint->dnsMessage)

Mapping/Loader/YamlFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ protected function parseNodes(array $nodes)
116116
private function parseFile($path)
117117
{
118118
$prevErrorHandler = set_error_handler(function ($level, $message, $script, $line) use ($path, &$prevErrorHandler) {
119-
$message = E_USER_DEPRECATED === $level ? preg_replace('/ on line \d+/', ' in "'.$path.'"$0', $message) : $message;
119+
$message = \E_USER_DEPRECATED === $level ? preg_replace('/ on line \d+/', ' in "'.$path.'"$0', $message) : $message;
120120

121121
return $prevErrorHandler ? $prevErrorHandler($level, $message, $script, $line) : false;
122122
});

Tests/Constraints/FileValidatorTest.php

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

@@ -206,7 +206,7 @@ public function provideMaxSizeNotExceededTests()
206206
*/
207207
public function testMaxSizeNotExceeded($bytesWritten, $limit)
208208
{
209-
fseek($this->file, $bytesWritten - 1, SEEK_SET);
209+
fseek($this->file, $bytesWritten - 1, \SEEK_SET);
210210
fwrite($this->file, '0');
211211
fclose($this->file);
212212

@@ -257,7 +257,7 @@ public function provideBinaryFormatTests()
257257
*/
258258
public function testBinaryFormat($bytesWritten, $limit, $binaryFormat, $sizeAsString, $limitAsString, $suffix)
259259
{
260-
fseek($this->file, $bytesWritten - 1, SEEK_SET);
260+
fseek($this->file, $bytesWritten - 1, \SEEK_SET);
261261
fwrite($this->file, '0');
262262
fclose($this->file);
263263

@@ -425,23 +425,23 @@ public function testUploadedFileError($error, $message, array $params = [], $max
425425
public function uploadedFileErrorProvider()
426426
{
427427
$tests = [
428-
[UPLOAD_ERR_FORM_SIZE, 'uploadFormSizeErrorMessage'],
429-
[UPLOAD_ERR_PARTIAL, 'uploadPartialErrorMessage'],
430-
[UPLOAD_ERR_NO_FILE, 'uploadNoFileErrorMessage'],
431-
[UPLOAD_ERR_NO_TMP_DIR, 'uploadNoTmpDirErrorMessage'],
432-
[UPLOAD_ERR_CANT_WRITE, 'uploadCantWriteErrorMessage'],
433-
[UPLOAD_ERR_EXTENSION, 'uploadExtensionErrorMessage'],
428+
[\UPLOAD_ERR_FORM_SIZE, 'uploadFormSizeErrorMessage'],
429+
[\UPLOAD_ERR_PARTIAL, 'uploadPartialErrorMessage'],
430+
[\UPLOAD_ERR_NO_FILE, 'uploadNoFileErrorMessage'],
431+
[\UPLOAD_ERR_NO_TMP_DIR, 'uploadNoTmpDirErrorMessage'],
432+
[\UPLOAD_ERR_CANT_WRITE, 'uploadCantWriteErrorMessage'],
433+
[\UPLOAD_ERR_EXTENSION, 'uploadExtensionErrorMessage'],
434434
];
435435

436436
if (class_exists('Symfony\Component\HttpFoundation\File\UploadedFile')) {
437437
// when no maxSize is specified on constraint, it should use the ini value
438-
$tests[] = [UPLOAD_ERR_INI_SIZE, 'uploadIniSizeErrorMessage', [
438+
$tests[] = [\UPLOAD_ERR_INI_SIZE, 'uploadIniSizeErrorMessage', [
439439
'{{ limit }}' => UploadedFile::getMaxFilesize() / 1048576,
440440
'{{ suffix }}' => 'MiB',
441441
]];
442442

443443
// it should use the smaller limitation (maxSize option in this case)
444-
$tests[] = [UPLOAD_ERR_INI_SIZE, 'uploadIniSizeErrorMessage', [
444+
$tests[] = [\UPLOAD_ERR_INI_SIZE, 'uploadIniSizeErrorMessage', [
445445
'{{ limit }}' => 1,
446446
'{{ suffix }}' => 'bytes',
447447
], '1'];
@@ -454,14 +454,14 @@ public function uploadedFileErrorProvider()
454454

455455
// it correctly parses the maxSize option and not only uses simple string comparison
456456
// 1000M should be bigger than the ini value
457-
$tests[] = [UPLOAD_ERR_INI_SIZE, 'uploadIniSizeErrorMessage', [
457+
$tests[] = [\UPLOAD_ERR_INI_SIZE, 'uploadIniSizeErrorMessage', [
458458
'{{ limit }}' => $limit,
459459
'{{ suffix }}' => $suffix,
460460
], '1000M'];
461461

462462
// it correctly parses the maxSize option and not only uses simple string comparison
463463
// 1000M should be bigger than the ini value
464-
$tests[] = [UPLOAD_ERR_INI_SIZE, 'uploadIniSizeErrorMessage', [
464+
$tests[] = [\UPLOAD_ERR_INI_SIZE, 'uploadIniSizeErrorMessage', [
465465
'{{ limit }}' => '0.1',
466466
'{{ suffix }}' => 'MB',
467467
], '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
@@ -64,7 +64,7 @@ public function validate($value, $constraints = null, $groups = null)
6464
{
6565
$violations = $this->validator->validate($value, $constraints, $groups);
6666

67-
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 7);
67+
$trace = debug_backtrace(\DEBUG_BACKTRACE_IGNORE_ARGS, 7);
6868

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

0 commit comments

Comments
 (0)