-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce breaking reader/writer PHP 8.4 changes and new stream funct…
…ions
- Loading branch information
Showing
15 changed files
with
691 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace VeeWee\Xml\Reader\Loader; | ||
|
||
use Closure; | ||
use Webmozart\Assert\Assert; | ||
use XMLReader; | ||
use function VeeWee\Xml\ErrorHandling\disallow_issues; | ||
use function VeeWee\Xml\ErrorHandling\disallow_libxml_false_returns; | ||
|
||
/** | ||
* @param resource $stream | ||
* @return Closure(): XMLReader | ||
*/ | ||
function xml_stream_loader(mixed $stream, ?string $encoding = null, int $flags = 0, ?string $documentUri = null): Closure | ||
{ | ||
return static fn (): XMLReader => disallow_issues( | ||
static function () use ($stream, $encoding, $flags, $documentUri): XMLReader { | ||
return disallow_libxml_false_returns( | ||
XMLReader::fromStream($stream, $encoding, $flags, $documentUri), | ||
'Could not read the provided XML stream!' | ||
); | ||
} | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace VeeWee\Xml\Writer\Applicative; | ||
|
||
interface Applicative | ||
{ | ||
/** | ||
* @return mixed | ||
*/ | ||
public function __invoke(\XMLWriter $writer): mixed; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace VeeWee\Xml\Writer\Applicative; | ||
|
||
use XMLWriter; | ||
|
||
/** | ||
* @param bool $empty - Whether to empty the buffer or not. | ||
* | ||
* @return \Closure(XMLWriter): mixed | ||
*/ | ||
function flush(bool $empty = true): \Closure { | ||
return function (XMLWriter $writer) use ($empty): void { | ||
$writer->flush($empty); | ||
}; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,5 @@ | |
|
||
interface Opener | ||
{ | ||
public function __invoke(XMLWriter $writer): bool; | ||
public function __invoke(): XMLWriter; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace VeeWee\Xml\Writer\Opener; | ||
|
||
use Closure; | ||
use Psl\File\WriteMode; | ||
use XMLWriter; | ||
use function Psl\File\write; | ||
|
||
/** | ||
* @param resource $stream | ||
* | ||
* @return Closure(): XMLWriter | ||
*/ | ||
function xml_stream_opener(mixed $stream): Closure | ||
{ | ||
return static function () use ($stream) : XMLWriter { | ||
return XMLWriter::toStream($stream); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.