mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 08:58:56 +00:00
singleton is bad example for traits
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@315127 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
cff74cb12a
commit
911156099e
1 changed files with 7 additions and 5 deletions
|
@ -394,15 +394,17 @@ class MyHelloWorld {
|
|||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
trait Singleton {
|
||||
public static function getInstance() { ... }
|
||||
trait StaticExample {
|
||||
public static function doSomething() {
|
||||
return 'Doing something';
|
||||
}
|
||||
}
|
||||
|
||||
class MySingleton extends SomeUnrelatedSuperClass {
|
||||
use Singleton;
|
||||
class Example {
|
||||
use StaticExample;
|
||||
}
|
||||
|
||||
MySingleton::getInstance();
|
||||
Example::doSomething();
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
|
Loading…
Reference in a new issue