Skip to content

Commit

Permalink
Fixes a wrong handling of null/empty node value.
Browse files Browse the repository at this point in the history
[#] Fixed:
* fixes #13.
  • Loading branch information
daniele-orlando committed Jul 12, 2016
1 parent 90d69ee commit fb4a086
Show file tree
Hide file tree
Showing 5 changed files with 237 additions and 102 deletions.
9 changes: 8 additions & 1 deletion documents/Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
[+]: new [~]: changed [-]: removed [#]: fixed [@]: internal


1.20.2: (2016-03-04)
1.20.3: (2016-07-12)
fixes wrong handling of null/empty node value.

[#] Fixed:
* fixes #13.


1.20.2:
fixes some leaked PHP notices.

[#] Fixed:
Expand Down
47 changes: 27 additions & 20 deletions documents/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,18 @@

## Changelog

**1.20.2** (2016-03-04):
_fixes some leaked PHP notices._
**1.20.3** (2016-07-12):
_fixes wrong handling of null/empty node value._

**...**

[The full changes list.][changelog]

<br/>

[![Donate][donate-button]][donate-link]<br/>
**1$ or more**<span style="color: gray;">, due to the PayPal fees.</span>
<a href='https://ko-fi.com/2216WXOPLSZER' target='_blank'>
<img height='32' src='https://az743702.vo.msecnd.net/cdn/kofi5.png?v=a' border='0' alt='Buy Me a Coffee at ko-fi.com'/>
</a>


# FluidXML
Expand All @@ -69,8 +70,6 @@ _fixes some leaked PHP notices._
FluidXML is a PHP library designed to manipulate XML documents with a **concise** and **fluent** API.<br/>
It leverages the fluent programming pattern to be **fun and effective**.

With FluidXML the DOM manipulation becomes **fast**, **clear** and **expressive**.

```php
$book = fluidxml();

Expand All @@ -93,6 +92,8 @@ $book->addChild('title', 'The Theory Of Everything')
->addChild('chapter', 'The Expanding Universe', ['id' => 2]);
```

With FluidXML the DOM manipulation becomes **fast**, **clear** and **expressive**.

**PHP Arrays** are first class citizens.

```php
Expand Down Expand Up @@ -131,11 +132,13 @@ $book->query('//title', '//author', '//chapter')
->attr('lang', 'en');
```

And **CSS Selectors** rocks.
And **CSS Selectors** rock.

```php
$book->query('title', 'author', 'chapters > chapter')
$book->query('#id', '.class1.class2', 'div p > span')
->attr('lang', 'en');

// Many other selectors are available.
```

**XML/CSS Namespaces** are fully covered.
Expand All @@ -147,7 +150,7 @@ $book->namespace('xhtml', 'http://www.w3.org/1999/xhtml')
->query('xhtml|h1'); // CSS namespace.
```

And sometimes **string fragments** are the fastest way.
And sometimes **XML Fragments** are the fastest way.

```php
$book->add(<<<XML
Expand All @@ -165,7 +168,7 @@ Everything is fluent, even **iterations**.

```php
$book->query('//chapter')
->each(function($i) {
->each(function ($i) {
$this->attr('id', $i);
});
```
Expand All @@ -174,7 +177,7 @@ $book->query('//chapter')
$book->query('//chapters')
->times(3)
->add('chapter')
->times(4, function($i) {
->times(4, function ($i) {
$this->add('chapter');
$this->add('illustration');
});
Expand All @@ -185,7 +188,7 @@ Whether some queries are too complex to express with XPath/CSS,<br/>

```php
$book->query('//chapters')
->filter(function($i, $node) {
->filter(function ($i, $node) {
return $i % 2 === 0;
})
->attr('even');
Expand Down Expand Up @@ -293,21 +296,25 @@ and go to the [Wiki Page][wiki] for more reading.

## Donation
If you think this code is **awesome** or if you want to demonstrate<br/>
your immense gratitude **[][thankyou]**, donate _1cent_.
your immense gratitude **[][thankyou]**, _buy me a coffe_.

<a href='https://ko-fi.com/2216WXOPLSZER' target='_blank'>
<img height='32' src='https://az743702.vo.msecnd.net/cdn/kofi5.png?v=a' border='0' alt='Buy Me a Coffee at ko-fi.com'/>
</a>

[//]: # ([![Donate][donate-button]][donate-link]<br/>)
[//]: # (**1$ or more**<span style="color: gray;">, due to the PayPal fees.</span>)

<a-off href='https://pledgie.com/campaigns/30607'>
<img-off alt='Click here to lend your support to: FluidXML and make a donation at pledgie.com !' src='https://pledgie.com/campaigns/30607.png?skin_name=chrome' border='0'/>
</a-off>

[![Donate][donate-button]][donate-link]<br/>
**1$ or more**<span style="color: gray;">, due to the PayPal fees.</span>

## Roadmap
* [x] PHP 5.6 backport
* [ ] Extending the documentation
* [ ] Expanding the APIs

<a href='https://pledgie.com/campaigns/30607'>
<img alt='Click here to lend your support to: FluidXML and make a donation at pledgie.com !' src='https://pledgie.com/campaigns/30607.png?skin_name=chrome' border='0' >
</a>


## Author
Daniele Orlando [&lt;[email protected]&gt;](mailto:[email protected])

Expand Down
2 changes: 1 addition & 1 deletion source/FluidXml/FluidHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public static function isAnXmlString($string)
// otherwise the first character check may fail.
$string = \ltrim($string);

return $string[0] === '<';
return $string && $string[0] === '<';
}

public static function exportNode(\DOMDocument $dom, \DOMNode $node, $html = false)
Expand Down
2 changes: 1 addition & 1 deletion source/FluidXml/FluidInsertionHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ protected function recognizeStringMixed($k, $v)
return 'insertSpecialAttribute';
}

if (\is_string($v)) {
if (\is_string($v) || $v === null) {
if (! FluidHelper::isAnXmlString($v)) {
return 'insertStringSimple';
}
Expand Down
Loading

0 comments on commit fb4a086

Please sign in to comment.