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

refactor: Fix phpstan booleanAnd.rightAlwaysTrue #9367

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

neznaika0
Copy link
Contributor

Description
is_file($target) not needed, as it will be overwritten anyway.
Question: Is it worth checking copy() and throwing an exception?

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@neznaika0 neznaika0 changed the title refactor: Fix phpstan always true refactor: Fix phpstan booleanAnd.rightAlwaysTrue Jan 3, 2025
@@ -96,7 +96,7 @@ function directory_mirror(string $originDir, string $targetDir, bool $overwrite
if (! is_dir($target)) {
mkdir($target, 0755);
}
} elseif (! is_file($target) || ($overwrite && is_file($target))) {
} elseif ($overwrite || ! is_file($target)) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
} elseif ($overwrite || ! is_file($target)) {
} elseif (! is_file($target) || $overwrite)) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the first check is true, then the next ones will not run. calling is_file() is not important, micro optimization

@paulbalandan paulbalandan added the refactor Pull requests that refactor code label Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Pull requests that refactor code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants