php - What means a class name in constructor of other class? -
I've read some scripts and I do not understand why they named the class in the second class constructor :
Public Function __Composition (AclassName $ foo) {$ this- & gt; Foo = $ foo; }
Because they want that $ foo
is an example There is only one instance of the aclassName
, not an example of a number, string, or class that is not AclassName
and neither does it enter AclassName
. Called in PHP, although they are not actually indicative, but enforcement Function foo (array $ bar) {// $ bar should be an array, otherwise an E_RECOVERABLE_ERROR is thrown} function falcon (class name $ bar) {// $ time classname} For example (new classname); // work fine baz (new stdClass); // Error Category ExtendsFromClassName classname {} baz (new ExtendsFromClassName) extends; // The job is OK
The signal can also be done on the interface or intangible sections:
interface some interface {} function baz (some inter $ object ) {// $ object should be an example of some client that applies someInterface} class Foo applies someInterface {} baz (new Foo); // work fine
Comments
Post a Comment