Ubiquity 2.5.2
php rapid development framework
Loading...
Searching...
No Matches
BaseAttribute.php
Go to the documentation of this file.
1<?php
2
4
6use Ubiquity\utils\base\UArray;
7
15abstract class BaseAttribute extends BaseAnnotationTrait {
16
17 public function __construct() {
18
19 }
20
21 public function asAnnotation(): string {
22 return $this->__toString();
23 }
24
25 public function getNamespace(): string {
26 return (new \ReflectionClass($this))->getNamespaceName();
27 }
28
29 protected function getDefaultParameters(): array {
30 $r = new \ReflectionMethod(get_class($this), '__construct');
31 $result = [];
32 foreach ($r->getParameters() as $param) {
33 if ($param->isOptional() && $param->isDefaultValueAvailable()) {
34 $result[$param->getName()] = $param->getDefaultValue();
35 }
36 }
37 return $result;
38 }
39
40 public function __toString(): string {
41 $fields = $this->getPropertiesAndValues();
42 $extsStr = UArray::asPhpAttribute($fields);
43 $className = (new \ReflectionClass($this))->getShortName();
44 return '#[' . $className . $extsStr . ']';
45 }
46}
47
Ubiquity\annotations$BaseAnnotationTrait This class is part of Ubiquity.
Ubiquity\attributes$BaseAttribute This class is part of Ubiquity.