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

Static methods called dynamically in documentation #2532

Closed
BenMorel opened this issue Feb 24, 2017 · 4 comments
Closed

Static methods called dynamically in documentation #2532

BenMorel opened this issue Feb 24, 2017 · 4 comments

Comments

@BenMorel
Copy link
Contributor

In PHPUnit, all assertions are static methods:

public static function assertTrue($condition, $message = '')

But the documentation has always suggested to call them dynamically:

$this->assertTrue(false);

And most of the tests I've seen have been following this convention so far (including mine).

It doesn't seem to be a problem for PHP, which doesn't complain in any error reporting mode; but in addition to being a code smell, this approach triggers the static code analysis tools of my IDE, which keeps complaining about static methods called dynamically.

Is there any reason why the documentation shows dynamic calls to the assertion methods?

The whole documentation could be re-written in the following manner:

self::assertTrue(false);

Is there any reason not to?

@sebastianbergmann
Copy link
Owner

This is not a discussion or support forum, sorry.

@BenMorel
Copy link
Contributor Author

This was a preliminary question to offer a contribution to the documentation, but it was seemingly misunderstood.

I wish you well.

@hboomsma
Copy link

@BenMorel see #1914

@BenMorel
Copy link
Contributor Author

@hboomsma Thanks for the pointer!

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

No branches or pull requests

3 participants