Page MenuHomePhabricator

MediaWiki.Commenting.FunctionComment.MissingDocumentationPublic false positive
Closed, ResolvedPublicBUG REPORT

Description

https://gerrit.wikimedia.org/r/c/css-sanitizer/+/786402/2/src/Objects/CSSObjectList.php

https://integration.wikimedia.org/ci/job/composer-package-php72-docker/20685/console

23:07:06 FILE: /src/src/Objects/CSSObjectList.php
23:07:06 ----------------------------------------------------------------------
23:07:06 FOUND 1 ERROR AFFECTING 1 LINE
23:07:06 ----------------------------------------------------------------------
23:07:06  172 | ERROR | Missing function doc comment
23:07:06      |       | (MediaWiki.Commenting.FunctionComment.MissingDocumentationPublic)
23:07:06 ----------------------------------------------------------------------

It doesn't seem to complain about

	/** @inheritDoc */
	#[\ReturnTypeWillChange]
	public function key() {
		return $this->offset;
	}

But it does about

	/** @inheritDoc */
	#[\ReturnTypeWillChange]
	public function offsetGet( $offset ) {
		if ( !is_numeric( $offset ) || (float)(int)$offset !== (float)$offset ) {
			throw new InvalidArgumentException( 'Offset must be an integer.' );
		}
		if ( $offset < 0 || $offset > count( $this->objects ) ) {
			throw new OutOfBoundsException( 'Offset is out of range.' );
		}
		return $this->objects[$offset];
	}

Event Timeline

key() doesn't have parameters, but offsetGet() does, and functions that do not start with "get" and have no parameters do not require documentation, per 42f4c82601e70e7a6ec6697253ab2bbae67e93a2

My guess is that key is not complained about since it doesn't need a doc block, but offsetGet() does and the return type will change attribute means that the doc block isn't detected

Change 786408 had a related patch set uploaded (by DannyS712; author: DannyS712):

[mediawiki/tools/codesniffer@master] FunctionCommentSniff: skip T_ATTRIBUTE when checking for doc block

https://gerrit.wikimedia.org/r/786408

Change 786408 merged by jenkins-bot:

[mediawiki/tools/codesniffer@master] FunctionCommentSniff: skip attributes when checking for doc block

https://gerrit.wikimedia.org/r/786408

DannyS712 claimed this task.
DannyS712 moved this task from Untriaged to Accepted rule changes on the MediaWiki-Codesniffer board.
DannyS712 changed the subtype of this task from "Task" to "Bug Report".