Ubiquity 2.5.2
php rapid development framework
Loading...
Searching...
No Matches
BaseAnnotation.php
Go to the documentation of this file.
1<?php
3
4use mindplay\annotations\Annotation;
6use Ubiquity\utils\base\UArray;
7
13class BaseAnnotation extends Annotation , BaseAnnotationTrait {
14
15 public function initAnnotation(array $properties) {
16 foreach ( $properties as $name => $value ) {
17 if (\is_array ( $this->$name )) {
18 if (\is_array ( $value )) {
19 foreach ( $value as $k => $v ) {
20 $this->$name [$k] = $v;
21 }
22 } else {
23 $this->$name [] = $value;
24 }
25 } else {
26 $this->$name = $value;
27 }
28 }
29 }
30
31 protected function getDefaultParameters():array{
32 $r=new \ReflectionClass($this);
33 return $r->getDefaultProperties();
34 }
35
36 public function asAnnotation() {
37 return "/**\n * ".$this."\n */";
38 }
39
40 public function __toString() {
41 $fields = $this->getPropertiesAndValues ();
42 $extsStr = UArray::asPhpArray ( $fields );
43 $className = (new \ReflectionClass( $this ))->getShortName();
44 $annotName = \substr ( $className, 0, \strlen ( $className ) - \strlen ( "Annotation" ) );
45 return '@' . \lcfirst ( $annotName ) . $extsStr;
46 }
47}
Ubiquity\annotations$BaseAnnotationTrait This class is part of Ubiquity.