Skip to content
Permalink
Browse files

Don’t be greedy with lines

  • Loading branch information...
muglug committed Apr 17, 2019
1 parent f51b073 commit b1044b267d9c2413a50165c7f9aa93c2ecf98200
@@ -369,7 +369,7 @@ function () {
$codebase = $project_analyzer->getCodebase();
if ($codebase->collect_references
if ($codebase->find_unused_code
&& ($project_analyzer->full_run || $codebase->find_unused_code === 'always')
) {
$project_analyzer->checkClassReferences();
@@ -41,21 +41,11 @@ public static function addForCodeLocation(
$file_contents = $codebase->getFileContents($code_location->file_path);
$removed_lines = false;
if (($file_contents[$bounds[0] - 1] ?? null) === PHP_EOL
&& ($file_contents[$bounds[0] - 2] ?? null) === PHP_EOL
) {
$removed_lines = true;
$bounds[0] -= 2;
}
if (!$removed_lines
&& ($file_contents[$bounds[1]] ?? null) === PHP_EOL
&& ($file_contents[$bounds[1] + 1] ?? null) === PHP_EOL
) {
$bounds[1] += 2;
}
}
self::add(
@@ -1605,6 +1605,27 @@ public function bat() : void {}
['PossiblyUnusedMethod'],
true,
],
'removeAllPossiblyUnusedMethods' => [
'<?php
class A {
public function foo() : void {}
public function bar() : void {}
public function bat() : void {}
}
new A();',
'<?php
class A {
}
new A();',
'7.1',
['PossiblyUnusedMethod'],
true,
],
'dontRemovePossiblyUnusedMethodWithMixedUse' => [
'<?php
class A {
@@ -1679,6 +1700,8 @@ public function bar() : void {}
(new A)->bar();',
'<?php
class A {
public function bar() : void {}
}

0 comments on commit b1044b2

Please sign in to comment.
You can’t perform that action at this time.