Rev 954 | Rev 969 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 954 | Rev 956 | ||
---|---|---|---|
Line 21... | Line 21... | ||
21 | 21 | ||
22 | abstract class OIDplusObject extends OIDplusBaseClass { |
22 | abstract class OIDplusObject extends OIDplusBaseClass { |
23 | const UUID_NAMEBASED_NS_OidPlusMisc = 'ad1654e6-7e15-11e4-9ef6-78e3b5fc7f22'; |
23 | const UUID_NAMEBASED_NS_OidPlusMisc = 'ad1654e6-7e15-11e4-9ef6-78e3b5fc7f22'; |
24 | 24 | ||
25 | public static function parse($node_id) { // please overwrite this function! |
25 | public static function parse($node_id) { // please overwrite this function! |
26 | // TODO: in case we are not calling this class directly, check if function is overwritten and throw exception otherwise |
- | |
27 | foreach (OIDplus::getEnabledObjectTypes() as $ot) { |
26 | foreach (OIDplus::getEnabledObjectTypes() as $ot) { |
28 | try { |
27 | try { |
- | 28 | $good = false; |
|
- | 29 | if (get_parent_class($ot) == 'OIDplusObject') { |
|
- | 30 | $reflector = new \ReflectionMethod($ot, 'parse'); |
|
- | 31 | $isImplemented = ($reflector->getDeclaringClass()->getName() === $ot); |
|
- | 32 | if ($isImplemented) { // avoid endless loop if parse is not overriden |
|
- | 33 | $good = true; |
|
- | 34 | } |
|
- | 35 | } |
|
- | 36 | // We need to do the workaround with "$good", otherwise PHPstan shows |
|
- | 37 | // "Call to an undefined static method object::parse()" |
|
29 | if ($obj = $ot::parse($node_id)) return $obj; |
38 | if ($good && $obj = $ot::parse($node_id)) return $obj; |
30 | } catch (Exception $e) {} |
39 | } catch (Exception $e) {} |
31 | } |
40 | } |
32 | return null; |
41 | return null; |
33 | } |
42 | } |
34 | 43 |