lundi 4 mai 2015

PHPUnit - Use $this or self for static methods?

I don't want to write a long text, cause it is a short questions. PHPUnit mock objects contain several methods that are static. For example all those assert methods and also the identicalTo, equalTo.

My IDE (with IntelliSense/autocompletion) don't accept calls with "$this", but with self. I have learned that static functions should be called through the class, not an object, so "self".

What is more correct now,

$this->assertTrue('test');

or

self::assertTrue('test');

?

(And if "$this" is more correct, can you maybe point out why we should not use "self"?)

Aucun commentaire:

Enregistrer un commentaire