-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathReader.php
More file actions
48 lines (38 loc) · 1.18 KB
/
Reader.php
File metadata and controls
48 lines (38 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
/**
* This file is part of Temporal package.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Temporal\Internal\Declaration\Reader;
use Spiral\Attributes\ReaderInterface;
/**
* @template T of object
*/
abstract class Reader
{
private const MAGIC_METHODS = [
'__construct', '__destruct', '__call', '__callStatic', '__get', '__set', '__isset', '__unset', '__sleep',
'__wakeup', '__serialize', '__unserialize', '__toString', '__invoke', '__set_state', '__clone', '__debugInfo',
];
protected ReaderInterface $reader;
public function __construct(ReaderInterface $reader)
{
$this->reader = $reader;
}
/**
* @param class-string $class
* @return array<T>|T
*/
abstract public function fromClass(string $class);
protected function isValidMethod(\ReflectionMethod $method): bool
{
return !$method->isStatic() && $method->isPublic();
}
protected function isMagic(\ReflectionMethod $method): bool
{
return \in_array($method->getName(), self::MAGIC_METHODS, true);
}
}