rspec/rules/S2014/php/comments-and-links.adoc

32 lines
1.6 KiB
Plaintext

=== on 17 Sep 2014, 10:33:13 Freddy Mallet wrote:
@Ann, if my feeling is correct the "Compliant Code Example" is incorrect because the $name field is not declared as being static. Moreover are you sure that when you call a static method on a class instance, the $this keyword is really correctly interpreted in the body of the static method ? (I'm asking the question because for sure in Java, this is not the case)
=== on 19 Sep 2014, 07:16:47 Ann Campbell wrote:
\[~freddy.mallet] the compliant code example has $name being passed in to the static method as a parameter. I've renamed it to make that clearer. And no, ``++$this++`` doesn't work correctly in a static context.
=== on 12 Oct 2014, 18:17:04 Freddy Mallet wrote:
@Ann, I guess I know why I was a bit lost when discovering this description :
____
But static methods can be accessed without instantiating the class, so it's very possible that there is no class instance at the time the code is executed, resulting in runtime errors.
____
According to this description, sounds like it's possible to access to a class instance from a static function whereas this is indeed not at all possible.
So I would rework the description to prevent any misunderstanding.
=== on 13 Oct 2014, 15:00:43 Linda Martin wrote:
\[~ann.campbell.2] +1 for what Freddy said.
If it can help here is what php interpreter error says: ``++"Fatal error: Using $this when not in object context [...]".++``
=== on 13 Oct 2014, 15:13:12 Ann Campbell wrote:
is this any better [~linda.martin]?
=== on 13 Oct 2014, 17:00:10 Linda Martin wrote:
Yes! Thanks [~ann.campbell.2]!