Skip to content

Commit f070c3a

Browse files
committed
minor #3798 DX: enable native_function_invocation (keradus)
This PR was squashed before being merged into the 2.12 branch (closes #3798). Discussion ---------- DX: enable native_function_invocation please vote Commits ------- 2f48a42 DX: enable native_function_invocation
2 parents c67d872 + 2f48a42 commit f070c3a

File tree

162 files changed

+433
-431
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

162 files changed

+433
-431
lines changed

.php_cs.dist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ $config = PhpCsFixer\Config::create()
4343
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
4444
'method_chaining_indentation' => true,
4545
'multiline_comment_opening_closing' => true,
46+
// TODO: remove at 2.13, as it's part of @Symfony ruleset since 2.13
47+
'native_function_invocation' => ['include' => ['@compiler_optimized'], 'scope' => 'namespaced'],
4648
'no_alternative_syntax' => true,
4749
'no_binary_string' => true,
4850
'no_extra_blank_lines' => ['tokens' => ['break', 'continue', 'extra', 'return', 'throw', 'use', 'parenthesis_brace_block', 'square_brace_block', 'curly_brace_block']],

src/AbstractAlignFixerHelper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function fix(Tokens $tokens)
4747
// To handle that unwanted behavior we work on clone of Tokens collection and then override original collection with fixed collection.
4848
$tokensClone = clone $tokens;
4949

50-
$this->injectAlignmentPlaceholders($tokensClone, 0, count($tokens));
50+
$this->injectAlignmentPlaceholders($tokensClone, 0, \count($tokens));
5151
$content = $this->replacePlaceholder($tokensClone);
5252

5353
$tokens->setCode($content);
@@ -96,7 +96,7 @@ protected function replacePlaceholder(Tokens $tokens)
9696
}
9797

9898
foreach ($linesWithPlaceholder as $group) {
99-
if (count($group) < 1) {
99+
if (\count($group) < 1) {
100100
continue;
101101
}
102102

src/AbstractDoctrineAnnotationFixer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ protected function createConfigurationDefinition()
7979
->setAllowedTypes(['array'])
8080
->setAllowedValues([static function ($values) {
8181
foreach ($values as $value) {
82-
if (!is_string($value)) {
82+
if (!\is_string($value)) {
8383
return false;
8484
}
8585
}

src/AbstractFixer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function isRisky()
9090
public function getName()
9191
{
9292
$nameParts = explode('\\', static::class);
93-
$name = substr(end($nameParts), 0, -strlen('Fixer'));
93+
$name = substr(end($nameParts), 0, -\strlen('Fixer'));
9494

9595
return Utils::camelCaseToUnderscore($name);
9696
}

src/AbstractProxyFixer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function isRisky()
7070
*/
7171
public function getPriority()
7272
{
73-
if (count($this->proxyFixers) > 1) {
73+
if (\count($this->proxyFixers) > 1) {
7474
throw new \LogicException('You need to override this method to provide the priority of combined fixers.');
7575
}
7676

src/Cache/Cache.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ public function get($file)
5555

5656
public function set($file, $hash)
5757
{
58-
if (!is_int($hash)) {
58+
if (!\is_int($hash)) {
5959
throw new \InvalidArgumentException(sprintf(
6060
'Value needs to be an integer, got "%s".',
61-
is_object($hash) ? get_class($hash) : gettype($hash)
61+
\is_object($hash) ? \get_class($hash) : \gettype($hash)
6262
));
6363
}
6464

@@ -103,7 +103,7 @@ public static function fromJson($json)
103103
if (null === $data && JSON_ERROR_NONE !== json_last_error()) {
104104
throw new \InvalidArgumentException(sprintf(
105105
'Value needs to be a valid JSON string, got "%s", error: "%s".',
106-
is_object($json) ? get_class($json) : gettype($json),
106+
\is_object($json) ? \get_class($json) : \gettype($json),
107107
json_last_error_msg()
108108
));
109109
}
@@ -117,7 +117,7 @@ public static function fromJson($json)
117117

118118
$missingKeys = array_diff_key(array_flip($requiredKeys), $data);
119119

120-
if (count($missingKeys)) {
120+
if (\count($missingKeys)) {
121121
throw new \InvalidArgumentException(sprintf(
122122
'JSON data is missing keys "%s"',
123123
implode('", "', $missingKeys)

src/Cache/Directory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function getRelativePathTo($file)
4343
return $file;
4444
}
4545

46-
return substr($file, strlen($this->directoryName) + 1);
46+
return substr($file, \strlen($this->directoryName) + 1);
4747
}
4848

4949
private function normalizePath($path)

src/Cache/Signature.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ public function equals(SignatureInterface $signature)
7070

7171
private static function utf8Encode(array $data)
7272
{
73-
if (!function_exists('mb_detect_encoding')) {
73+
if (!\function_exists('mb_detect_encoding')) {
7474
return $data;
7575
}
7676

7777
array_walk_recursive($data, static function (&$item) {
78-
if (is_string($item) && !mb_detect_encoding($item, 'utf-8', true)) {
78+
if (\is_string($item) && !mb_detect_encoding($item, 'utf-8', true)) {
7979
$item = utf8_encode($item);
8080
}
8181
});

src/Config.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,10 @@ public function getUsingCache()
152152
*/
153153
public function registerCustomFixers($fixers)
154154
{
155-
if (false === is_array($fixers) && false === $fixers instanceof \Traversable) {
155+
if (false === \is_array($fixers) && false === $fixers instanceof \Traversable) {
156156
throw new \InvalidArgumentException(sprintf(
157157
'Argument must be an array or a Traversable, got "%s".',
158-
is_object($fixers) ? get_class($fixers) : gettype($fixers)
158+
\is_object($fixers) ? \get_class($fixers) : \gettype($fixers)
159159
));
160160
}
161161

@@ -181,10 +181,10 @@ public function setCacheFile($cacheFile)
181181
*/
182182
public function setFinder($finder)
183183
{
184-
if (false === is_array($finder) && false === $finder instanceof \Traversable) {
184+
if (false === \is_array($finder) && false === $finder instanceof \Traversable) {
185185
throw new \InvalidArgumentException(sprintf(
186186
'Argument must be an array or a Traversable, got "%s".',
187-
is_object($finder) ? get_class($finder) : gettype($finder)
187+
\is_object($finder) ? \get_class($finder) : \gettype($finder)
188188
));
189189
}
190190

src/Console/Command/DescribeCommand.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ private function describeRule(OutputInterface $output, $name)
161161

162162
$output->writeln(sprintf('<info>Description of</info> %s <info>rule</info>.', $name));
163163
if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
164-
$output->writeln(sprintf('Fixer class: <comment>%s</comment>.', get_class($fixer)));
164+
$output->writeln(sprintf('Fixer class: <comment>%s</comment>.', \get_class($fixer)));
165165
}
166166

167167
$output->writeln($description);
@@ -184,7 +184,7 @@ private function describeRule(OutputInterface $output, $name)
184184
$configurationDefinition = $fixer->getConfigurationDefinition();
185185
$options = $configurationDefinition->getOptions();
186186

187-
$output->writeln(sprintf('Fixer is configurable using following option%s:', 1 === count($options) ? '' : 's'));
187+
$output->writeln(sprintf('Fixer is configurable using following option%s:', 1 === \count($options) ? '' : 's'));
188188

189189
foreach ($options as $option) {
190190
$line = '* <info>'.OutputFormatter::escape($option->getName()).'</info>';
@@ -259,7 +259,7 @@ function ($type) {
259259
return true;
260260
});
261261

262-
if (!count($codeSamples)) {
262+
if (!\count($codeSamples)) {
263263
$output->writeln([
264264
'Fixing examples can not be demonstrated on the current PHP version.',
265265
'',
@@ -313,7 +313,7 @@ function ($type) {
313313
*/
314314
private function describeSet(OutputInterface $output, $name)
315315
{
316-
if (!in_array($name, $this->getSetNames(), true)) {
316+
if (!\in_array($name, $this->getSetNames(), true)) {
317317
throw new DescribeNameNotFoundException($name, 'set');
318318
}
319319

@@ -400,7 +400,7 @@ private function describeList(OutputInterface $output, $type)
400400
foreach ($describe as $list => $items) {
401401
$output->writeln(sprintf('<comment>Defined %s:</comment>', $list));
402402
foreach ($items as $name => $item) {
403-
$output->writeln(sprintf('* <info>%s</info>', is_string($name) ? $name : $item));
403+
$output->writeln(sprintf('* <info>%s</info>', \is_string($name) ? $name : $item));
404404
}
405405
}
406406
}

src/Console/Command/FixCommand.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
199199
$stdErr,
200200
$this->eventDispatcher,
201201
'estimating' !== $progressType ? (new Terminal())->getWidth() : null,
202-
count($finder)
202+
\count($finder)
203203
);
204204
}
205205

@@ -245,15 +245,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
245245
if (null !== $stdErr) {
246246
$errorOutput = new ErrorOutput($stdErr);
247247

248-
if (count($invalidErrors) > 0) {
248+
if (\count($invalidErrors) > 0) {
249249
$errorOutput->listErrors('linting before fixing', $invalidErrors);
250250
}
251251

252-
if (count($exceptionErrors) > 0) {
252+
if (\count($exceptionErrors) > 0) {
253253
$errorOutput->listErrors('fixing', $exceptionErrors);
254254
}
255255

256-
if (count($lintErrors) > 0) {
256+
if (\count($lintErrors) > 0) {
257257
$errorOutput->listErrors('linting after fixing', $lintErrors);
258258
}
259259
}
@@ -262,9 +262,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
262262

263263
return $exitStatusCalculator->calculate(
264264
$resolver->isDryRun(),
265-
count($changed) > 0,
266-
count($invalidErrors) > 0,
267-
count($exceptionErrors) > 0
265+
\count($changed) > 0,
266+
\count($invalidErrors) > 0,
267+
\count($exceptionErrors) > 0
268268
);
269269
}
270270
}

src/Console/Command/HelpCommand.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ public static function getHelpCopy()
284284
),
285285
'%%%CI_INTEGRATION%%%' => implode("\n", array_map(
286286
static function ($line) { return ' $ '.$line; },
287-
array_slice(file(__DIR__.'/../../../dev-tools/ci-integration.sh', FILE_IGNORE_NEW_LINES), 3)
287+
\array_slice(file(__DIR__.'/../../../dev-tools/ci-integration.sh', FILE_IGNORE_NEW_LINES), 3)
288288
)),
289289
'%%%FIXERS_DETAILS%%%' => self::getFixersHelp(),
290290
]);
@@ -297,7 +297,7 @@ static function ($line) { return ' $ '.$line; },
297297
*/
298298
public static function toString($value)
299299
{
300-
if (is_array($value)) {
300+
if (\is_array($value)) {
301301
// Output modifications:
302302
// - remove new-lines
303303
// - combine multiple whitespaces
@@ -362,7 +362,7 @@ public static function getDisplayableAllowedValues(FixerOptionInterface $option)
362362
);
363363
});
364364

365-
if (0 === count($allowed)) {
365+
if (0 === \count($allowed)) {
366366
$allowed = null;
367367
}
368368
}
@@ -468,7 +468,7 @@ static function (FixerInterface $a, FixerInterface $b) {
468468
return $sets;
469469
};
470470

471-
$count = count($fixers) - 1;
471+
$count = \count($fixers) - 1;
472472
foreach ($fixers as $i => $fixer) {
473473
$sets = $getSetsWithRule($fixer->getName());
474474

@@ -511,7 +511,7 @@ static function (FixerInterface $a, FixerInterface $b) {
511511
if ($fixer instanceof ConfigurationDefinitionFixerInterface) {
512512
$configurationDefinition = $fixer->getConfigurationDefinition();
513513
$configurationDefinitionOptions = $configurationDefinition->getOptions();
514-
if (count($configurationDefinitionOptions)) {
514+
if (\count($configurationDefinitionOptions)) {
515515
$help .= " |\n | Configuration options:\n";
516516

517517
usort(
@@ -601,7 +601,7 @@ private static function wordwrap($string, $width)
601601
$currentLine = 0;
602602
$lineLength = 0;
603603
foreach (explode(' ', $string) as $word) {
604-
$wordLength = strlen(Preg::replace('~</?(\w+)>~', '', $word));
604+
$wordLength = \strlen(Preg::replace('~</?(\w+)>~', '', $word));
605605
if (0 !== $lineLength) {
606606
++$wordLength; // space before word
607607
}

src/Console/Command/SelfUpdateCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
149149
return 1;
150150
}
151151

152-
$tempFilename = dirname($localFilename).'/'.basename($localFilename, '.phar').'-tmp.phar';
152+
$tempFilename = \dirname($localFilename).'/'.basename($localFilename, '.phar').'-tmp.phar';
153153
$remoteFilename = $this->toolInfo->getPharDownloadUri($remoteTag);
154154

155155
if (false === @copy($remoteFilename, $tempFilename)) {

0 commit comments

Comments
 (0)