|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This software package is licensed under `AGPL, Commercial` license[s]. |
|
5
|
|
|
* |
|
6
|
|
|
* @package maslosoft/zamm |
|
7
|
|
|
* @license AGPL, Commercial |
|
8
|
|
|
* |
|
9
|
|
|
* @copyright Copyright (c) Peter Maselkowski <[email protected]> |
|
10
|
|
|
* |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace Maslosoft\Zamm; |
|
14
|
|
|
|
|
15
|
|
|
use Maslosoft\Zamm\Helpers\InlineWrapper; |
|
16
|
|
|
use Maslosoft\Zamm\Interfaces\SourceAccessorInterface; |
|
17
|
|
|
use ReflectionClass; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* This simply return names of methods and properties. |
|
21
|
|
|
* This is helper for IDE's. |
|
22
|
|
|
* Use this together with @var type hint. |
|
23
|
|
|
* |
|
24
|
|
|
* @author Piotr Maselkowski <pmaselkowski at gmail.com> |
|
25
|
|
|
*/ |
|
26
|
|
|
class Namer implements SourceAccessorInterface |
|
27
|
|
|
{ |
|
28
|
|
|
|
|
29
|
|
|
use Traits\SourceMagic; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Working class name |
|
33
|
|
|
* @var string |
|
34
|
|
|
*/ |
|
35
|
|
|
private $className = ''; |
|
36
|
|
|
private $info = null; |
|
37
|
|
|
|
|
38
|
|
|
public function __construct($className = null) |
|
39
|
|
|
{ |
|
40
|
|
|
$this->className = $className; |
|
41
|
|
|
$this->info = new ReflectionClass($this->className); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
public function __get($name) |
|
45
|
|
|
{ |
|
46
|
|
|
if($name == 'md' || $name == 'html') |
|
47
|
|
|
{ |
|
48
|
|
|
if(!$this->info->hasProperty($name)) |
|
49
|
|
|
{ |
|
50
|
|
|
return (new InlineWrapper($this->className))->$name; |
|
51
|
|
|
} |
|
52
|
|
|
} |
|
53
|
|
|
return parent::__get($name); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public function method($name) |
|
57
|
|
|
{ |
|
58
|
|
|
assert($this->info->hasMethod($name)); |
|
59
|
|
|
return new InlineWrapper(sprintf('%s::%s()', $this->className, $name)); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
public function property($name) |
|
63
|
|
|
{ |
|
64
|
|
|
assert($this->info->hasProperty($name)); |
|
65
|
|
|
return new InlineWrapper(sprintf('%s::%s', $this->className, $name)); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
public static function __callStatic($name, $arguments) |
|
69
|
|
|
{ |
|
70
|
|
|
return new InlineWrapper(sprintf('%s', $name)); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
public function __toString() |
|
74
|
|
|
{ |
|
75
|
|
|
return $this->className; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
} |
|
79
|
|
|
|