Skip to content

Commit

Permalink
Change default confic of native_function_invocation
Browse files Browse the repository at this point in the history
  • Loading branch information
dunglas committed Sep 18, 2018
1 parent 7136aa4 commit 0172b2b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 36 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ Choose from the list of available rules:
- ``include`` (``array``): list of function names or sets to fix. Defined sets are
``@internal`` (all native functions), ``@all`` (all global functions) and
``@compiler_optimized`` (functions that are specially optimized by Zend);
defaults to ``['@internal']``
defaults to ``['@compiler_optimized']``
- ``scope`` (``'all'``, ``'namespaced'``): only fix function calls that are made
within a namespace or fix all; defaults to ``'all'``

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ protected function createConfigurationDefinition()

return true;
}])
->setDefault([self::SET_INTERNAL])
->setDefault([self::SET_COMPILER_OPTIMIZED])
->getOption(),
(new FixerOptionBuilder('scope', 'Only fix function calls that are made within a namespace or fix all.'))
->setAllowedValues(['all', 'namespaced'])
Expand Down
68 changes: 34 additions & 34 deletions tests/Fixer/FunctionNotation/NativeFunctionInvocationFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function provideInvalidConfigurationElementCases()
'array' => [[]],
'float' => [0.1],
'object' => [new \stdClass()],
'not-trimmed' => [' json_encode '],
'not-trimmed' => [' is_string '],
];
}

Expand Down Expand Up @@ -124,7 +124,7 @@ public function testConfigureResetsExclude()
{
$this->fixer->configure([
'exclude' => [
'json_encode',
'is_string',
],
]);

Expand All @@ -138,7 +138,7 @@ class Bar
public function baz($foo)
{
if (isset($foo)) {
json_encode($foo);
is_string($foo);
}
}
}
Expand All @@ -154,7 +154,7 @@ class Bar
public function baz($foo)
{
if (isset($foo)) {
\json_encode($foo);
\is_string($foo);
}
}
}
Expand Down Expand Up @@ -194,17 +194,17 @@ public function provideFixWithDefaultConfigurationCases()
[
'<?php
\json_encode($foo);
\is_string($foo);
',
],
[
'<?php
\json_encode($foo);
\is_string($foo);
',
'<?php
json_encode($foo);
is_string($foo);
',
],
[
Expand All @@ -214,7 +214,7 @@ class Foo
{
public function bar($foo)
{
return \json_encode($foo);
return \is_string($foo);
}
}
',
Expand All @@ -226,7 +226,7 @@ class Foo
{
public function bar($foo)
{
return \JSON_ENCODE($foo);
return \IS_STRING($foo);
}
}
',
Expand All @@ -236,7 +236,7 @@ class Foo
{
public function bar($foo)
{
return JSON_ENCODE($foo);
return IS_STRING($foo);
}
}
',
Expand Down Expand Up @@ -272,7 +272,7 @@ public function testFixWithConfiguredExclude($expected, $input = null)
{
$this->fixer->configure([
'exclude' => [
'json_encode',
'is_string',
],
]);

Expand All @@ -288,7 +288,7 @@ public function provideFixWithConfiguredExcludeCases()
[
'<?php
json_encode($foo);
is_string($foo);
',
],
[
Expand All @@ -298,7 +298,7 @@ class Foo
{
public function bar($foo)
{
return json_encode($foo);
return is_string($foo);
}
}
',
Expand Down Expand Up @@ -340,44 +340,44 @@ public function provideFixWithNamespaceConfigurationCases()
[
'<?php
namespace Bar {
echo \strtoLOWER("in 1");
echo \strLEN("in 1");
}
namespace {
echo strtolower("out 1");
echo strlen("out 1");
}
namespace {
echo strtolower("out 2");
echo strlen("out 2");
}
namespace Bar{
echo \strtolower("in 2");
echo \strlen("in 2");
}
namespace {
echo strtolower("out 3");
echo strlen("out 3");
}
',
'<?php
namespace Bar {
echo strtoLOWER("in 1");
echo strLEN("in 1");
}
namespace {
echo strtolower("out 1");
echo strlen("out 1");
}
namespace {
echo strtolower("out 2");
echo strlen("out 2");
}
namespace Bar{
echo strtolower("in 2");
echo strlen("in 2");
}
namespace {
echo strtolower("out 3");
echo strlen("out 3");
}
',
],
Expand All @@ -386,17 +386,17 @@ public function provideFixWithNamespaceConfigurationCases()
namespace space11 ?>
<?php
echo \strtolower(__NAMESPACE__);
echo \strlen(__NAMESPACE__);
namespace space2;
echo \strtolower(__NAMESPACE__);
echo \strlen(__NAMESPACE__);
',
'<?php
namespace space11 ?>
<?php
echo strtolower(__NAMESPACE__);
echo strlen(__NAMESPACE__);
namespace space2;
echo strtolower(__NAMESPACE__);
echo strlen(__NAMESPACE__);
',
],
[
Expand Down Expand Up @@ -426,33 +426,33 @@ public function provideFixWithNamespaceConfigurationCases()
',
],
[
'<?php namespace {echo strtolower("out 2");}',
'<?php namespace {echo strlen("out 2");}',
],
[
'<?php
namespace space13 {
echo \strtolower("in 1");
echo \strlen("in 1");
}
namespace space2 {
echo \strtolower("in 2");
echo \strlen("in 2");
}
namespace { // global
echo strtolower("global 1");
echo strlen("global 1");
}
',
'<?php
namespace space13 {
echo strtolower("in 1");
echo strlen("in 1");
}
namespace space2 {
echo strtolower("in 2");
echo strlen("in 2");
}
namespace { // global
echo strtolower("global 1");
echo strlen("global 1");
}
',
],
Expand Down

0 comments on commit 0172b2b

Please sign in to comment.