Skip to content

Commit

Permalink
Fixes some leaked PHP notices.
Browse files Browse the repository at this point in the history
  • Loading branch information
daniele-orlando committed Mar 4, 2016
1 parent 1e99f2f commit 90d69ee
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 122 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.1: (2016-02-21)
1.20.2: (2016-03-04)
fixes some leaked PHP notices.

[#] Fixed:
* fix.


1.20.1:
internal cleanup.

[@] Internal:
Expand Down
2 changes: 1 addition & 1 deletion documents/License.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2015, Daniele Orlando <danieleorlando.com>
Copyright (c) 2016, Daniele Orlando <fluidxml(at)danieleorlando.com>
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
Expand Down
45 changes: 3 additions & 42 deletions documents/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,51 +48,12 @@

## Changelog

**1.20** (2016-02-21):
_is a major step forward breaking compatibility with the past.<br/>
Under the hood there is a general reorganization to be `PSR-0/4` compliant,<br/>
a general cleanup of the API for being consistent and allowing future clean APIs<br/>
growth, some notable additions like the `->filter()` method to programmatically<br/>
filter the query results and `->html()` to output the document as valid HTML 5<br/>
string. Just because awesomenesses are never enough, `->query()` supports<br/>
**CSS Selectors**._

### New:
* `->html()` is part of the family.
* `->filter()` is part of the family.
* `->comment()` is part of the family.
* `->setComment()` is part of the family.
* `->addComment()` is part of the family.
* `->size()` is an alias of `->length()`.
* `->__invoke()` is an alias of `->query()`.
* `->__toString()` is an alias of `->xml()`.
* `->array()` replaces `->asArray()`.
* `->addChild()` replaces `->appendChild()`.
* `->addText()` replaces `->appendText()`.
* `->addCdata()` replaces `->appendCdata()`.

### Changed:
* `->query()` supports CSS Selectors.
* `fluidxml()` has gained the super powers of `fluidify()`.
* `FluidXml->__construct()` has gained the super powers of `FluidXml::load()`.
* `::load()/fluidify()` can be ONLY used to load an XML file.

### Removed:
* `->asArray()` has been removed superseded by `->array()`.
* `->appendText()` has been removed superseded by `->addText()`.
* `->appendCdata()` has been removed superseded by `->addCdata()`.
* `->appendChild()` has been removed superseded by `->addChild()`.
* `->insertSiblingBefore()` has been removed superseded by `->prependSibling()`.
* `->insertSiblingAfter()` has been removed superseded by `->appendSibling()`.

### Internal:
* `PSR-0/4` compliance.
* `FluidXml.php` is still there for people NOT using Composer/PSR-0/4 loaders.
* `FluidInsertionHandler` refactoring.
**1.20.2** (2016-03-04):
_fixes some leaked PHP notices._

**...**

[See the full changes list.][changelog]
[The full changes list.][changelog]

<br/>

Expand Down
4 changes: 2 additions & 2 deletions source/FluidXml/FluidContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,10 @@ public function appendSibling($sibling, ...$optionals)
// setAttribute(['name' => 'value', ...])
public function setAttribute($name, $value = null)
{
$attrs = [ $name => $value ];

if (\is_array($name)) {
$attrs = $name;
} else {
$attrs = [ $name => $value ];
}

foreach ($this->nodes as $n) {
Expand Down
10 changes: 0 additions & 10 deletions source/FluidXml/FluidNamespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,6 @@ class FluidNamespace

public function __construct($id, $uri, $mode = 1)
{
if (\is_array($id)) {
$args = $id;
$id = $args[self::ID];
$uri = $args[self::URI];

if (isset($args[self::MODE])) {
$mode = $args[self::MODE];
}
}

$this->config[self::ID] = $id;
$this->config[self::URI] = $uri;
$this->config[self::MODE] = $mode;
Expand Down
2 changes: 0 additions & 2 deletions source/FluidXml/FluidXml.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,6 @@ protected function namespace_(...$arguments)
}

$namespaces[] = new FluidNamespace(...$args);
} elseif (\is_array($arguments[0])) {
$namespaces = $arguments[0];
} else {
$namespaces = $arguments;
}
Expand Down
2 changes: 1 addition & 1 deletion source/FluidXml/fluid.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace FluidXml;

define('FLUIDXML_VERSION', '1.20');
define('FLUIDXML_VERSION', '1.20.2');

function fluidxml(...$arguments)
{
Expand Down
50 changes: 4 additions & 46 deletions specs/FluidXml.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,13 @@
});

it('should throw for not existing file', function () {
$err_handler = \set_error_handler(function () {});
try {
$xml = FluidXml::load('.impossible.xml');
} catch (\Exception $e) {
$actual = $e;
}
\set_error_handler($err_handler);

assert_is_a($actual, \Exception::class);
});
Expand Down Expand Up @@ -383,23 +385,6 @@
$expected = $xx_ns;
\assert($actual === $expected, __($actual, $expected));
});

it('should accept an array of namespaces', function () {
$xml = new FluidXml();
$x_ns = new FluidNamespace('x', 'x.com');
$xx_ns = fluidns('xx', 'xx.com', FluidNamespace::MODE_IMPLICIT);

$nss = $xml->namespace([ $x_ns, $xx_ns ])
->namespaces();

$actual = $nss[$x_ns->id()];
$expected = $x_ns;
\assert($actual === $expected, __($actual, $expected));

$actual = $nss[$xx_ns->id()];
$expected = $xx_ns;
\assert($actual === $expected, __($actual, $expected));
});
});

describe('.query()', function () {
Expand Down Expand Up @@ -2210,11 +2195,13 @@ function addchild($parent, $i)
it('should throw for not writable file', function () {
$xml = new FluidXml();

$err_handler = \set_error_handler(function () {});
try {
$xml->save('/.impossible/tmp/out.xml');
} catch (\Exception $e) {
$actual = $e;
}
\set_error_handler($err_handler);

assert_is_a($actual, \Exception::class);
});
Expand Down Expand Up @@ -2521,35 +2508,6 @@ function addchild($parent, $i)
$expected = $ns_mode;
\assert($actual === $expected, __($actual, $expected));
});

it('should accept an array with an id, an uri and an optional mode flag', function () {
$ns_id = 'x';
$ns_uri = 'x.com';
$ns_mode = FluidNamespace::MODE_EXPLICIT;
$args = [ FluidNamespace::ID => $ns_id,
FluidNamespace::URI => $ns_uri ];
$ns = new FluidNamespace($args);

$actual = $ns->id();
$expected = $ns_id;
\assert($actual === $expected, __($actual, $expected));

$actual = $ns->uri();
$expected = $ns_uri;
\assert($actual === $expected, __($actual, $expected));

$actual = $ns->mode();
$expected = $ns_mode;
\assert($actual === $expected, __($actual, $expected));

$ns_mode = FluidNamespace::MODE_IMPLICIT;
$args[FluidNamespace::MODE] = $ns_mode;
$ns = new FluidNamespace($args);

$actual = $ns->mode();
$expected = $ns_mode;
\assert($actual === $expected, __($actual, $expected));
});
});

describe('.id()', function () {
Expand Down
26 changes: 12 additions & 14 deletions support/peridot.php
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
<?php

// use Evenement\EventEmitterInterface;
// use Peridot\Plugin\Watcher\WatcherPlugin;
//
// return function(EventEmitterInterface $emitter) {
// $watcher = new WatcherPlugin($emitter);
// $watcher->track(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'source');
// };

use Evenement\EventEmitterInterface;
use Peridot\Reporter\CodeCoverage\AbstractCodeCoverageReporter;
use Peridot\Reporter\CodeCoverageReporters;
// use Peridot\Plugin\Watcher\WatcherPlugin;

return function (EventEmitterInterface $eventEmitter) {
(new CodeCoverageReporters($eventEmitter))->register();
$eventEmitter->on('error', function ($errn, $msg, $file, $line) {
printf("$file:$line\n");
printf(" $msg\n");
});

// $eventEmitter->on('peridot.start', function (\Peridot\Console\Environment $environment) {
// $environment->getDefinition()->getArgument('path')->setDefault(__DIR__ . '/../specs');
// });

(new CodeCoverageReporters($eventEmitter))->register();
$eventEmitter->on('code-coverage.start', function (AbstractCodeCoverageReporter $reporter) {
/*
$reporter->addDirectoryToWhitelist(__DIR__ . '/../source')
->addFilesToBlacklist([__DIR__ . '/../source/FluidXml.php56.php',
__DIR__ . '/../source/FluidXml.php70.php']);
*/
$reporter->addDirectoryToWhitelist(__DIR__ . '/../source');
// $reporter->addFilesToWhitelist([__DIR__ . '/../source/FluidXml.php']);
// $reporter->addDirectoryToWhitelist(__DIR__ . '/../source')
// ->addFilesToBlacklist([__DIR__ . '/../source/FluidXml.php56.php',
// __DIR__ . '/../source/FluidXml.php70.php']);
});

// $watcher = new WatcherPlugin($eventEmitter);
// $watcher->track(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'source');
};
2 changes: 1 addition & 1 deletion support/tools/speedtest
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env sh

cd "$(dirname "$0")"
. ".common.sh"
. "./.common.sh"
cd ../..

clear
Expand Down
4 changes: 2 additions & 2 deletions support/tools/test
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fi
phpdbg=

if (test $# -ge 1) && (test $1 = 'debug') && chkcmd 'phpdbg'; then
phpdbg=phpdbg
phpdbg="phpdbg -e"
fi

$phpdbg $(which peridot) -g "*.php" "./specs/"
$phpdbg "$(which peridot)" -c "./support/peridot.php" -g "*.php" "./specs/"

0 comments on commit 90d69ee

Please sign in to comment.