Skip to content

Conversation

@thekid
Copy link
Member

@thekid thekid commented Feb 24, 2023

This pull request deprecates XmlStream, XmlFile, XmlString and XmlResource in favor of a new class, util.address.XmlStreaming, and introduces a new base class, util.address.Streaming. This way, it becomes easier to stream other formats, e.g. by implementing a class util.address.JsonStreaming.

Before

Every input source has a different (but 90% identical) implementation:

use util\address\{XmlStream, XmlFile, XmlString};

$stream= new XmlStream($socket->in());
$stream= new XmlFile(new File('...'));
$stream= new XmlString('<root>...</root>');
$stream= new XmlResource($package, 'releases.xml');

After

The XmlStreaming constructor accepts string|io.Channel|io.streams.InputStream as source, and can handle all cases:

use util\address\XmlStreaming;

$stream= new XmlStreaming($socket->in());    // or also new XmlStreaming($socket);
$stream= new XmlStreaming(new File('...'));
$stream= new XmlStreaming('<root>...</root>');
$stream= new XmlStreaming($package->getResourceAsStream('releases.xml'));

Deprecations

The following classes are marked as deprecated and will be removed in the next major release.

$ grep -Hrn @deprecated src/main/php/
src/main/php/util/address/Address.class.php:8: * @deprecated Inherit from util.address.Streaming instead!
src/main/php/util/address/XmlFile.class.php:9: * @deprecated by XmlStreaming
src/main/php/util/address/XmlResource.class.php:9: * @deprecated by XmlStreaming
src/main/php/util/address/XmlStream.class.php:8: * @deprecated by XmlStreaming
src/main/php/util/address/XmlString.class.php:9: * @deprecated by XmlStreaming

@thekid thekid changed the title Join various input source into one new API: XmlStreaming Join various input sources into one new API: XmlStreaming Feb 24, 2023
@thekid thekid merged commit 66aecf5 into master Feb 24, 2023
@thekid thekid deleted the refactor/xml-streaming branch February 24, 2023 10:19
@thekid
Copy link
Member Author

thekid commented Mar 3, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants