Skip to content

Backwards Compatibility

Thomas Weinert edited this page Aug 19, 2017 · 2 revisions

Backwards Compatibility Breaks

From 6.2 to 7.0

The minimum required PHP version now is 7.0. HHVM is not supported any more. Scalar type hints and return types were added.

Moved the extended DOM classes into the FluentDOM\DOM namespace. (FluentDOM\Document -> FluentDOM\DOM\Document). FluentDOM\Nodes\Creator was moved to FluentDOM\Creator. Several internal classes were moved into a FluentDOM\Utiltity namespace.

FluentDOM\Query::get() now return a DOMNodeis the position was provided, not an array any more.

FluentDOM\DOM\Element::find() was removed, use FluentDOM($element)->find().

From 5.3 to 6.0

The minimum required PHP version now is 5.6.

FluentDOM\Query now parses fragment arguments depending on the content type. It uses the loaders to parse the fragments for methods like FluentDOM\Query::append(). To parse the fragments as XML change the content type after loading.

$fd = FluentDOM($content, 'type/some-type');
$fd->contentType = 'text/xml';

FluentDOM\Query::attr(), FluentDOM\Query::css() and FluentDOM\Query::data() now recognize that the second argument is provided, even if it is NULL.

Serializer factories can now be registered on the FluentDOM class. Loaders implement an additional method to parse a fragment. This allows the FluentDOM\Nodes() class to keep the content type used to load a source. Methods like append() now parse a string as a fragment of the current content type. Casting the FluentDOM\Nodes() instance to a string serializes it to the current content type.

$fd = FluentDOM('{"firstName": "John"}', 'text/json');
echo $fd->find('/*')->append('{"lastName": "Smith"}');
/*
 {"firstName":"John","lastName":"Smith"}
 */

To get the previous behaviour you will have to change the content type to 'text/xml' after loading a source.

$fd = FluentDOM('{"firstName": "John"}', 'text/json');
$fd->contentType = 'text/xml';
echo $fd->find('/*')->append('<lastName>Smith</lastName>');

/* 
  <json:json xmlns:json="urn:carica-json-dom.2013">
    <firstName>John</firstName>
    <lastName>Smith</lastName>
  </json:json>
 */

Loaders have an additional method loadFragment(). Serializers are now expected to be able to serialize a node (not only a document).

You will now have to explicitly allow loaders to load a file.

$fd = FluentDOM('...', '...', [FluentDOM\Loader\Options::ALLOW_FILE => TRUE]);
$fd = FluentDOM('...', '...', [FluentDOM\Loader\Options::IS_FILE => TRUE]);

From 5.2 To 5.3

CSS Selectors are now provided by separate packages. If you like to use them you will need to require the connector package now.

From 5.1 To 5.2

The FluentDOM\Loadable::load() method now has a third argument $options. The FluentDOM\Nodes method and the FluentDOM function that load data sources got this argument, too. It allows to specify additional, loader specific options. The values are only used inside the loader. This change affects the implementation of loaders, but not the use.

From 4 To 5

Version 5 is a major rewrite. It now uses php namespaces. The original FluentDOM classes (FluentDOM, FluentDOMCore and FluentDOMStyle) are merged into the new FluentDOM\Query class.

The old loaders are gone and replaced with the new FluentDOM\Loadable interface.

The registerNamespaces() method was replaced with a registerNamespace() method, having the same arguments like DOMXpath::registerNamespace().

Clone this wiki locally