-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We use `DOMDocument::registerNodeClass()` to make DOM methods return `JSLikeHTMLElement` instead of `DOMElement`. Unfortunately, it is not possible for PHPStan to detect that so we need to cast it ourselves: phpstan/phpstan#10748 We may want to deprecate it in the future just to get rid of this mess. This also allows us to get rid of the assertions in tests.
- Loading branch information
Showing
4 changed files
with
45 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
// SPDX-FileCopyrightText: 2022 Ondřej Mirtes | ||
// SPDX-License-Identifier: MIT | ||
// Based on https://github.com/phpstan/phpstan-src/blob/b2a9ba4b82d19b01f37eb983746f1840f1213851/stubs/dom.stub | ||
|
||
use Readability\JSLikeHTMLElement; | ||
|
||
class DOMDocument | ||
{ | ||
/** @var JSLikeHTMLElement|null */ | ||
public $documentElement; | ||
|
||
/** @var null */ | ||
public $ownerDocument; | ||
|
||
/** | ||
* @param string $name | ||
* @return DOMNodeList<JSLikeHTMLElement> | ||
*/ | ||
public function getElementsByTagName($name) {} | ||
} | ||
|
||
class DOMNode | ||
{ | ||
|
||
} | ||
|
||
class DOMElement extends DOMNode | ||
{ | ||
/** | ||
* @param string $name | ||
* @return DOMNodeList<JSLikeHTMLElement> | ||
*/ | ||
public function getElementsByTagName($name) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters