Skip to content

Commit 5ab63ce

Browse files
Merge branch '4.4' into 5.1
* 4.4: Enable "native_constant_invocation" CS rule Make AbstractPhpFileCacheWarmer public
2 parents 236d88a + 82e315e commit 5ab63ce

16 files changed

+64
-64
lines changed

Command/DebugCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ private function findAlternatives(string $name, array $collection): array
237237

238238
$threshold = 1e3;
239239
$alternatives = array_filter($alternatives, function ($lev) use ($threshold) { return $lev < 2 * $threshold; });
240-
ksort($alternatives, SORT_NATURAL | SORT_FLAG_CASE);
240+
ksort($alternatives, \SORT_NATURAL | \SORT_FLAG_CASE);
241241

242242
return array_keys($alternatives);
243243
}

Console/Descriptor/JsonDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ private function writeData(array $data, array $options)
9797
{
9898
$flags = isset($options['json_encoding']) ? $options['json_encoding'] : 0;
9999

100-
$this->output->write(json_encode($data, $flags | JSON_PRETTY_PRINT)."\n");
100+
$this->output->write(json_encode($data, $flags | \JSON_PRETTY_PRINT)."\n");
101101
}
102102

103103
private function sortOptions(array &$options)

Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public function reverseTransform($value)
165165
throw new TransformationFailedException($formatter->getErrorMessage());
166166
}
167167

168-
if ($result >= PHP_INT_MAX || $result <= -PHP_INT_MAX) {
168+
if ($result >= \PHP_INT_MAX || $result <= -\PHP_INT_MAX) {
169169
throw new TransformationFailedException('I don\'t have a clear idea what infinity looks like.');
170170
}
171171

@@ -255,13 +255,13 @@ private function round($number)
255255
$number = $number > 0 ? floor($number) : ceil($number);
256256
break;
257257
case \NumberFormatter::ROUND_HALFEVEN:
258-
$number = round($number, 0, PHP_ROUND_HALF_EVEN);
258+
$number = round($number, 0, \PHP_ROUND_HALF_EVEN);
259259
break;
260260
case \NumberFormatter::ROUND_HALFUP:
261-
$number = round($number, 0, PHP_ROUND_HALF_UP);
261+
$number = round($number, 0, \PHP_ROUND_HALF_UP);
262262
break;
263263
case \NumberFormatter::ROUND_HALFDOWN:
264-
$number = round($number, 0, PHP_ROUND_HALF_DOWN);
264+
$number = round($number, 0, \PHP_ROUND_HALF_DOWN);
265265
break;
266266
}
267267

Extension/Core/DataTransformer/PercentToLocalizedStringTransformer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,13 +227,13 @@ private function round($number)
227227
$number = $number > 0 ? floor($number) : ceil($number);
228228
break;
229229
case \NumberFormatter::ROUND_HALFEVEN:
230-
$number = round($number, 0, PHP_ROUND_HALF_EVEN);
230+
$number = round($number, 0, \PHP_ROUND_HALF_EVEN);
231231
break;
232232
case \NumberFormatter::ROUND_HALFUP:
233-
$number = round($number, 0, PHP_ROUND_HALF_UP);
233+
$number = round($number, 0, \PHP_ROUND_HALF_UP);
234234
break;
235235
case \NumberFormatter::ROUND_HALFDOWN:
236-
$number = round($number, 0, PHP_ROUND_HALF_DOWN);
236+
$number = round($number, 0, \PHP_ROUND_HALF_DOWN);
237237
break;
238238
}
239239

Extension/Core/Type/FileType.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,14 @@ private function getFileUploadError(int $errorCode)
145145
{
146146
$messageParameters = [];
147147

148-
if (UPLOAD_ERR_INI_SIZE === $errorCode) {
148+
if (\UPLOAD_ERR_INI_SIZE === $errorCode) {
149149
list($limitAsString, $suffix) = $this->factorizeSizes(0, self::getMaxFilesize());
150150
$messageTemplate = 'The file is too large. Allowed maximum size is {{ limit }} {{ suffix }}.';
151151
$messageParameters = [
152152
'{{ limit }}' => $limitAsString,
153153
'{{ suffix }}' => $suffix,
154154
];
155-
} elseif (UPLOAD_ERR_FORM_SIZE === $errorCode) {
155+
} elseif (\UPLOAD_ERR_FORM_SIZE === $errorCode) {
156156
$messageTemplate = 'The file is too large.';
157157
} else {
158158
$messageTemplate = 'The file could not be uploaded.';
@@ -177,7 +177,7 @@ private static function getMaxFilesize(): int
177177
$iniMax = strtolower(ini_get('upload_max_filesize'));
178178

179179
if ('' === $iniMax) {
180-
return PHP_INT_MAX;
180+
return \PHP_INT_MAX;
181181
}
182182

183183
$max = ltrim($iniMax, '+');

Extension/Core/Type/TimeType.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
126126
$hours = $minutes = [];
127127

128128
foreach ($options['hours'] as $hour) {
129-
$hours[str_pad($hour, 2, '0', STR_PAD_LEFT)] = $hour;
129+
$hours[str_pad($hour, 2, '0', \STR_PAD_LEFT)] = $hour;
130130
}
131131

132132
// Only pass a subset of the options to children
@@ -136,7 +136,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
136136

137137
if ($options['with_minutes']) {
138138
foreach ($options['minutes'] as $minute) {
139-
$minutes[str_pad($minute, 2, '0', STR_PAD_LEFT)] = $minute;
139+
$minutes[str_pad($minute, 2, '0', \STR_PAD_LEFT)] = $minute;
140140
}
141141

142142
$minuteOptions['choices'] = $minutes;
@@ -148,7 +148,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
148148
$seconds = [];
149149

150150
foreach ($options['seconds'] as $second) {
151-
$seconds[str_pad($second, 2, '0', STR_PAD_LEFT)] = $second;
151+
$seconds[str_pad($second, 2, '0', \STR_PAD_LEFT)] = $second;
152152
}
153153

154154
$secondOptions['choices'] = $seconds;

FormRenderer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,9 @@ public function humanize(string $text)
291291
public function encodeCurrency(Environment $environment, string $text, string $widget = ''): string
292292
{
293293
if ('UTF-8' === $charset = $environment->getCharset()) {
294-
$text = htmlspecialchars($text, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
294+
$text = htmlspecialchars($text, \ENT_QUOTES | \ENT_SUBSTITUTE, 'UTF-8');
295295
} else {
296-
$text = htmlentities($text, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
296+
$text = htmlentities($text, \ENT_QUOTES | \ENT_SUBSTITUTE, 'UTF-8');
297297
$text = iconv('UTF-8', $charset, $text);
298298
$widget = iconv('UTF-8', $charset, $widget);
299299
}

NativeRequestHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public function getUploadFileError($data)
152152
return null;
153153
}
154154

155-
if (UPLOAD_ERR_OK === $data['error']) {
155+
if (\UPLOAD_ERR_OK === $data['error']) {
156156
return null;
157157
}
158158

@@ -238,7 +238,7 @@ private static function stripEmptyFiles($data)
238238
sort($keys);
239239

240240
if (self::$fileKeys === $keys) {
241-
if (UPLOAD_ERR_NO_FILE === $data['error']) {
241+
if (\UPLOAD_ERR_NO_FILE === $data['error']) {
242242
return null;
243243
}
244244

Tests/AbstractRequestHandlerTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -371,14 +371,14 @@ public function testFailedFileUploadIsTurnedIntoFormError($errorCode, $expectedE
371371
public function uploadFileErrorCodes()
372372
{
373373
return [
374-
'no error' => [UPLOAD_ERR_OK, null],
375-
'upload_max_filesize ini directive' => [UPLOAD_ERR_INI_SIZE, UPLOAD_ERR_INI_SIZE],
376-
'MAX_FILE_SIZE from form' => [UPLOAD_ERR_FORM_SIZE, UPLOAD_ERR_FORM_SIZE],
377-
'partially uploaded' => [UPLOAD_ERR_PARTIAL, UPLOAD_ERR_PARTIAL],
378-
'no file upload' => [UPLOAD_ERR_NO_FILE, UPLOAD_ERR_NO_FILE],
379-
'missing temporary directory' => [UPLOAD_ERR_NO_TMP_DIR, UPLOAD_ERR_NO_TMP_DIR],
380-
'write failure' => [UPLOAD_ERR_CANT_WRITE, UPLOAD_ERR_CANT_WRITE],
381-
'stopped by extension' => [UPLOAD_ERR_EXTENSION, UPLOAD_ERR_EXTENSION],
374+
'no error' => [\UPLOAD_ERR_OK, null],
375+
'upload_max_filesize ini directive' => [\UPLOAD_ERR_INI_SIZE, \UPLOAD_ERR_INI_SIZE],
376+
'MAX_FILE_SIZE from form' => [\UPLOAD_ERR_FORM_SIZE, \UPLOAD_ERR_FORM_SIZE],
377+
'partially uploaded' => [\UPLOAD_ERR_PARTIAL, \UPLOAD_ERR_PARTIAL],
378+
'no file upload' => [\UPLOAD_ERR_NO_FILE, \UPLOAD_ERR_NO_FILE],
379+
'missing temporary directory' => [\UPLOAD_ERR_NO_TMP_DIR, \UPLOAD_ERR_NO_TMP_DIR],
380+
'write failure' => [\UPLOAD_ERR_CANT_WRITE, \UPLOAD_ERR_CANT_WRITE],
381+
'stopped by extension' => [\UPLOAD_ERR_EXTENSION, \UPLOAD_ERR_EXTENSION],
382382
];
383383
}
384384

Tests/CompoundFormTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ public function testSubmitPostOrPutRequest($method)
623623

624624
$files = [
625625
'author' => [
626-
'error' => ['image' => UPLOAD_ERR_OK],
626+
'error' => ['image' => \UPLOAD_ERR_OK],
627627
'name' => ['image' => 'upload.png'],
628628
'size' => ['image' => null],
629629
'tmp_name' => ['image' => $path],
@@ -646,7 +646,7 @@ public function testSubmitPostOrPutRequest($method)
646646

647647
$form->handleRequest($request);
648648

649-
$file = new UploadedFile($path, 'upload.png', 'image/png', UPLOAD_ERR_OK);
649+
$file = new UploadedFile($path, 'upload.png', 'image/png', \UPLOAD_ERR_OK);
650650

651651
$this->assertEquals('Bernhard', $form['name']->getData());
652652
$this->assertEquals($file, $form['image']->getData());
@@ -670,7 +670,7 @@ public function testSubmitPostOrPutRequestWithEmptyRootFormName($method)
670670

671671
$files = [
672672
'image' => [
673-
'error' => UPLOAD_ERR_OK,
673+
'error' => \UPLOAD_ERR_OK,
674674
'name' => 'upload.png',
675675
'size' => null,
676676
'tmp_name' => $path,
@@ -693,7 +693,7 @@ public function testSubmitPostOrPutRequestWithEmptyRootFormName($method)
693693

694694
$form->handleRequest($request);
695695

696-
$file = new UploadedFile($path, 'upload.png', 'image/png', UPLOAD_ERR_OK);
696+
$file = new UploadedFile($path, 'upload.png', 'image/png', \UPLOAD_ERR_OK);
697697

698698
$this->assertEquals('Bernhard', $form['name']->getData());
699699
$this->assertEquals($file, $form['image']->getData());
@@ -713,7 +713,7 @@ public function testSubmitPostOrPutRequestWithSingleChildForm($method)
713713

714714
$files = [
715715
'image' => [
716-
'error' => UPLOAD_ERR_OK,
716+
'error' => \UPLOAD_ERR_OK,
717717
'name' => 'upload.png',
718718
'size' => null,
719719
'tmp_name' => $path,
@@ -732,7 +732,7 @@ public function testSubmitPostOrPutRequestWithSingleChildForm($method)
732732

733733
$form->handleRequest($request);
734734

735-
$file = new UploadedFile($path, 'upload.png', 'image/png', UPLOAD_ERR_OK);
735+
$file = new UploadedFile($path, 'upload.png', 'image/png', \UPLOAD_ERR_OK);
736736

737737
$this->assertEquals($file, $form->getData());
738738

@@ -1117,7 +1117,7 @@ public function testFileUpload()
11171117

11181118
$this->form->submit([
11191119
'foo' => 'Foo',
1120-
'bar' => new UploadedFile(__FILE__, 'upload.png', 'image/png', UPLOAD_ERR_OK),
1120+
'bar' => new UploadedFile(__FILE__, 'upload.png', 'image/png', \UPLOAD_ERR_OK),
11211121
]);
11221122

11231123
$this->assertSame('Submitted data was expected to be text or number, file upload given.', $this->form->get('bar')->getTransformationFailure()->getMessage());

0 commit comments

Comments
 (0)