Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PhanTypeMissingReturn on inherited methods with @return never when if a function is reanalyzed and AddNeverReturnTypePlugin is enabled #4537

Closed
Daimona opened this issue Sep 8, 2021 · 0 comments · Fixed by #4538

Comments

@Daimona
Copy link
Member

Daimona commented Sep 8, 2021

Very similar to #4536. The snippet for this one is

<?php

class BaseClass {
	/**
	 * @return never
	 */
	protected function fatalError( $x ) {
		exit();
	}
}

class ChildClass extends BaseClass {
	/**
	 * @return never
	 */
	public function fatalError( $x ) {
		echo implode(['a' => $x]);
		parent::fatalError( $x );
	}

	private function main() {
		$this->fatalError( 42 );
	}
}

test.php:16 PhanTypeMissingReturn Method \ChildClass::fatalError is declared to return never in phpdoc but has no return value

Like for the other issue, fatalError needs to be reanalyzed (hence the parameter without documented types), and AddNeverReturnTypePlugin must be enabled.

TysonAndre added a commit to TysonAndre/phan that referenced this issue Sep 8, 2021
The check was wrong and should have been checking for never returning.
Return statements can be omitted if a function unconditionally exits.

Closes phan#4537
TysonAndre added a commit to TysonAndre/phan that referenced this issue Sep 8, 2021
The check was wrong and should have been checking for never returning.
Return statements can be omitted if a function unconditionally exits.

Closes phan#4537
TysonAndre added a commit to TysonAndre/phan that referenced this issue Sep 8, 2021
The check was wrong and should have been checking for never returning.
Return statements can be omitted if a function unconditionally exits.

Closes phan#4537
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant