@@ -6,61 +6,61 @@ |
||
6 | 6 | { |
7 | 7 | protected static array $objects = []; |
8 | 8 | |
9 | - public static function add (NetObject $object): void |
|
9 | + public static function add(NetObject $object): void |
|
10 | 10 | { |
11 | - self::$objects[$object->selector] = \WeakReference::create ($object); |
|
11 | + self::$objects[$object->selector] = \WeakReference::create($object); |
|
12 | 12 | } |
13 | 13 | |
14 | - public static function get (int $selector): ?NetObject |
|
14 | + public static function get(int $selector): ?NetObject |
|
15 | 15 | { |
16 | 16 | if (!isset (self::$objects[$selector])) |
17 | 17 | return null; |
18 | 18 | |
19 | - $object = self::$objects[$selector]->get (); |
|
19 | + $object = self::$objects[$selector]->get(); |
|
20 | 20 | |
21 | 21 | if ($object === null) |
22 | - self::remove ($selector); |
|
22 | + self::remove($selector); |
|
23 | 23 | |
24 | 24 | return $object; |
25 | 25 | } |
26 | 26 | |
27 | - public static function exists (int $selector): bool |
|
27 | + public static function exists(int $selector): bool |
|
28 | 28 | { |
29 | 29 | return isset (self::$objects[$selector]); |
30 | 30 | } |
31 | 31 | |
32 | - public static function getObjects (): array |
|
32 | + public static function getObjects(): array |
|
33 | 33 | { |
34 | 34 | return self::$objects; |
35 | 35 | } |
36 | 36 | |
37 | - public static function remove (int $selector): void |
|
37 | + public static function remove(int $selector): void |
|
38 | 38 | { |
39 | 39 | unset (self::$objects[$selector]); |
40 | 40 | } |
41 | 41 | |
42 | - public static function clean (): void |
|
42 | + public static function clean(): void |
|
43 | 43 | { |
44 | 44 | foreach (self::$objects as $selector => $reference) |
45 | - if ($reference->get () === null) |
|
45 | + if ($reference->get() === null) |
|
46 | 46 | unset (self::$objects[$selector]); |
47 | 47 | } |
48 | 48 | } |
49 | 49 | |
50 | -function _c (int $selector): ?NetObject |
|
50 | +function _c(int $selector): ?NetObject |
|
51 | 51 | { |
52 | - return Components::get ($selector); |
|
52 | + return Components::get($selector); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | // TODO: поддержка многоуровневых ссылок вида родитель->родитель->объект |
56 | -function c (string $name): ?NetObject |
|
56 | +function c(string $name): ?NetObject |
|
57 | 57 | { |
58 | - if (is_int ($name) && ($object = _c($name)) !== null) |
|
58 | + if (is_int($name) && ($object = _c($name)) !== null) |
|
59 | 59 | return $object; |
60 | 60 | |
61 | - foreach (Components::getObjects () as $selector => $reference) |
|
61 | + foreach (Components::getObjects() as $selector => $reference) |
|
62 | 62 | { |
63 | - $object = $reference->get (); |
|
63 | + $object = $reference->get(); |
|
64 | 64 | |
65 | 65 | if ($object === null) |
66 | 66 | continue; |