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

Fix signature compatibility errors detected by phan #3631

Merged
merged 3 commits into from
May 3, 2018

Conversation

driusan
Copy link
Collaborator

@driusan driusan commented May 2, 2018

This increases the coverage of phan to detect incompatible
signatures between parent and child classes. (These are primarily
caused by invalid doc comments, where phan extracts the variable
types from, or previous ambiguity between how to denote something
that returns no value. phan insists on "void", while the codebase
had a mixture of "void", "none", or "null".)

When there's disagreement between a child and parent class about
what the return value should be, this change sides with the parent
(which may not always be correct, but can be fixed in a future
change if any errors are detected.)

This increases the coverage of phan to detect incompatible
signatures between parent and child classes. (These are primarily
caused by invalid doc comments, where phan extracts the variable
types from, or previous ambiguity between how to denote something
that returns no value. phan insists on "void", while the codebase
had a mixture of "void", "none", or "null".)

When there's disagreement between a child and parent class about
what the return value should be, this change sides with the parent
(which may not always be correct, but can be fixed in a future
change if any errors are detected.)
@@ -101,7 +101,7 @@ class Acknowledgements extends \NDB_Menu_Filter_Form
* Sets up all the class variables needed for the
* acknowledgements menu filter
*
* @return true on success
* @return void
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This match the return type definition with parent but in both case, the code always return true. Should be change for @return bool ? while other class derived from the parent return void. Future PR fix?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't change the return type of a child class from the parent class, that's what the signature compatibility checks is checking for.

I can remove the useless return statement from these two functions, but otherwise they'll be caught when "PhanTypeMismatchReturn" is removed from the ignore list. Fixing all the mismatched returns in the codebase is beyond the scope of this PR which is only trying to strengthen the signature compatibility analysis. Adding the PhanTypeMismatchReturn check to this PR would require 269 more changes:

vendor/bin/phan | wc -l
     269

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Fixed these 2 in the latest commit)

Copy link
Contributor

@PapillonMcGill PapillonMcGill May 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@driusan thanks, I just wanted some clarification.

@@ -157,7 +157,7 @@ class Acknowledgements extends \NDB_Menu_Filter_Form
* that are common to every type of page. May be overridden by a specific
* page or specific page type.
*
* @return none
* @return void
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@@ -194,23 +194,23 @@ class Project
* @note If the database value is null then the return value will be the sum of
* all this project's subproject recruitment target.
*
* @return string This project's name
* @return int This project's name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably the scope of another PR but should not that be "@return in This project's target

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I mostly ignored the comments/descriptions I noticed that made my head hurt in this PR for the sake of my sanity.

But I just removed this description entirely (other than the type annotation), since it doesn't really add any value that isn't already in the comment/function name.

Copy link
Contributor

@PapillonMcGill PapillonMcGill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@driusan driusan merged commit 6e47e36 into aces:major May 3, 2018
@ridz1208 ridz1208 added this to the 20.0 milestone May 3, 2018
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 this pull request may close these issues.

3 participants