Skip to content

Commit

Permalink
Tidy up after quality analysis (#403)
Browse files Browse the repository at this point in the history
* build: upgrade dom requirement and loosen version range

* docs: update examples

* feature: trim whitespace when there are only template children
closes #363

* maintenance: phpstorm analysis improvements
  • Loading branch information
g105b authored Jan 31, 2023
1 parent 98beac1 commit 7ae5310
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 127 deletions.
76 changes: 38 additions & 38 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions src/ElementBinder.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
<?php
namespace Gt\DomTemplate;

use Gt\Dom\DOMTokenList;
use Gt\Dom\Element;
use Gt\Dom\Facade\DOMTokenListFactory;
use Gt\Dom\Node;
use Gt\Dom\XPathResult;
use ReflectionClass;
use ReflectionMethod;
use ReflectionProperty;

class ElementBinder {
private HTMLAttributeBinder $htmlAttributeBinder;
Expand Down
5 changes: 3 additions & 2 deletions src/ListBinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
class ListBinder {
private BindableCache $bindableCache;

/** @noinspection PhpPropertyCanBeReadonlyInspection */
public function __construct(
private TemplateCollection $templateCollection,
?BindableCache $bindableCache = null
) {
$this->bindableCache = $bindableCache ?? new BindableCache();
}

/** @param iterable<mixed> $listData */
/** @param iterable<int|string,mixed> $listData */
public function bindListData(
iterable $listData,
Document|Element $context,
Expand Down Expand Up @@ -102,7 +103,7 @@ public function bindListData(
return $nestedCount + $i + 1;
}

/** @param iterable<mixed>|array<mixed> $listData */
/** @param iterable<int|string,mixed> $listData */
private function isEmpty(iterable $listData):bool {
if(is_array($listData)) {
return is_null(array_key_first($listData));
Expand Down
4 changes: 2 additions & 2 deletions src/NodePathCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class NodePathCalculator implements Stringable {
public function __construct(
private Node|Element $element
private readonly Node|Element $element
) {
}

Expand Down Expand Up @@ -39,7 +39,7 @@ public function __toString():string {
$path = "/" . $contextPath . $path;
$context = $context->parentElement;
}
while($context && $context instanceof Element);
while($context instanceof Element);

return $path;
}
Expand Down
2 changes: 1 addition & 1 deletion src/PartialContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class PartialContent {
public function __construct(
private string $dirPath
private readonly string $dirPath
) {
if(!is_dir($this->dirPath)) {
throw new PartialContentDirectoryNotFoundException("The partial content path does not exist: $this->dirPath");
Expand Down
Loading

0 comments on commit 7ae5310

Please sign in to comment.