| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- <?php
- declare(strict_types=1);
- abstract class Abst {
- protected ?int $prop = null;
- abstract function toBeReplaced($tell) : string;
- function tell() {
- echo 'hoi';
- }
- /** property möglich */
- public string $name;
- function setName($name) {
- $this->name = $name;
- }
- function getName() {
- return $this->name;
- }
- public function tellme() : string {
- return 'I tell ' . $this->prop;
- }
- }
- class Normal {
- }
- class AbstChild extends Abst {
- public function toBeReplaced($tell) : string {
- return 'i fill Abst with: ' . $tell;
- }
- function tell() {
- echo 'tschau!';
- }
- static function create(): AbstChild {
- $normal = new AbstChild();
- $normal->prop = 1;
- return $normal;
- }
- }
- $normal = AbstChild::create();
- echo $normal->tellme();
- //die();
- /*
- class NoWorkAbstChild extends Abst {
- public function ifill() : string {
- return "i fill";
- }
- }
- */
- interface AInterface {
- /** Interface kann kein property haben */
- public function toBeReplaced() : string;
- }
- interface AOtherInterface {
- /** Interface kann kein property haben */
- public function toBeReplaced() : string;
- }
- class WithInterface implements AInterface, AOtherInterface {
- public function toBeReplaced(): string {
- return 'i fill interface';
- }
- }
- trait TraitOne {
- public function tellme() {
- echo 'do tell me';
- echo '<br>';
- }
- }
- trait TraitTwo {
- public function listenme() {
- echo 'i listen you';
- echo '<br>';
- }
- }
- class MyMe {
- use TraitOne, TraitTwo;
- /** wenn mehr als 1 Verrerbung nötig */
- }
- $abstchild = new AbstChild();
- $abstchild->setName('AbstName');
- echo $abstchild->toBeReplaced('gugus');
- echo "<br>";
- echo $abstchild->getName();
- echo "<br>";
- $withinterface = new WithInterface();
- echo $withinterface->toBeReplaced();
- echo "<br>";
- $myme = new MyMe();
- $myme->tellme();
- $myme->listenme();
- // $this->tagIds = array_map(fn (NewsTag $t) => $t->getId(), $news->getTags()->getArrayCopy());
|