Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing "use function" declarations #1450

Merged
merged 2 commits into from Nov 29, 2020

Conversation

sanmai
Copy link
Member

@sanmai sanmai commented Nov 29, 2020

This PR:

  • Adds missing "use function" declarations around the code
  • Adds missing "use constant" declarations around the code
  • Changes CS Fixer rules to fix these issues automatically.

Copy link
Member

@theofidry theofidry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM otherwise

@@ -38,30 +38,30 @@ use Infection\Console\Application;
use Infection\Container;
use function Safe\getcwd;

if (in_array(PHP_SAPI, ['cli', 'phpdbg', 'embed'], true) === false) {
echo PHP_EOL . 'Infection may only be invoked from a command line, got "' . PHP_SAPI . '"' . PHP_EOL;
if (\in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true) === false) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of those could be use statements instead as well

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CS Fixer plainly refuses to make them so.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I confirm - when I use import here and run make cs, it removes import and adds \

1)) /home/maksrafalko/apps/infection/bin/infection (native_function_invocation, no_unused_imports)

On the other side, it works correctly for for example SourceDirGuesser.php - when I remove import there, fixer adds it back and doesn't add \:

1) /home/maksrafalko/apps/infection/src/Config/Guesser/SourceDirGuesser.php (native_function_invocation, global_namespace_import, ordered_imports)

it looks like a bug in PHP-CS-Fixer

@@ -36,11 +36,11 @@ declare(strict_types=1);
use PhpCsFixer\Config;
use PhpCsFixer\Finder;

$header = trim(sprintf(
$header = \trim(\sprintf(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

set_error_handler(static function ($errno, $errstr): void {
var_dump($errno, $errstr);
}, E_ALL);
\set_error_handler(static function ($errno, $errstr): void {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@@ -33,13 +33,13 @@

declare(strict_types=1);

if (!function_exists('xdebug_set_filter')) {
if (!\function_exists('xdebug_set_filter')) {
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like that's the cost of having this ruleset work in other places. It just won't make them imported here and there.

@@ -38,30 +38,30 @@ use Infection\Console\Application;
use Infection\Container;
use function Safe\getcwd;

if (in_array(PHP_SAPI, ['cli', 'phpdbg', 'embed'], true) === false) {
echo PHP_EOL . 'Infection may only be invoked from a command line, got "' . PHP_SAPI . '"' . PHP_EOL;
if (\in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true) === false) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I confirm - when I use import here and run make cs, it removes import and adds \

1)) /home/maksrafalko/apps/infection/bin/infection (native_function_invocation, no_unused_imports)

On the other side, it works correctly for for example SourceDirGuesser.php - when I remove import there, fixer adds it back and doesn't add \:

1) /home/maksrafalko/apps/infection/src/Config/Guesser/SourceDirGuesser.php (native_function_invocation, global_namespace_import, ordered_imports)

it looks like a bug in PHP-CS-Fixer

@maks-rafalko
Copy link
Member

TravisCI is still broken. It shows we have 0 credits of 0 for the current month :| Still didn't get a reply from them, so I temporarily disabled TravisCI from protected branches so you can merge.

@sanmai
Copy link
Member Author

sanmai commented Nov 29, 2020

I think it's a bout time to un-require Travis CI for protected branches.

@sanmai
Copy link
Member Author

sanmai commented Nov 29, 2020

@maks-rafalko thank you!

@sanmai sanmai merged commit 1368b12 into infection:master Nov 29, 2020
@sanmai sanmai deleted the pr/2020-11/use-function branch November 29, 2020 09:55
@sanmai
Copy link
Member Author

sanmai commented Nov 29, 2020

It seems like this is the end of Travis CI we knew and loved.

@sidz
Copy link
Member

sidz commented Nov 29, 2020

RIP Travis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants