Skip to content

Commit 0ec2c54

Browse files
authored
Version 1.0.2
2 parents 0570c70 + 6b58d0a commit 0ec2c54

File tree

3 files changed

+23
-14
lines changed

3 files changed

+23
-14
lines changed

.travis.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ language: php
44
php:
55
- 7.0
66
- 7.1
7-
- nightly
8-
9-
matrix:
10-
allow_failures:
11-
- php: nightly
127

138
# This triggers builds to run on the new TravisCI infrastructure.
149
# See: http://docs.travis-ci.com/user/workers/container-based-infrastructure/

docs/CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,16 @@
1+
# Version 1.0.2 2017-09-28 - Thanks phpstan!
2+
- After using `phpstan/phpstan` change the execution plan on `CadenaOrigen`.
3+
The function previous function `throwLibXmlErrorOrMessage(string $message)` always
4+
throw an exception but it was not clear in the flow of `build` method.
5+
Now it returns a \RuntimeException and that is thrown. So it is easy for an analysis tool
6+
to know that the flow has been stopped.
7+
- Also fix case of calls `XSLTProcessor::importStylesheet` and `XSLTProcessor::transformToXml`
8+
- Check with `isset` that LibXMLError::$message exists, phpstan was failing for this.
9+
10+
11+
# Version 1.0.1 2017-09-27
12+
- Remove Travis CI PHP nightly builds, it fail with require-dev dependencies.
13+
14+
115
# Version 1.0.0 2017-09-27
216
- Initial release

src/CfdiUtils/CadenaOrigen.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function build(string $cfdiContent, string $xsltLocation = ''): string
4747
// load the cfdi document
4848
$cfdi = new DOMDocument();
4949
if (! $cfdi->loadXML($cfdiContent)) {
50-
$this->throwLibXmlErrorOrMessage('Error while loading the cfdi content');
50+
throw $this->createLibXmlErrorOrMessage('Error while loading the cfdi content');
5151
}
5252

5353
// if not set, obtain default location from document version
@@ -61,18 +61,18 @@ public function build(string $cfdiContent, string $xsltLocation = ''): string
6161

6262
$xsl = new DOMDocument();
6363
if (! $xsl->load($xsltLocation)) {
64-
$this->throwLibXmlErrorOrMessage('Error while loading the Xslt location');
64+
throw $this->createLibXmlErrorOrMessage('Error while loading the Xslt location');
6565
}
6666

6767
$xslt = new XSLTProcessor();
68-
if (! $xslt->importStyleSheet($xsl)) {
69-
$this->throwLibXmlErrorOrMessage('Error while importing the style sheet from the Xslt location');
68+
if (! $xslt->importStylesheet($xsl)) {
69+
throw $this->createLibXmlErrorOrMessage('Error while importing the style sheet from the Xslt location');
7070
}
7171

7272
// this error silenced call is intentional, avoid transformation errors except when return false
73-
$transform = @$xslt->transformToXML($cfdi);
73+
$transform = @$xslt->transformToXml($cfdi);
7474
if (false === $transform || null === $transform) {
75-
$this->throwLibXmlErrorOrMessage('Error while transforming the xslt content');
75+
throw $this->createLibXmlErrorOrMessage('Error while transforming the xslt content');
7676
}
7777

7878
return $transform;
@@ -82,12 +82,12 @@ public function build(string $cfdiContent, string $xsltLocation = ''): string
8282
}
8383
}
8484

85-
private function throwLibXmlErrorOrMessage(string $message)
85+
private function createLibXmlErrorOrMessage(string $message): \Exception
8686
{
8787
$error = libxml_get_last_error();
88-
if ($error instanceof LibXMLError) {
88+
if (($error instanceof LibXMLError) && isset($error->message)) {
8989
$message = $message . ': ' . $error->message;
9090
}
91-
throw new \RuntimeException($message);
91+
return new \RuntimeException($message);
9292
}
9393
}

0 commit comments

Comments
 (0)