Skip to content

Commit

Permalink
Fix dom_import_simplexml()
Browse files Browse the repository at this point in the history
  • Loading branch information
jack-worman committed Jan 18, 2023
1 parent 396e7fc commit d892edc
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
4 changes: 0 additions & 4 deletions stubs/extensions/dom.phpstub
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ const DOM_NAMESPACE_ERR = 14;
const DOM_INVALID_ACCESS_ERR = 15;
const DOM_VALIDATION_ERR = 16;

function dom_import_simplexml(object $node): ?DOMElement {}
/** @php-from 8.0 */
function dom_import_simplexml(object $node): DOMElement {}

final class DOMException extends Exception
{
public int $code;
Expand Down
36 changes: 36 additions & 0 deletions tests/ExtLibxmlStubTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

declare(strict_types=1);

namespace Psalm\Tests;

use Psalm\Tests\Traits\ValidCodeAnalysisTestTrait;

class ExtLibxmlStubTest extends TestCase
{
use ValidCodeAnalysisTestTrait;

public function providerValidCodeParse(): iterable
{
return [
'dom_import_simplexml, php >=8.0' => [
'code' => <<<'PHP'
<?php
$x = dom_import_simplexml(new SimpleXMLElement(''));
PHP,
'assertions' => ['$x===' => 'DOMElement'],
'ignored_issues' => [],
'php_version' => '8.0',
],
'dom_import_simplexml, php <8.0' => [
'code' => <<<'PHP'
<?php
$x = dom_import_simplexml(new SimpleXMLElement(''));
PHP,
'assertions' => ['$x===' => 'DOMElement|null'],
'ignored_issues' => [],
'php_version' => '7.4',
],
];
}
}

0 comments on commit d892edc

Please sign in to comment.