diff --git a/src/analyzer/Cli/AnalyzeCommand.php b/src/analyzer/Cli/AnalyzeCommand.php
index 154af84..41a647a 100644
--- a/src/analyzer/Cli/AnalyzeCommand.php
+++ b/src/analyzer/Cli/AnalyzeCommand.php
@@ -74,7 +74,7 @@ private function doExecute(): void
/** @var string $configFile */
$configFile = $this->input->getOption('config') ?? getcwd().DIRECTORY_SEPARATOR.'tombstone.yml';
if (!file_exists($configFile)) {
- throw new \InvalidArgumentException(sprintf('Could not find configuration file %s', $configFile));
+ throw new \InvalidArgumentException(\sprintf('Could not find configuration file %s', $configFile));
}
$this->output->debug('Load config from '.$configFile);
@@ -117,7 +117,7 @@ private function createLogCollector(array $config, VampireIndex $vampireIndex):
$reflectionClass = new \ReflectionClass($config['logs']['custom']['class']);
if (!$reflectionClass->implementsInterface(LogProviderInterface::class)) {
- throw new \Exception(sprintf('Class %s must implement %s', $config['logs']['custom']['class'], LogProviderInterface::class));
+ throw new \Exception(\sprintf('Class %s must implement %s', $config['logs']['custom']['class'], LogProviderInterface::class));
}
/** @var LogProviderInterface $logReader */
diff --git a/src/analyzer/Cli/ConsoleOutput.php b/src/analyzer/Cli/ConsoleOutput.php
index cc45886..892ef99 100644
--- a/src/analyzer/Cli/ConsoleOutput.php
+++ b/src/analyzer/Cli/ConsoleOutput.php
@@ -42,9 +42,9 @@ public function createProgressBar(int $width): ProgressBar
public function error(string $message, ?\Throwable $exception = null): void
{
- $this->output->writeln(sprintf('%s', $message));
+ $this->output->writeln(\sprintf('%s', $message));
if (null !== $exception && $this->output->isDebug()) {
- $this->output->writeln(sprintf(
+ $this->output->writeln(\sprintf(
'%s: %s at %s line %s',
\get_class($exception),
$exception->getMessage(),
diff --git a/src/analyzer/Log/AnalyzerLogFileReader.php b/src/analyzer/Log/AnalyzerLogFileReader.php
index 1798a9f..a113b7a 100644
--- a/src/analyzer/Log/AnalyzerLogFileReader.php
+++ b/src/analyzer/Log/AnalyzerLogFileReader.php
@@ -35,7 +35,7 @@ public function readLogFile(string $file): \Traversable
{
$handle = @fopen($file, 'r');
if (false === $handle) {
- throw new AnalyzerLogProviderException(sprintf('Could not read log file %s', $file));
+ throw new AnalyzerLogProviderException(\sprintf('Could not read log file %s', $file));
}
$lineNumber = 0;
@@ -44,7 +44,7 @@ public function readLogFile(string $file): \Traversable
try {
yield AnalyzerLogFormat::logToVampire($line, $this->rootDir);
} catch (AnalyzerLogFormatException $e) {
- $this->output->error(sprintf('Ignoring invalid log data in "%s" on line %s', $file, $lineNumber), $e);
+ $this->output->error(\sprintf('Ignoring invalid log data in "%s" on line %s', $file, $lineNumber), $e);
}
}
fclose($handle);
diff --git a/src/analyzer/Report/Checkstyle/CheckstyleReportGenerator.php b/src/analyzer/Report/Checkstyle/CheckstyleReportGenerator.php
index 37ad3c7..29c97f7 100644
--- a/src/analyzer/Report/Checkstyle/CheckstyleReportGenerator.php
+++ b/src/analyzer/Report/Checkstyle/CheckstyleReportGenerator.php
@@ -67,7 +67,7 @@ private function createError(\DOMDocument $dom, Tombstone $tombstone): \DOMEleme
private function getMessage(Tombstone $tombstone): string
{
- return sprintf('Tombstone "%s" was called', (string) $tombstone).$this->getCalledBy($tombstone);
+ return \sprintf('Tombstone "%s" was called', (string) $tombstone).$this->getCalledBy($tombstone);
}
/**
@@ -82,7 +82,7 @@ private function getCalledBy(Tombstone $tombstone): string
}
$invoker = array_shift($vampires)->getInvoker();
- $calledBy = sprintf(' by "%s"', null !== $invoker ? $invoker : 'global scope');
+ $calledBy = \sprintf(' by "%s"', null !== $invoker ? $invoker : 'global scope');
$numAdditionalVampires = $numVampires - 1;
if ($numAdditionalVampires > 0) {
diff --git a/src/analyzer/Report/Console/ConsoleReportGenerator.php b/src/analyzer/Report/Console/ConsoleReportGenerator.php
index 796603a..89c7a5b 100644
--- a/src/analyzer/Report/Console/ConsoleReportGenerator.php
+++ b/src/analyzer/Report/Console/ConsoleReportGenerator.php
@@ -46,8 +46,8 @@ public function generate(AnalyzerResult $result): void
$numDeleted = $result->getDeletedCount();
$this->newLine();
- $this->output->writeln(sprintf('Vampires/Tombstones: %d/%d', $numUndead, $numUndead + $numDead));
- $this->output->writeln(sprintf('Deleted tombstones: %d', $numDeleted));
+ $this->output->writeln(\sprintf('Vampires/Tombstones: %d/%d', $numUndead, $numUndead + $numDead));
+ $this->output->writeln(\sprintf('Deleted tombstones: %d', $numDeleted));
foreach ($result->getFileResults() as $fileResult) {
$this->newLine();
@@ -81,7 +81,7 @@ private function displayVampires(array $result): void
private function printCalledBy(array $invokers): void
{
foreach ($invokers as $invoker) {
- $this->output->writeln(sprintf(' was called by %s', $invoker ?: 'global scope'));
+ $this->output->writeln(\sprintf(' was called by %s', $invoker ?: 'global scope'));
}
}
@@ -97,9 +97,9 @@ private function displayTombstones(array $result): void
if (null !== $date) {
$age = TimePeriodFormatter::formatAge($date);
if (null !== $age) {
- $this->output->writeln(sprintf(' was not called for %s', $age));
+ $this->output->writeln(\sprintf(' was not called for %s', $age));
} else {
- $this->output->writeln(sprintf(' was not called since %s', $date));
+ $this->output->writeln(\sprintf(' was not called since %s', $date));
}
}
}
@@ -107,11 +107,11 @@ private function displayTombstones(array $result): void
private function printTombstone(Tombstone $tombstone, string $prefix): void
{
- $this->output->writeln(sprintf(' [%s] %s', $prefix, (string) $tombstone));
- $this->output->writeln(sprintf(' in line %s', $tombstone->getLine()));
+ $this->output->writeln(\sprintf(' [%s] %s', $prefix, (string) $tombstone));
+ $this->output->writeln(\sprintf(' in line %s', $tombstone->getLine()));
$method = $tombstone->getMethod();
if (null !== $method) {
- $this->output->writeln(sprintf(' in method %s', $method));
+ $this->output->writeln(\sprintf(' in method %s', $method));
} else {
$this->output->writeln(' in global scope');
}
diff --git a/src/analyzer/Report/FileSystem.php b/src/analyzer/Report/FileSystem.php
index 7abe1ef..459aa76 100644
--- a/src/analyzer/Report/FileSystem.php
+++ b/src/analyzer/Report/FileSystem.php
@@ -13,7 +13,7 @@ public static function copyDirectoryFiles(string $templateDir, string $reportDir
self::ensureDirectoryCreated($reportDir);
$handle = @opendir($templateDir);
if (!$handle) {
- throw new FileSystemException(sprintf('Could not read template files from %s', $templateDir));
+ throw new FileSystemException(\sprintf('Could not read template files from %s', $templateDir));
}
while ($file = readdir($handle)) {
@@ -30,7 +30,7 @@ public static function copyDirectoryFiles(string $templateDir, string $reportDir
}
if (!@copy($templateFile, $reportFile)) {
- throw new FileSystemException(sprintf('Could not copy %s to %s', $templateFile, $reportFile));
+ throw new FileSystemException(\sprintf('Could not copy %s to %s', $templateFile, $reportFile));
}
}
closedir($handle);
@@ -40,10 +40,10 @@ public static function ensureDirectoryCreated(string $dir): void
{
if (!is_dir($dir)) {
if (!@mkdir($dir, 0777, true)) {
- throw new FileSystemException(sprintf('Could not create directory %s', $dir));
+ throw new FileSystemException(\sprintf('Could not create directory %s', $dir));
}
} elseif (!is_writable($dir)) {
- throw new FileSystemException(sprintf('Directory %s has to be writable', $dir));
+ throw new FileSystemException(\sprintf('Directory %s has to be writable', $dir));
}
}
diff --git a/src/analyzer/Report/Html/Renderer/DashboardRenderer.php b/src/analyzer/Report/Html/Renderer/DashboardRenderer.php
index e47f8c7..c63eed4 100644
--- a/src/analyzer/Report/Html/Renderer/DashboardRenderer.php
+++ b/src/analyzer/Report/Html/Renderer/DashboardRenderer.php
@@ -231,7 +231,7 @@ private function getTombstoneScope(Tombstone $tombstone): string
{
$method = $tombstone->getMethod();
if (null !== $method) {
- return sprintf('method %s', htmlspecialchars($method));
+ return \sprintf('method %s', htmlspecialchars($method));
}
return 'global scope';
@@ -240,7 +240,7 @@ private function getTombstoneScope(Tombstone $tombstone): string
private function linkToTombstoneInCode(string $label, FilePathInterface $file, int $line): string
{
if ($file instanceof RelativeFilePath) {
- return sprintf('%s', $file->getRelativePath(), $line, htmlspecialchars($label));
+ return \sprintf('%s', $file->getRelativePath(), $line, htmlspecialchars($label));
}
return htmlspecialchars($label);
diff --git a/src/analyzer/Report/Html/Renderer/PhpSyntaxHighlighter.php b/src/analyzer/Report/Html/Renderer/PhpSyntaxHighlighter.php
index 556eb44..23767da 100644
--- a/src/analyzer/Report/Html/Renderer/PhpSyntaxHighlighter.php
+++ b/src/analyzer/Report/Html/Renderer/PhpSyntaxHighlighter.php
@@ -29,7 +29,7 @@ public static function formatBracket(string $value): string
private static function formatValue(string $value, string $color): string
{
- return sprintf('%s', $color, $value);
+ return \sprintf('%s', $color, $value);
}
private static function getColorForToken(int $token): string
diff --git a/src/analyzer/Stock/TombstoneExtractor.php b/src/analyzer/Stock/TombstoneExtractor.php
index 9331262..1f4bcf6 100644
--- a/src/analyzer/Stock/TombstoneExtractor.php
+++ b/src/analyzer/Stock/TombstoneExtractor.php
@@ -50,7 +50,7 @@ public function extractTombstones(string $filePath): array
$this->extractedTombstones = [];
$this->currentFilePath = $filePath;
if (!is_readable($filePath)) {
- throw new TombstoneExtractorException(sprintf('File "%s" is not readable.', $filePath));
+ throw new TombstoneExtractorException(\sprintf('File "%s" is not readable.', $filePath));
}
$this->parseSourceCode($filePath);
@@ -68,7 +68,7 @@ private function parseSourceCode(string $absoluteFilePath): void
$content = file_get_contents($absoluteFilePath);
$stmts = $this->parser->parse($content);
if (null === $stmts) {
- throw new TombstoneExtractorException(sprintf('PHP code in "%s" could not be parsed.', $absoluteFilePath));
+ throw new TombstoneExtractorException(\sprintf('PHP code in "%s" could not be parsed.', $absoluteFilePath));
}
// Calls back to onTombstoneFound()
@@ -76,9 +76,9 @@ private function parseSourceCode(string $absoluteFilePath): void
} catch (TombstoneExtractorException $e) {
throw $e;
} catch (Error $e) {
- throw new TombstoneExtractorException(sprintf('PHP code in "%s" could not be parsed.', $absoluteFilePath), 0, $e);
+ throw new TombstoneExtractorException(\sprintf('PHP code in "%s" could not be parsed.', $absoluteFilePath), 0, $e);
} catch (\Throwable $e) {
- throw new TombstoneExtractorException(sprintf('Exception while parsing "%s".', $absoluteFilePath), 0, $e);
+ throw new TombstoneExtractorException(\sprintf('Exception while parsing "%s".', $absoluteFilePath), 0, $e);
}
}
diff --git a/src/analyzer/Stock/TombstoneNodeVisitor.php b/src/analyzer/Stock/TombstoneNodeVisitor.php
index 9151ea9..c7e98c3 100644
--- a/src/analyzer/Stock/TombstoneNodeVisitor.php
+++ b/src/analyzer/Stock/TombstoneNodeVisitor.php
@@ -82,7 +82,7 @@ private function getNamespacedName($node): string
/** @psalm-suppress DocblockTypeContradiction */
if (!isset($node->namespacedName)) {
$nodeName = isset($node->name) ? (string) $node->name : '';
- throw new \RuntimeException(sprintf('Node %s of type %s did not provide attribute namespacedName', $nodeName, \get_class($node)));
+ throw new \RuntimeException(\sprintf('Node %s of type %s did not provide attribute namespacedName', $nodeName, \get_class($node)));
}
return (string) $node->namespacedName;
diff --git a/src/core/Format/AnalyzerLogFormatException.php b/src/core/Format/AnalyzerLogFormatException.php
index 061fc8d..d040f7f 100644
--- a/src/core/Format/AnalyzerLogFormatException.php
+++ b/src/core/Format/AnalyzerLogFormatException.php
@@ -12,7 +12,7 @@ class AnalyzerLogFormatException extends \Exception
public static function createIncompatibleDataException(int $currentVersion, ?int $version): self
{
return new self(
- sprintf('Log data provided in incompatible version, current version %s, provided version: %s', $currentVersion, $version ?? 'unknown'),
+ \sprintf('Log data provided in incompatible version, current version %s, provided version: %s', $currentVersion, $version ?? 'unknown'),
self::INCOMPATIBLE_VERSION
);
}
@@ -20,7 +20,7 @@ public static function createIncompatibleDataException(int $currentVersion, ?int
public static function createMissingDataException(array $missingData): self
{
return new self(
- sprintf('Log data is missing fields: %s', implode(', ', $missingData)),
+ \sprintf('Log data is missing fields: %s', implode(', ', $missingData)),
self::MISSING_DATA
);
}
diff --git a/src/core/Model/RootPath.php b/src/core/Model/RootPath.php
index a9b970b..441b266 100644
--- a/src/core/Model/RootPath.php
+++ b/src/core/Model/RootPath.php
@@ -26,7 +26,7 @@ public function __construct(string $rootPath)
}
if (!self::isPathAbsolute($rootPath)) {
- throw new \InvalidArgumentException(sprintf('Root rootPath "%s" must be absolute.', $rootPath));
+ throw new \InvalidArgumentException(\sprintf('Root rootPath "%s" must be absolute.', $rootPath));
}
$rootPath = PathNormalizer::normalizeDirectorySeparator($rootPath);
diff --git a/src/logger/Formatter/LineFormatter.php b/src/logger/Formatter/LineFormatter.php
index 6871de5..b282f89 100644
--- a/src/logger/Formatter/LineFormatter.php
+++ b/src/logger/Formatter/LineFormatter.php
@@ -10,7 +10,7 @@ class LineFormatter implements FormatterInterface
{
public function format(Vampire $vampire): string
{
- $line = sprintf(
+ $line = \sprintf(
'%s - Vampire detected: %s, in file %s:%s',
$vampire->getInvocationDate(),
(string) $vampire->getTombstone(),
diff --git a/src/logger/Graveyard/Graveyard.php b/src/logger/Graveyard/Graveyard.php
index e2fa01a..def4996 100644
--- a/src/logger/Graveyard/Graveyard.php
+++ b/src/logger/Graveyard/Graveyard.php
@@ -40,7 +40,7 @@ public function logTombstoneCall(array $arguments, array $trace, array $metadata
$handler->log($vampire);
}
} catch (\Throwable $e) {
- $this->logger->error(sprintf('Exception while tracking a tombstone call: %s %s (%s)', \get_class($e), $e->getMessage(), $e->getCode()));
+ $this->logger->error(\sprintf('Exception while tracking a tombstone call: %s %s (%s)', \get_class($e), $e->getMessage(), $e->getCode()));
}
}
@@ -51,7 +51,7 @@ public function flush(): void
$handler->flush();
}
} catch (\Throwable $e) {
- $this->logger->error(sprintf('Exception while flushing tombstones: %s %s (%s)', \get_class($e), $e->getMessage(), $e->getCode()));
+ $this->logger->error(\sprintf('Exception while flushing tombstones: %s %s (%s)', \get_class($e), $e->getMessage(), $e->getCode()));
}
}
}
diff --git a/src/logger/Handler/AnalyzerLogHandler.php b/src/logger/Handler/AnalyzerLogHandler.php
index 5e90040..5ce4894 100644
--- a/src/logger/Handler/AnalyzerLogHandler.php
+++ b/src/logger/Handler/AnalyzerLogHandler.php
@@ -77,7 +77,7 @@ private function getLogFile(Vampire $vampire): string
$date = date('Ymd');
$hash = $vampire->getTombstone()->getHash();
- return $this->logDir.'/'.sprintf(self::LOG_FILE_NAME, $hash, $date);
+ return $this->logDir.'/'.\sprintf(self::LOG_FILE_NAME, $hash, $date);
}
private function getLogStream(string $logFile): StreamHandler
diff --git a/src/logger/Handler/StreamHandler.php b/src/logger/Handler/StreamHandler.php
index 14c3fbf..5c3bb98 100644
--- a/src/logger/Handler/StreamHandler.php
+++ b/src/logger/Handler/StreamHandler.php
@@ -96,7 +96,7 @@ public function log(Vampire $vampire): void
if (!\is_resource($this->stream)) {
$this->stream = null;
/** @psalm-suppress NullArgument */
- throw new \UnexpectedValueException(sprintf('The stream or file "%s" could not be opened: %s', $this->errorMessage, $this->url));
+ throw new \UnexpectedValueException(\sprintf('The stream or file "%s" could not be opened: %s', $this->errorMessage, $this->url));
}
}
if ($this->useLocking) {
@@ -145,7 +145,7 @@ private function createDir(): void
restore_error_handler();
if (false === $status && !is_dir($dir)) {
/** @psalm-suppress NullArgument */
- throw new \UnexpectedValueException(sprintf('There is no existing directory at "%s" and its not buildable: %s', $dir, $this->errorMessage));
+ throw new \UnexpectedValueException(\sprintf('There is no existing directory at "%s" and its not buildable: %s', $dir, $this->errorMessage));
}
}
$this->dirCreated = true;
diff --git a/tests/ComposerJsonTest.php b/tests/ComposerJsonTest.php
index 99b0055..f4301fa 100644
--- a/tests/ComposerJsonTest.php
+++ b/tests/ComposerJsonTest.php
@@ -24,10 +24,10 @@ public function packageDependenciesEqualRootDependencies(): void
continue;
}
- $message = sprintf('Dependency "%s" from package "%s" is not defined in root composer.json', $dependency, $package);
+ $message = \sprintf('Dependency "%s" from package "%s" is not defined in root composer.json', $dependency, $package);
$this->assertArrayHasKey($dependency, $rootDependencies, $message);
- $message = sprintf('Dependency "%s:%s" from package "%s" requires a different version in the root composer.json', $dependency, $version, $package);
+ $message = \sprintf('Dependency "%s:%s" from package "%s" requires a different version in the root composer.json', $dependency, $version, $package);
$this->assertEquals($version, $rootDependencies[$dependency], $message);
$usedDependencies[] = $dependency;
@@ -35,7 +35,7 @@ public function packageDependenciesEqualRootDependencies(): void
}
$unusedDependencies = array_diff(array_keys($rootDependencies), array_unique($usedDependencies));
- $message = sprintf('Dependencies declared in root composer.json, which are not declared in any sub-package: %s', implode($unusedDependencies));
+ $message = \sprintf('Dependencies declared in root composer.json, which are not declared in any sub-package: %s', implode($unusedDependencies));
$this->assertCount(0, $unusedDependencies, $message);
}
@@ -47,7 +47,7 @@ public function rootReplacesSubPackages(): void
$rootReplaces = $this->getComposerReplaces(__DIR__.'/../composer.json');
foreach ($this->listSubPackages() as $package) {
$packageName = $this->getComposerPackageName(self::SRC_DIR.'/'.$package.'/composer.json');
- $message = sprintf('Root composer.json must replace the sub-packages "%s"', $packageName);
+ $message = \sprintf('Root composer.json must replace the sub-packages "%s"', $packageName);
$this->assertArrayHasKey($packageName, $rootReplaces, $message);
}
}