Ubiquity 2.5.2
php rapid development framework
Loading...
Searching...
No Matches
ReflexionFieldsTrait.php
Go to the documentation of this file.
1<?php
2
3namespace Ubiquity\orm\parser;
4
6
7 abstract public static function getAnnotationMember($class, $member, $annotation);
8
9 abstract public static function getAnnotsEngine();
10
17 protected static function getAnnotationColumnMember($class, $member) {
18 if (($r = self::getAnnotationMember ( $class, $member, 'column' )) === false) {
19 $r = self::getAnnotationMember ( $class, $member, 'joinColumn' );
20 }
21 return $r;
22 }
23
24 public static function getDbType($class, $member) {
25 $ret = self::getAnnotationColumnMember ( $class, $member );
26 if (\is_object ( $ret ) && \property_exists ( $ret, 'dbType' )) {
27 return $ret->dbType;
28 }
29 return false;
30 }
31
32 public static function isSerializable($class, $member) {
33 return self::getAnnotationMember ( $class, $member, 'transient' ) === false
34 && self::getAnnotationMember ( $class, $member, 'manyToOne' ) === false
35 && self::getAnnotationMember ( $class, $member, 'manyToMany' ) === false
36 && self::getAnnotationMember ( $class, $member, 'oneToMany' ) === false;
37 }
38
39 public static function getFieldName($class, $member) {
40 $ret = self::getAnnotationColumnMember ( $class, $member );
41 if ($ret === false || ! isset ( $ret->name )) {
42 $ret = $member;
43 } else {
44 $ret = $ret->name;
45 }
46 return $ret;
47 }
48
49 public static function isNullable($class, $member) {
50 $ret = self::getAnnotationColumnMember ( $class, $member );
51 if (\is_object ( $ret ) && \property_exists ( $ret, 'nullable' )) {
52 return $ret->nullable;
53 }
54 return false;
55 }
56
57 public static function getProperties($class) {
58 $reflect = new \ReflectionClass ( $class );
59 return $reflect->getProperties ();
60 }
61
62 public static function getProperty($instance, $member) {
63 $reflect = new \ReflectionClass ( $instance );
64 $prop = false;
65 if ($reflect->hasProperty ( $member )) {
66 $prop = $reflect->getProperty ( $member );
67 }
68 return $prop;
69 }
70
71 public static function getPropertyType($class, $property) {
72 if (($r = self::getMetadata ( $class, $property, 'var', 'type' )) === false) {
73 $reflect = new \ReflectionProperty ( $class, $property );
74 return $reflect->getType ();
75 }
76 return $r;
77 }
78
79 public static function getMetadata($class, $property, $type, $name) {
80 $a = self::getAnnotsEngine ()->getAnnotsOfProperty ( $class, $property, $type );
81 if (! \count ( $a )) {
82 return false;
83 }
84 return \trim ( $a [0]->$name, ';' );
85 }
86}
87
static getMetadata($class, $property, $type, $name)
static getAnnotationMember($class, $member, $annotation)