Skip to content

Commit

Permalink
misc
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed Sep 6, 2024
1 parent 37bca44 commit 32425e8
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/Command/PrivatizeConstantsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Rector\SwissKnife\PhpParser\ClassConstantFetchFinder;
use Rector\SwissKnife\PhpParser\NodeTraverserFactory;
use Rector\SwissKnife\PhpParser\NodeVisitor\FindNonPrivateClassConstNodeVisitor;
use Rector\SwissKnife\ValueObject\ClassConstant;
use Rector\SwissKnife\ValueObject\ClassConstantFetch\CurrentClassConstantFetch;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
Expand Down Expand Up @@ -117,7 +118,9 @@ private function processFileInfo(SplFileInfo $phpFileInfo, array $classConstantF

FileSystem::write($phpFileInfo->getRealPath(), $changedFileContents);

$this->symfonyStyle->note(sprintf('Constant %s changed to public', $classConstant->getConstantName()));
$this->symfonyStyle->note(
sprintf('Constant "%s" changed to public', $classConstant->getConstantName())
);
continue;
}

Expand All @@ -129,19 +132,21 @@ private function processFileInfo(SplFileInfo $phpFileInfo, array $classConstantF
);
FileSystem::write($phpFileInfo->getRealPath(), $changedFileContents);

$this->symfonyStyle->note(sprintf('Constant %s changed to private', $classConstant->getConstantName()));
$this->symfonyStyle->note(sprintf('Constant "%s" changed to private', $classConstant->getConstantName()));
}
}

private function isClassConstantUsedPublicly(
array $classConstantFetches,
\Rector\SwissKnife\ValueObject\ClassConstant $classConstant
): bool {
/**
* @param ClassConstantFetchInterface[] $classConstantFetches
*/
private function isClassConstantUsedPublicly(array $classConstantFetches, ClassConstant $classConstant): bool
{
foreach ($classConstantFetches as $classConstantFetch) {
if (! $classConstantFetch->isClassConstantMatch($classConstant)) {
continue;
}

// used only locally, can stay private
if ($classConstantFetch instanceof CurrentClassConstantFetch) {
continue;
}
Expand Down

0 comments on commit 32425e8

Please sign in to comment.