rspec/rules/S1605/php/rule.adoc
Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

56 lines
1.2 KiB
Plaintext

== Why is this an issue?
In PHP both the way to declare a constructor and the way to make a call to a parent constructor have evolved.
When declaring constructors with the ``++__construct++`` name, nested calls to parent constructors should also use the new ``++__constructor++`` name.
=== Noncompliant code example
[source,php,diff-id=1,diff-type=noncompliant]
----
class Foo extends Bar {
function __construct() {
parent::Bar();
}
}
----
=== Compliant solution
[source,php,diff-id=1,diff-type=compliant]
----
class Foo extends Bar {
function __construct() {
parent::__construct();
}
}
----
== Resources
=== Documentation
* https://www.php.net/manual/en/language.oop5.decon.php[PHP Manual - Constructors and Destructors]
* https://www.phptutorial.net/php-oop/php-call-parent-constructor/[PHP Tutorial - How to Call the Parent Constructor]
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Replace "parent::XXXX(...)" by "parent::__construct(...)".
'''
== Comments And Links
(visible only on this page)
=== on 24 Feb 2014, 15:10:58 Freddy Mallet wrote:
Is implemented by \http://jira.codehaus.org/browse/SONARPLUGINS-3518
endif::env-github,rspecator-view[]