mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ImageMap
synced 2024-11-23 22:03:31 +00:00
Remove null fallback from DOMElement::getAttribute
Also set @phan-var to handle nullable parentNode DOMNode::$parentNode is documented as nullable in php8.1 DOMElement::getAttribute is documented to return string in php8.1 Reported by phan running under php8.1 Change-Id: Ia4abd7bf03bc52d7d4ba2c69738bb90c55d01a2b
This commit is contained in:
parent
87731b7e09
commit
9b9ef62a4c
|
@ -317,6 +317,7 @@ class ImageMap implements ParserFirstCallInitHook {
|
|||
// Add a surrounding div, remove the default link to the description page
|
||||
$anchor = $imageNode->parentNode;
|
||||
$parent = $anchor->parentNode;
|
||||
'@phan-var DOMElement $anchor';
|
||||
|
||||
// Handle cases where there are no anchors, like `|link=`
|
||||
if ( $anchor instanceof DOMDocumentFragment ) {
|
||||
|
@ -349,6 +350,7 @@ class ImageMap implements ParserFirstCallInitHook {
|
|||
$anchor = $imageNode->parentNode;
|
||||
$wrapper = $anchor->parentNode;
|
||||
Assert::precondition( $wrapper instanceof DOMElement, 'Anchor node has a parent' );
|
||||
'@phan-var DOMElement $anchor';
|
||||
|
||||
$classes = $wrapper->getAttribute( 'class' );
|
||||
|
||||
|
@ -438,7 +440,7 @@ class ImageMap implements ParserFirstCallInitHook {
|
|||
}
|
||||
} else {
|
||||
'@phan-var DOMElement $wrapper';
|
||||
$typeOf = $wrapper->getAttribute( 'typeof' ) ?? '';
|
||||
$typeOf = $wrapper->getAttribute( 'typeof' );
|
||||
if ( preg_match( '#\bmw:File/Thumb\b#', $typeOf ) ) {
|
||||
// $imageNode was cloned above
|
||||
$img = $imageParent->firstChild;
|
||||
|
|
|
@ -138,10 +138,10 @@ class ParsoidImageMap extends ExtensionTagHandler implements ExtensionModule {
|
|||
// factor when one is much larger than the other
|
||||
// (sx+sy)/(x+y) = s
|
||||
|
||||
$thumbWidth = (int)( $imageNode->getAttribute( 'width' ) ?? '' );
|
||||
$thumbHeight = (int)( $imageNode->getAttribute( 'height' ) ?? '' );
|
||||
$imageWidth = (int)( $imageNode->getAttribute( 'data-file-width' ) ?? '' );
|
||||
$imageHeight = (int)( $imageNode->getAttribute( 'data-file-height' ) ?? '' );
|
||||
$thumbWidth = (int)( $imageNode->getAttribute( 'width' ) );
|
||||
$thumbHeight = (int)( $imageNode->getAttribute( 'height' ) );
|
||||
$imageWidth = (int)( $imageNode->getAttribute( 'data-file-width' ) );
|
||||
$imageHeight = (int)( $imageNode->getAttribute( 'data-file-height' ) );
|
||||
|
||||
$denominator = $imageWidth + $imageHeight;
|
||||
$numerator = $thumbWidth + $thumbHeight;
|
||||
|
@ -207,7 +207,7 @@ class ParsoidImageMap extends ExtensionTagHandler implements ExtensionModule {
|
|||
}
|
||||
DOMUtils::assertElt( $a );
|
||||
|
||||
$href = $a->getAttribute( 'href' ) ?? '';
|
||||
$href = $a->getAttribute( 'href' );
|
||||
$externLink = DOMUtils::matchRel( $a, '#^mw:ExtLink/#D' ) !== null;
|
||||
$alt = '';
|
||||
|
||||
|
@ -323,7 +323,7 @@ class ParsoidImageMap extends ExtensionTagHandler implements ExtensionModule {
|
|||
DOMCompat::getClassList( $thumb )->add( 'noresize' );
|
||||
|
||||
// Determine whether a "magnify" link is present
|
||||
$typeOf = $thumb->getAttribute( 'typeof' ) ?? '';
|
||||
$typeOf = $thumb->getAttribute( 'typeof' );
|
||||
if ( !preg_match( '#\bmw:File/Thumb\b#', $typeOf ) && $descType !== self::NONE ) {
|
||||
// The following classes are used here:
|
||||
// * mw-ext-imagemap-desc-top-right
|
||||
|
|
Loading…
Reference in a new issue