Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[CLEANUP] Avoid Hungarian notation in OutputFormat (part 9)
Also rename the getters to match the new property names.

Part of #756
  • Loading branch information
oliverklee committed Mar 9, 2025
commit 369a318e51d6b82b673ac64a3c0957359d877158
24 changes: 12 additions & 12 deletions src/OutputFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class OutputFormat
*
* @var bool
*/
private $bRenderComments = false;
private $shouldRenderComments = false;

/**
* @var OutputFormatter|null
Expand All @@ -178,25 +178,25 @@ class OutputFormat
/**
* @var int
*/
private $iIndentationLevel = 0;
private $indendationLevel = 0;

public function __construct() {}

/**
* @param non-empty-string $sMethodName
* @param non-empty-string $methodName
* @param array<array-key, mixed> $arguments
*
* @return mixed
*
* @throws \Exception
*/
public function __call(string $sMethodName, array $arguments)
public function __call(string $methodName, array $arguments)
{
if (\method_exists(OutputFormatter::class, $sMethodName)) {
if (\method_exists(OutputFormatter::class, $methodName)) {
// @deprecated since 8.8.0, will be removed in 9.0.0. Call the method on the formatter directly instead.
return \call_user_func_array([$this->getFormatter(), $sMethodName], $arguments);
return \call_user_func_array([$this->getFormatter(), $methodName], $arguments);
} else {
throw new \Exception('Unknown OutputFormat method called: ' . $sMethodName);
throw new \Exception('Unknown OutputFormat method called: ' . $methodName);
}
}

Expand Down Expand Up @@ -643,17 +643,17 @@ public function setIgnoreExceptions(bool $ignoreExceptions): self
/**
* @internal
*/
public function getRenderComments(): bool
public function shouldRenderComments(): bool
{
return $this->bRenderComments;
return $this->shouldRenderComments;
}

/**
* @return $this fluent interface
*/
public function setRenderComments(bool $renderComments): self
{
$this->bRenderComments = $renderComments;
$this->shouldRenderComments = $renderComments;

return $this;
}
Expand All @@ -663,7 +663,7 @@ public function setRenderComments(bool $renderComments): self
*/
public function getIndentationLevel(): int
{
return $this->iIndentationLevel;
return $this->indendationLevel;
}

/**
Expand All @@ -689,7 +689,7 @@ public function nextLevel(): self
{
if ($this->nextLevelFormat === null) {
$this->nextLevelFormat = clone $this;
$this->nextLevelFormat->iIndentationLevel++;
$this->nextLevelFormat->indendationLevel++;
$this->nextLevelFormat->outputFormatter = null;
}
return $this->nextLevelFormat;
Expand Down
2 changes: 1 addition & 1 deletion src/OutputFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public function removeLastSemicolon(string $string): string

public function comments(Commentable $commentable): string
{
if (!$this->outputFormat->getRenderComments()) {
if (!$this->outputFormat->shouldRenderComments()) {
return '';
}

Expand Down
10 changes: 5 additions & 5 deletions tests/Unit/OutputFormatTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -688,9 +688,9 @@ public function setIgnoreExceptionsProvidesFluentInterface(): void
/**
* @test
*/
public function getRenderCommentsInitiallyReturnsFalse(): void
public function shouldRenderCommentsInitiallyReturnsFalse(): void
{
self::assertFalse($this->subject->getRenderComments());
self::assertFalse($this->subject->shouldRenderComments());
}

/**
Expand All @@ -702,7 +702,7 @@ public function setRenderCommentsSetsRenderComments(bool $value): void
{
$this->subject->setRenderComments($value);

self::assertSame($value, $this->subject->getRenderComments());
self::assertSame($value, $this->subject->shouldRenderComments());
}

/**
Expand Down Expand Up @@ -1041,7 +1041,7 @@ public function createCompactReturnsInstanceWithRenderCommentsDisabled(): void
{
$newInstance = OutputFormat::createCompact();

self::assertFalse($newInstance->getRenderComments());
self::assertFalse($newInstance->shouldRenderComments());
}

/**
Expand Down Expand Up @@ -1170,6 +1170,6 @@ public function createPrettyReturnsInstanceWithRenderCommentsEnabled(): void
{
$newInstance = OutputFormat::createPretty();

self::assertTrue($newInstance->getRenderComments());
self::assertTrue($newInstance->shouldRenderComments());
}
}