Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP Upgrade to PHP 7 #5

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/vendor/
/composer.lock
/.phpunit.result.cache
12 changes: 7 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
language: php
php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.2
- 7.3
- 7.4

script: phpunit
install:
- composer install

script: vendor/bin/simple-phpunit
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2012 Groupe Express Roularta
Copyright (c) 2020 Jérôme Tamarelle

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
16 changes: 15 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,26 @@
}
],
"require": {
"php": ">=5.3.0"
"php": ">=7.2.0",
"ext-dom": "*",
"ext-xsl": "*",
"ext-libxml": "*"
},
"suggest": {
"symfony/css-selector": "Provides facilities is you prefers CSS to Xpath"
},
"autoload": {
"psr-0": { "Welldom": "src/" }
},
"autoload-dev": {
"psr-0": { "Welldom\\Tests": "tests/" }
},
"require-dev": {
"symfony/phpunit-bridge": "^5.0"
},
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
}
}
3 changes: 1 addition & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="tests/bootstrap.php"
bootstrap="vendor/autoload.php"
>

<testsuites>
Expand Down
2 changes: 1 addition & 1 deletion src/Welldom/Attr.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of the Welldom package.
*
* (c) Groupe Express Roularta
* (c) Jérôme Tamarelle
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
2 changes: 1 addition & 1 deletion src/Welldom/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of the Welldom package.
*
* (c) Groupe Express Roularta
* (c) Jérôme Tamarelle
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
10 changes: 5 additions & 5 deletions src/Welldom/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of the Welldom package.
*
* (c) Groupe Express Roularta
* (c) Jérôme Tamarelle
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down Expand Up @@ -84,7 +84,7 @@ static public function create($source, $encoding = null, $version = null)
* Factory.
* Create a document from a DOMNode.
*
* @param \Welldom\DOMNode $node
* @param \Welldom\NodeInterface $node
* @param bool $deep When false, $node subtree is not imported.
* @return \Welldom\Document
*/
Expand Down Expand Up @@ -345,7 +345,7 @@ public function createElement($name, $value = null, $namespaceUri = null) {
*/
public function createNode($expression, $value = null, array $attributes = null)
{
$current = ('/' === $expression{0}) ? $this : $this->documentElement;
$current = ('/' === $expression[0]) ? $this : $this->documentElement;
$xpaths = explode('/', str_replace('//', '', $expression));

$i = 0;
Expand Down Expand Up @@ -459,7 +459,7 @@ public function getNodeValue($expression, $default = false)
*
* @param string $expression
* @param string $value
* @return \Welldom\Node
* @return \Welldom\NodeInterface
*/
public function setNodeValue($expression, $value = null)
{
Expand Down Expand Up @@ -530,7 +530,7 @@ public function getNodeInnerXml($expression, $default = false)
* @param string $expression
* @param string $xml
* @param boolean $append
* @return \Welldom\Node
* @return \Welldom\NodeInterface
*/
public function setNodeInnerXml($expression, $xml, $append = false)
{
Expand Down
4 changes: 1 addition & 3 deletions src/Welldom/DocumentFragment.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@
/*
* This file is part of the Welldom package.
*
* (c) Groupe Express Roularta
* (c) Jérôme Tamarelle
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Welldom;

use Welldom\Exception\XmlLoadingException;

/**
* DOM Document Fragment extension.
*
Expand Down
4 changes: 2 additions & 2 deletions src/Welldom/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of the Welldom package.
*
* (c) Groupe Express Roularta
* (c) Jérôme Tamarelle
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down Expand Up @@ -284,7 +284,7 @@ public function toArray($renderRoot = false)
$mValue = $childNode->getValue();
}

$sKey = $childNode->nodeName{0} == '#' ? 0 : $childNode->nodeName;
$sKey = $childNode->nodeName[0] == '#' ? 0 : $childNode->nodeName;

// this will give us a clue as to what the result structure should be
// how many of these child nodes do we have?
Expand Down
2 changes: 1 addition & 1 deletion src/Welldom/Exception/InvalidXpathException.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of the Welldom package.
*
* (c) Groupe Express Roularta
* (c) Jérôme Tamarelle
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
2 changes: 1 addition & 1 deletion src/Welldom/NodeInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of the Welldom package.
*
* (c) Groupe Express Roularta
* (c) Jérôme Tamarelle
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
2 changes: 1 addition & 1 deletion src/Welldom/NodeList.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of the Welldom package.
*
* (c) Groupe Express Roularta
* (c) Jérôme Tamarelle
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
2 changes: 1 addition & 1 deletion src/Welldom/Text.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of the Welldom package.
*
* (c) Groupe Express Roularta
* (c) Jérôme Tamarelle
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
2 changes: 1 addition & 1 deletion src/Welldom/XmlErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of the Welldom package.
*
* (c) Groupe Express Roularta
* (c) Jérôme Tamarelle
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
2 changes: 1 addition & 1 deletion src/Welldom/XmlSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of the Welldom package.
*
* (c) Groupe Express Roularta
* (c) Jérôme Tamarelle
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
4 changes: 2 additions & 2 deletions src/Welldom/Xpath.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of the Welldom package.
*
* (c) Groupe Express Roularta
* (c) Jérôme Tamarelle
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down Expand Up @@ -74,7 +74,7 @@ public function query($expression, \DOMNode $contextnode = null, $registerNodeNS
* @param string $expression Xpath expression
* @param \DOMNode $contextnode
* @param bool $registerNodeNS
* @return \Welldom\Node The node found or FALSE if the number of results is not 1
* @return \Welldom\NodeInterface|false The node found or FALSE if the number of results is not 1
* @throws \Welldom\Exception\InvalidXpathException
*/
public function queryOne($expression, \DOMNode $contextnode = null, $registerNodeNS = true)
Expand Down
6 changes: 3 additions & 3 deletions src/Welldom/XsltProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of the Welldom package.
*
* (c) Groupe Express Roularta
* (c) Jérôme Tamarelle
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down Expand Up @@ -64,7 +64,7 @@ public function transformToXml(\DOMNode $node, array $parameters = array())
{
$this->preTransform($parameters);
$xml = $this->processor->transformToXml($node);
$this->postTransform($parameters);
$this->postTransform();

if (false === $xml) {
return false;
Expand Down Expand Up @@ -166,7 +166,7 @@ public function removeParameter(array $name)
/**
* Removes a list of parameters.
*
* @param type $names List of names
* @param string[] $names List of names
* @return \Welldom\XsltProcessor
*/
public function removeParameters(array $names)
Expand Down
2 changes: 1 addition & 1 deletion src/Welldom/XsltProcessorCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of the Welldom package.
*
* (c) Groupe Express Roularta
* (c) Jérôme Tamarelle
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
25 changes: 0 additions & 25 deletions src/autoload.php

This file was deleted.

10 changes: 7 additions & 3 deletions tests/Welldom/Tests/DocumentFragmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,37 @@
/*
* This file is part of the Welldom package.
*
* (c) Groupe Express Roularta
* (c) Jérôme Tamarelle
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Welldom\Tests;

use PHPUnit\Framework\TestCase;

/**
* @covers \Welldom\DocumentFragment
*/
class DocumentFragmentTest extends TestCase
{
use TestHelpers;

public function testAppendXmlError()
{
$doc = $this->createDocument('<foo />');
$fragment = $doc->createDocumentFragment();

$errors = $fragment->getLastErrors();
$this->assertInternalType('array', $errors);
$this->assertIsArray($errors);
$this->assertCount(0, $errors);

$success = $fragment->appendXML('<invalid att="v><test></invalid>');
$this->assertSame(false, $success);

$errors = $fragment->getLastErrors();
$this->assertInternalType('array', $errors);
$this->assertIsArray($errors);
$this->assertCount(5, $errors);
}

Expand Down
Loading