Skip to content

[CLEANUP] Avoid Hungarian notation for aContents and items #854

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
Jan 30, 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
20 changes: 10 additions & 10 deletions src/CSSList/CSSBlockList.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ public function __construct($lineNumber = 0)
*/
protected function allDeclarationBlocks(array &$result): void
{
foreach ($this->aContents as $mContent) {
if ($mContent instanceof DeclarationBlock) {
$result[] = $mContent;
} elseif ($mContent instanceof CSSBlockList) {
$mContent->allDeclarationBlocks($result);
foreach ($this->contents as $item) {
if ($item instanceof DeclarationBlock) {
$result[] = $item;
} elseif ($item instanceof CSSBlockList) {
$item->allDeclarationBlocks($result);
}
}
}
Expand All @@ -47,11 +47,11 @@ protected function allDeclarationBlocks(array &$result): void
*/
protected function allRuleSets(array &$result): void
{
foreach ($this->aContents as $mContent) {
if ($mContent instanceof RuleSet) {
$result[] = $mContent;
} elseif ($mContent instanceof CSSBlockList) {
$mContent->allRuleSets($result);
foreach ($this->contents as $item) {
if ($item instanceof RuleSet) {
$result[] = $item;
} elseif ($item instanceof CSSBlockList) {
$item->allRuleSets($result);
}
}
}
Expand Down
64 changes: 32 additions & 32 deletions src/CSSList/CSSList.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ abstract class CSSList implements Renderable, Commentable
/**
* @var array<int, RuleSet|CSSList|Import|Charset>
*/
protected $aContents;
protected $contents;

/**
* @var int
Expand All @@ -54,7 +54,7 @@ abstract class CSSList implements Renderable, Commentable
public function __construct($lineNumber = 0)
{
$this->comments = [];
$this->aContents = [];
$this->contents = [];
$this->lineNumber = $lineNumber;
}

Expand Down Expand Up @@ -259,21 +259,21 @@ public function getLineNo()
/**
* Prepends an item to the list of contents.
*
* @param RuleSet|CSSList|Import|Charset $oItem
* @param RuleSet|CSSList|Import|Charset $item
*/
public function prepend($oItem): void
public function prepend($item): void
{
\array_unshift($this->aContents, $oItem);
\array_unshift($this->contents, $item);
}

/**
* Appends an item to the list of contents.
*
* @param RuleSet|CSSList|Import|Charset $oItem
* @param RuleSet|CSSList|Import|Charset $item
*/
public function append($oItem): void
public function append($item): void
{
$this->aContents[] = $oItem;
$this->contents[] = $item;
}

/**
Expand All @@ -285,7 +285,7 @@ public function append($oItem): void
*/
public function splice($iOffset, $iLength = null, $mReplacement = null): void
{
\array_splice($this->aContents, $iOffset, $iLength, $mReplacement);
\array_splice($this->contents, $iOffset, $iLength, $mReplacement);
}

/**
Expand All @@ -297,7 +297,7 @@ public function splice($iOffset, $iLength = null, $mReplacement = null): void
*/
public function insertBefore($item, $sibling): void
{
if (\in_array($sibling, $this->aContents, true)) {
if (\in_array($sibling, $this->contents, true)) {
$this->replace($sibling, [$item, $sibling]);
} else {
$this->append($item);
Expand All @@ -307,17 +307,17 @@ public function insertBefore($item, $sibling): void
/**
* Removes an item from the CSS list.
*
* @param RuleSet|Import|Charset|CSSList $oItemToRemove
* @param RuleSet|Import|Charset|CSSList $itemToRemove
* May be a `RuleSet` (most likely a `DeclarationBlock`), an `Import`,
* a `Charset` or another `CSSList` (most likely a `MediaQuery`)
*
* @return bool whether the item was removed
*/
public function remove($oItemToRemove)
public function remove($itemToRemove)
{
$iKey = \array_search($oItemToRemove, $this->aContents, true);
$iKey = \array_search($itemToRemove, $this->contents, true);
if ($iKey !== false) {
unset($this->aContents[$iKey]);
unset($this->contents[$iKey]);
return true;
}
return false;
Expand All @@ -326,33 +326,33 @@ public function remove($oItemToRemove)
/**
* Replaces an item from the CSS list.
*
* @param RuleSet|Import|Charset|CSSList $oOldItem
* @param RuleSet|Import|Charset|CSSList $oldItem
* May be a `RuleSet` (most likely a `DeclarationBlock`), an `Import`, a `Charset`
* or another `CSSList` (most likely a `MediaQuery`)
*
* @return bool
*/
public function replace($oOldItem, $mNewItem)
public function replace($oldItem, $newItem)
{
$iKey = \array_search($oOldItem, $this->aContents, true);
$iKey = \array_search($oldItem, $this->contents, true);
if ($iKey !== false) {
if (\is_array($mNewItem)) {
\array_splice($this->aContents, $iKey, 1, $mNewItem);
if (\is_array($newItem)) {
\array_splice($this->contents, $iKey, 1, $newItem);
} else {
\array_splice($this->aContents, $iKey, 1, [$mNewItem]);
\array_splice($this->contents, $iKey, 1, [$newItem]);
}
return true;
}
return false;
}

/**
* @param array<int, RuleSet|Import|Charset|CSSList> $aContents
* @param array<int, RuleSet|Import|Charset|CSSList> $contents
*/
public function setContents(array $aContents): void
public function setContents(array $contents): void
{
$this->aContents = [];
foreach ($aContents as $content) {
$this->contents = [];
foreach ($contents as $content) {
$this->append($content);
}
}
Expand Down Expand Up @@ -383,12 +383,12 @@ public function removeDeclarationBlockBySelector($mSelector, $bRemoveAll = false
$mSel = new Selector($mSel);
}
}
foreach ($this->aContents as $iKey => $mItem) {
if (!($mItem instanceof DeclarationBlock)) {
foreach ($this->contents as $iKey => $item) {
if (!($item instanceof DeclarationBlock)) {
continue;
}
if ($mItem->getSelectors() == $mSelector) {
unset($this->aContents[$iKey]);
if ($item->getSelectors() == $mSelector) {
unset($this->contents[$iKey]);
if (!$bRemoveAll) {
return;
}
Expand All @@ -412,9 +412,9 @@ protected function renderListContents(OutputFormat $oOutputFormat)
if (!$this->isRootList()) {
$oNextLevel = $oOutputFormat->nextLevel();
}
foreach ($this->aContents as $oContent) {
$sRendered = $oOutputFormat->safely(static function () use ($oNextLevel, $oContent): string {
return $oContent->render($oNextLevel);
foreach ($this->contents as $listItem) {
$sRendered = $oOutputFormat->safely(static function () use ($oNextLevel, $listItem): string {
return $listItem->render($oNextLevel);
});
if ($sRendered === null) {
continue;
Expand Down Expand Up @@ -450,7 +450,7 @@ abstract public function isRootList();
*/
public function getContents()
{
return $this->aContents;
return $this->contents;
}

/**
Expand Down