Skip to content

Conversation

mmoll
Copy link
Contributor

@mmoll mmoll commented Oct 19, 2018

No description provided.

@codecov
Copy link

codecov bot commented Oct 19, 2018

Codecov Report

Merging #103 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #103   +/-   ##
=========================================
  Coverage     98.47%   98.47%           
  Complexity      124      124           
=========================================
  Files             6        6           
  Lines           523      523           
=========================================
  Hits            515      515           
  Misses            8        8
Impacted Files Coverage Δ Complexity Δ
...iffs/Formatting/AlphabeticalUseStatementsSniff.php 100% <100%> (ø) 35 <0> (ø) ⬇️
MO4/Sniffs/Commenting/PropertyCommentSniff.php 91.57% <100%> (ø) 22 <0> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1467198...9d98803. Read the comment docs.

@@ -312,7 +312,7 @@ private function findNewDestination(
}

$prevLine = $tokens[$prevPtr]['line'];
$prevImportArr = $this->getUseImport($phpcsFile, (int) $prevPtr);
$prevImportArr = (array) $this->getUseImport($phpcsFile, (int) $prevPtr);
Copy link
Contributor

Choose a reason for hiding this comment

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

Which quality tool was picky about that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

PHP Inspections and there would still be a few other issues that got detected by it, but it would be IMHO too tedious to satisfy all the other tools we're using when "fixing" these.

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think that this is overly helpful here, false conversed with (array) becomes an empty array. In the while condition we refer to to the array key content which would raise an error in case false is returned, so this doesn't prevent a bug, it simply makes the inspection tools happy.

So, getUseImport only returns false if use is the last token in the file which would be syntactically incorrect. I'm currently not sure how PHPCS behaves in case of incorrect files, but I'd prefer to remove the conversion here (I'm also wondering why the if ($start === false) condition was introduced in getUseImport if this simply covers a syntactically incorrect case.

Choose a reason for hiding this comment

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

@mmoll, what was a warning related to the introduced array casting?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kalessil ohai :)
"'$prevImportArr' may not support offset operations (or its type not annotated properly: [bool, array])." on Line 317

Copy link

@kalessil kalessil Nov 2, 2018

Choose a reason for hiding this comment

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

@mmoll hi :) Checked, the issue is correct, but even adding if ($prevImportArr === false) { break; } will not help. The getUseImport refactoring would be needed, but might be declined by maintainers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kalessil We will leave this as-is for now, the two other changes went in with GH-104, but thanks for looking into it. 👍

@mmoll mmoll closed this Oct 19, 2018
@mmoll mmoll deleted the moar_inspections branch October 19, 2018 15:42
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.

4 participants