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

Fix errors detected by PHPStan #27

Merged
merged 1 commit into from
Aug 9, 2019
Merged
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
7 changes: 4 additions & 3 deletions src/ApiProblem.php
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ public function asXml(bool $pretty = false)

$this->arrayToXml($this->compile(), $doc);

/** @var \DOMElement */
$dom = dom_import_simplexml($doc);
if ($pretty) {
$dom->ownerDocument->preserveWhiteSpace = false;
Expand Down Expand Up @@ -466,12 +467,12 @@ protected function compile() : array
*
* @param array $data
* The data to add to the element.
* @param \SimpleXmlElement $element
* @param \SimpleXMLElement $element
* The XML object to which to add data.
* @param mixed $parent
* Used for internal recursion only.
*/
protected function arrayToXml(array $data, \SimpleXmlElement $element, $parent = null)
protected function arrayToXml(array $data, \SimpleXMLElement $element, $parent = null)
{
foreach ($data as $key => $value) {
if (is_array($value)) {
Expand All @@ -493,7 +494,7 @@ protected function arrayToXml(array $data, \SimpleXmlElement $element, $parent =
} elseif ($key === 'value') {
$element->{0} = $value;
} elseif (is_bool($value)) {
$element->addChild($key, (int) $value);
$element->addChild($key, strval($value));
} else {
$element->addChild($key, htmlspecialchars((string) $value, ENT_QUOTES));
}
Expand Down
4 changes: 2 additions & 2 deletions src/JsonException.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected static function getExceptionMessage(int $jsonError): string
*
* @param int $jsonError
* the JSON error code.
* @param $failedValue
* @param mixed $failedValue
* The value that failed to parse or encode.
* @return JsonException
* A new exception object.
Expand All @@ -65,7 +65,7 @@ public function __construct(string $message = '', int $code = 0, \Throwable $pre
/**
* Sets the value that failed to parse or encode so it can be analyzed later.
*
* @param $failedValue
* @param mixed $failedValue
* The value that failed to parse or encode correctly.
* @return JsonException
* The invoked object.
Expand Down