0

So my IDE (PHPStorm) complains about $this->assertCount()being dynamic instead of static which would give me static::assertCount().

Is there any benefit to calling assert methods as static instead of dynamic? What is the best practice here? There's no performance gain from what I've seen in a relatively small test suite and using sqlite in memory.

Pixlforge
  • 31
  • 6
  • PHPStorm does not complain about that to me. Perhaps you need to check if it's properly integrating with PHPUnit (i.e. flagging the tests folder as a unit test root and correctly locating the phpunit.xml to use?). Other than that `$this->...` is the documented (and I'm assuming recommended) way to make assertions – apokryfos Dec 13 '17 at 11:16
  • @apokryfos Yes that's what I thought and I'm positive the test folder is flagged as such. – Pixlforge Dec 13 '17 at 11:30
  • Specifically from that other question, [this issue](https://github.com/sebastianbergmann/phpunit/issues/1914) on PHPUnit's issue tracker, which in turn leads to [this section](https://phpunit.de/manual/current/en/appendixes.assertions.html#appendixes.assertions.static-vs-non-static-usage-of-assertion-methods) of the manual – iainn Dec 13 '17 at 11:31
  • Upon closer inspection it turns out that my PHPStorm does not complain about this is because I've probably ran into this problem at some point in the past and have since turned off that warning. – apokryfos Dec 13 '17 at 11:41

0 Answers0