1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Nip\Config\Loaders; |
4
|
|
|
|
5
|
|
|
use Nip\Config\Config; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class AbstractLoader |
9
|
|
|
* @package Nip\Config\Loaders |
10
|
|
|
*/ |
11
|
|
|
abstract class AbstractLoader |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* @var string |
15
|
|
|
*/ |
16
|
|
|
protected $path; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @var string |
20
|
|
|
*/ |
21
|
|
|
protected $resolvedPath = null; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @var bool |
25
|
|
|
*/ |
26
|
|
|
protected $useIncludePath = false; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @var bool |
30
|
|
|
*/ |
31
|
|
|
protected $returnConfigObject = false; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Constructor. |
35
|
|
|
* |
36
|
|
|
* @param string $path A path where to look for resources |
37
|
|
|
*/ |
38
|
1 |
|
public function __construct($path) |
39
|
|
|
{ |
40
|
1 |
|
$this->setPath($path); |
41
|
1 |
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @return string |
45
|
|
|
*/ |
46
|
1 |
|
public function getPath() |
47
|
|
|
{ |
48
|
1 |
|
return $this->path; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @param string $path |
53
|
|
|
*/ |
54
|
1 |
|
public function setPath($path) |
55
|
|
|
{ |
56
|
1 |
|
$this->path = $path; |
57
|
1 |
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @return string |
61
|
|
|
*/ |
62
|
1 |
|
public function getResolvedPath() |
63
|
|
|
{ |
64
|
1 |
|
if ($this->resolvedPath === null) { |
65
|
1 |
|
$this->setResolvedPath($this->resolvePath()); |
66
|
|
|
} |
67
|
|
|
|
68
|
1 |
|
return $this->resolvedPath; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @param string $resolvedPath |
73
|
|
|
*/ |
74
|
1 |
|
public function setResolvedPath($resolvedPath) |
75
|
|
|
{ |
76
|
1 |
|
$this->resolvedPath = $resolvedPath; |
77
|
1 |
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @return string |
81
|
|
|
*/ |
82
|
|
|
abstract protected function resolvePath(); |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @return string |
86
|
|
|
*/ |
87
|
1 |
|
public function getResult() |
88
|
|
|
{ |
89
|
1 |
|
$data = $this->getData(); |
90
|
|
|
|
91
|
1 |
|
return ($this->returnConfigObject()) ? new Config($data) : $data; |
|
|
|
|
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @return string |
96
|
|
|
*/ |
97
|
|
|
abstract protected function getData(); |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @return boolean |
101
|
|
|
*/ |
102
|
1 |
|
public function returnConfigObject() |
103
|
|
|
{ |
104
|
1 |
|
return $this->returnConfigObject; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* @param boolean $useIncludePath |
109
|
|
|
*/ |
110
|
1 |
|
public function setUseIncludePath($useIncludePath) |
111
|
|
|
{ |
112
|
1 |
|
$this->useIncludePath = $useIncludePath; |
113
|
1 |
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* @return boolean |
117
|
|
|
*/ |
118
|
|
|
public function useIncludePath() |
119
|
|
|
{ |
120
|
|
|
return $this->useIncludePath; |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @param boolean $returnConfigObject |
125
|
|
|
*/ |
126
|
1 |
|
public function setReturnConfigObject($returnConfigObject) |
127
|
|
|
{ |
128
|
1 |
|
$this->returnConfigObject = $returnConfigObject; |
129
|
1 |
|
} |
130
|
|
|
} |
131
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: