Skip to content

[CLEANUP] Avoid Hungarian notation for outputFormat(ter) #942

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

Merged
merged 1 commit into from
Feb 16, 2025
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
13 changes: 7 additions & 6 deletions src/OutputFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class OutputFormat
* Spacing
* Note that these strings are not sanity-checked: the value should only consist of whitespace
* Any newline character will be indented according to the current level.
* The triples (After, Before, Between) can be set using a wildcard (e.g. `$oFormat->set('Space*Rules', "\n");`)
* The triples (After, Before, Between) can be set using a wildcard
* (e.g. `$outputFormat->set('Space*Rules', "\n");`)
*
* @var string
*
Expand Down Expand Up @@ -217,7 +218,7 @@ class OutputFormat
/**
* @var OutputFormatter|null
*/
private $oFormatter;
private $outputFormatter;

/**
* @var OutputFormat|null
Expand Down Expand Up @@ -788,7 +789,7 @@ public function nextLevel(): self
if ($this->oNextLevelFormat === null) {
$this->oNextLevelFormat = clone $this;
$this->oNextLevelFormat->iIndentationLevel++;
$this->oNextLevelFormat->oFormatter = null;
$this->oNextLevelFormat->outputFormatter = null;
}
return $this->oNextLevelFormat;
}
Expand All @@ -800,10 +801,10 @@ public function beLenient(): void

public function getFormatter(): OutputFormatter
{
if ($this->oFormatter === null) {
$this->oFormatter = new OutputFormatter($this);
if ($this->outputFormatter === null) {
$this->outputFormatter = new OutputFormatter($this);
}
return $this->oFormatter;
return $this->outputFormatter;
}

/**
Expand Down
28 changes: 14 additions & 14 deletions src/OutputFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ class OutputFormatter
/**
* @var OutputFormat
*/
private $oFormat;
private $outputFormat;

public function __construct(OutputFormat $oFormat)
public function __construct(OutputFormat $outputFormat)
{
$this->oFormat = $oFormat;
$this->outputFormat = $outputFormat;
}

/**
Expand All @@ -25,7 +25,7 @@ public function __construct(OutputFormat $oFormat)
*/
public function space($sName, $sType = null): string
{
$sSpaceString = $this->oFormat->get("Space$sName");
$sSpaceString = $this->outputFormat->get("Space$sName");
// If $sSpaceString is an array, we have multiple values configured
// depending on the type of object the space applies to
if (\is_array($sSpaceString)) {
Expand Down Expand Up @@ -91,7 +91,7 @@ public function spaceAfterSelectorSeparator(): string
*/
public function spaceBeforeListArgumentSeparator($sSeparator): string
{
$spaceForSeparator = $this->oFormat->getSpaceBeforeListArgumentSeparators();
$spaceForSeparator = $this->outputFormat->getSpaceBeforeListArgumentSeparators();

return $spaceForSeparator[$sSeparator] ?? $this->space('BeforeListArgumentSeparator', $sSeparator);
}
Expand All @@ -101,7 +101,7 @@ public function spaceBeforeListArgumentSeparator($sSeparator): string
*/
public function spaceAfterListArgumentSeparator($sSeparator): string
{
$spaceForSeparator = $this->oFormat->getSpaceAfterListArgumentSeparators();
$spaceForSeparator = $this->outputFormat->getSpaceAfterListArgumentSeparators();

return $spaceForSeparator[$sSeparator] ?? $this->space('AfterListArgumentSeparator', $sSeparator);
}
Expand All @@ -120,7 +120,7 @@ public function spaceBeforeOpeningBrace(): string
*/
public function safely($cCode)
{
if ($this->oFormat->get('IgnoreExceptions')) {
if ($this->outputFormat->get('IgnoreExceptions')) {
// If output exceptions are ignored, run the code with exception guards
try {
return $cCode();
Expand All @@ -142,9 +142,9 @@ public function safely($cCode)
public function implode(string $sSeparator, array $aValues, $bIncreaseLevel = false): string
{
$result = '';
$oFormat = $this->oFormat;
$outputFormat = $this->outputFormat;
if ($bIncreaseLevel) {
$oFormat = $oFormat->nextLevel();
$outputFormat = $outputFormat->nextLevel();
}
$bIsFirst = true;
foreach ($aValues as $mValue) {
Expand All @@ -154,7 +154,7 @@ public function implode(string $sSeparator, array $aValues, $bIncreaseLevel = fa
$result .= $sSeparator;
}
if ($mValue instanceof Renderable) {
$result .= $mValue->render($oFormat);
$result .= $mValue->render($outputFormat);
} else {
$result .= $mValue;
}
Expand All @@ -169,7 +169,7 @@ public function implode(string $sSeparator, array $aValues, $bIncreaseLevel = fa
*/
public function removeLastSemicolon($sString)
{
if ($this->oFormat->get('SemicolonAfterLastRule')) {
if ($this->outputFormat->get('SemicolonAfterLastRule')) {
return $sString;
}
$sString = \explode(';', $sString);
Expand All @@ -184,7 +184,7 @@ public function removeLastSemicolon($sString)

public function comments(Commentable $oCommentable): string
{
if (!$this->oFormat->bRenderComments) {
if (!$this->outputFormat->bRenderComments) {
return '';
}

Expand All @@ -193,7 +193,7 @@ public function comments(Commentable $oCommentable): string
$iLastCommentIndex = \count($comments) - 1;

foreach ($comments as $i => $oComment) {
$result .= $oComment->render($this->oFormat);
$result .= $oComment->render($this->outputFormat);
$result .= $i === $iLastCommentIndex ? $this->spaceAfterBlocks() : $this->spaceBetweenBlocks();
}
return $result;
Expand All @@ -212,6 +212,6 @@ private function prepareSpace($sSpaceString): string
*/
private function indent(): string
{
return \str_repeat($this->oFormat->sIndentation, $this->oFormat->getIndentationLevel());
return \str_repeat($this->outputFormat->sIndentation, $this->outputFormat->getIndentationLevel());
}
}