|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the O2System PHP Framework package. |
|
4
|
|
|
* |
|
5
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
6
|
|
|
* file that was distributed with this source code. |
|
7
|
|
|
* |
|
8
|
|
|
* @author Steeve Andrian Salim |
|
9
|
|
|
* @copyright Copyright (c) Steeve Andrian Salim |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
// ------------------------------------------------------------------------ |
|
13
|
|
|
|
|
14
|
|
|
namespace O2System\Reactor\Models\Sql\DataObjects\Result; |
|
15
|
|
|
|
|
16
|
|
|
// ------------------------------------------------------------------------ |
|
17
|
|
|
|
|
18
|
|
|
use O2System\Database; |
|
19
|
|
|
use O2System\Reactor\Models\Sql\Model; |
|
20
|
|
|
use O2System\Spl\DataStructures\SplArrayObject; |
|
21
|
|
|
use O2System\Spl\Info\SplClassInfo; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Class Row |
|
25
|
|
|
* |
|
26
|
|
|
* @package O2System\Reactor\Models\Sql\DataObjects |
|
27
|
|
|
*/ |
|
28
|
|
|
class Row extends SplArrayObject |
|
29
|
|
|
{ |
|
30
|
|
|
/** |
|
31
|
|
|
* Row Model Instance |
|
32
|
|
|
* |
|
33
|
|
|
* @var Model |
|
34
|
|
|
*/ |
|
35
|
|
|
private $model; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Row::__construct |
|
39
|
|
|
* |
|
40
|
|
|
* @param Database\DataObjects\Result\Row|array $row |
|
41
|
|
|
* @param Model $model |
|
42
|
|
|
*/ |
|
43
|
|
|
public function __construct($row, Model &$model) |
|
44
|
|
|
{ |
|
45
|
|
|
$this->model = new SplClassInfo($model); |
|
|
|
|
|
|
46
|
|
|
|
|
47
|
|
|
if ( ! models()->has($this->model->getParameter())) { |
|
48
|
|
|
models()->register($this->model->getParameter(), $model); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
if ($row instanceof Database\DataObjects\Result\Row) { |
|
52
|
|
|
parent::__construct($row->getArrayCopy()); |
|
53
|
|
|
} elseif (is_array($row)) { |
|
|
|
|
|
|
54
|
|
|
parent::__construct($row); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
models($this->model->getParameter())->row = $this; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
// ------------------------------------------------------------------------ |
|
61
|
|
|
|
|
62
|
|
|
public function offsetGet($offset) |
|
63
|
|
|
{ |
|
64
|
|
|
if (null !== ($result = $this->__call($offset))) { |
|
65
|
|
|
return $result; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
return parent::offsetGet($offset); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
// ------------------------------------------------------------------------ |
|
72
|
|
|
|
|
73
|
|
|
public function __call($method, $args = []) |
|
74
|
|
|
{ |
|
75
|
|
|
$model = models($this->model->getParameter()); |
|
|
|
|
|
|
76
|
|
|
|
|
77
|
|
|
if (method_exists($model, $method)) { |
|
78
|
|
|
$model->row = $this; |
|
79
|
|
|
|
|
80
|
|
|
return call_user_func_array([&$model, $method], $args); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
return null; |
|
84
|
|
|
} |
|
85
|
|
|
} |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..