diff --git a/includes/ImageMap.php b/includes/ImageMap.php index a1881ea..280ae59 100644 --- a/includes/ImageMap.php +++ b/includes/ImageMap.php @@ -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; diff --git a/includes/ParsoidImageMap.php b/includes/ParsoidImageMap.php index 7857c90..be7dc48 100644 --- a/includes/ParsoidImageMap.php +++ b/includes/ParsoidImageMap.php @@ -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