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
2 changes: 1 addition & 1 deletion src/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function extractAsSnippets(Selector $selector, string $targetId): Snippet
return $list;
}

public function asString(Filter $filter = null): string {
public function asString(?Filter $filter = null): string {
$content = $this->serializeDomDocument();
$content = (new EmptyElementsFilter())->apply($content);
$content = (new ClearRedundantHtmlNamespaceDefinitionsFilter($this->dom->documentElement->nodeName))->apply($content);
Expand Down
2 changes: 1 addition & 1 deletion src/TempladoException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class TempladoException extends Exception {
/** @var \LibXMLError[] */
private $errorList;

public function __construct(string $message, int $code = 0, Exception $previous = null) {
public function __construct(string $message, int $code = 0, ?Exception $previous = null) {
parent::__construct($message, $code, $previous);
$this->errorList = \libxml_get_errors();
\libxml_clear_errors();
Expand Down
10 changes: 5 additions & 5 deletions src/snippet/SnippetLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use DOMDocument;

class SnippetLoader {
public function load(FileName $fileName, string $id = null): Snippet {
public function load(FileName $fileName, ?string $id = null): Snippet {
$this->ensureFileExists($fileName);
$this->ensureIsReadableFile($fileName);

Expand All @@ -26,7 +26,7 @@ public function load(FileName $fileName, string $id = null): Snippet {
);
}

private function loadAsText(FileName $fileName, string $id = null): TextSnippet {
private function loadAsText(FileName $fileName, ?string $id = null): TextSnippet {
return new TextSnippet(
$id ?? $fileName->getName(),
(new DOMDocument())->createTextNode(\file_get_contents($fileName->asString()))
Expand All @@ -36,7 +36,7 @@ private function loadAsText(FileName $fileName, string $id = null): TextSnippet
/**
* @throws SnippetLoaderException
*/
private function loadAsSnippet(FileName $fileName, string $id = null): Snippet {
private function loadAsSnippet(FileName $fileName, ?string $id = null): Snippet {
$dom = $this->loadFile($fileName);

if ($this->isTempladoSnippetDocument($dom)) {
Expand Down Expand Up @@ -123,11 +123,11 @@ private function ensureIsReadableFile(FileName $fileName): void {
}
}

private function parseAsTempladoSnippet(DOMDocument $dom, string $id = null): TempladoSnippet {
private function parseAsTempladoSnippet(DOMDocument $dom, ?string $id = null): TempladoSnippet {
return new TempladoSnippet($id ?? $dom->documentElement->getAttribute('id'), $dom);
}

private function parseAsHTML(DOMDocument $dom, string $id = null): SimpleSnippet {
private function parseAsHTML(DOMDocument $dom, ?string $id = null): SimpleSnippet {
$id = $id ?? $dom->documentElement->getAttribute('id');

if ($id === '') {
Expand Down
Loading