mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-23 22:45:20 +00:00
Make DataParsoid be a real class
Use @property to provide the types of undeclared variables to Phan and PHPStorm, as in my NodeData patch. Declare $dp->tmp since it is commonly used and does not affect the JSON serialized output since it is always stripped. I omitted the constructor, instead of following the suggestion in the massageLoadedDataParsoid doc comment which proposed injesting a JSON-like data structure in the constructor. I thought it would be more efficient to have the initial property assignments inline in the calling code. This means breaking up many object cast expressions into individual assignments. In IncludeOnly, the coalescing null operator was only handling the case where $start->dataAttribs was unset, which seems unlikely. I made it so that it checks whether $start->dataAttribs->tsr is unset. I added strongly typed clone() methods, to preserve type information for static analysis. DataParsoid is the type of the data in both the DOM and in tokens. To simplify the changes to the Token hierarchy, I removed the duplicate definitions of the public properties $attribs and $dataAttribs. Change-Id: I16172083e7e9bcb94601d1d6862d1d202a7e3660
This commit is contained in:
parent
c0ace40aaa
commit
0cc211d675
|
@ -14,6 +14,7 @@ use Wikimedia\Parsoid\Ext\ExtensionTagHandler;
|
|||
use Wikimedia\Parsoid\Ext\ParsoidExtensionAPI;
|
||||
use Wikimedia\Parsoid\Ext\PHPUtils;
|
||||
use Wikimedia\Parsoid\Ext\WTUtils;
|
||||
use Wikimedia\Parsoid\NodeData\DataParsoid;
|
||||
use Wikimedia\Parsoid\Utils\DOMCompat;
|
||||
|
||||
class References extends ExtensionTagHandler {
|
||||
|
@ -370,7 +371,7 @@ class References extends ExtensionTagHandler {
|
|||
);
|
||||
DOMUtils::addTypeOf( $linkBack, 'mw:Extension/ref' );
|
||||
|
||||
$dataParsoid = new stdClass;
|
||||
$dataParsoid = new DataParsoid;
|
||||
if ( isset( $nodeDp->src ) ) {
|
||||
$dataParsoid->src = $nodeDp->src;
|
||||
}
|
||||
|
@ -507,7 +508,6 @@ class References extends ExtensionTagHandler {
|
|||
} else {
|
||||
unset( $dataMw->body );
|
||||
}
|
||||
// @phan-suppress-next-line PhanTypeObjectUnsetDeclaredProperty
|
||||
unset( $dp->selfClose );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue