@@ -68,47 +68,47 @@ |
||
68 | 68 | public function register($sType, $sDirectory, $aOptions) |
69 | 69 | { |
70 | 70 | $sType = trim($sType); |
71 | - if($sType != $this->getName()) |
|
71 | + if ($sType != $this->getName()) |
|
72 | 72 | { |
73 | 73 | return false; |
74 | 74 | } |
75 | 75 | |
76 | - if(!is_string($sDirectory) || !is_dir($sDirectory)) |
|
76 | + if (!is_string($sDirectory) || !is_dir($sDirectory)) |
|
77 | 77 | { |
78 | 78 | throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid-declaration')); |
79 | 79 | } |
80 | - if(is_string($aOptions)) |
|
80 | + if (is_string($aOptions)) |
|
81 | 81 | { |
82 | 82 | $aOptions = ['namespace' => $aOptions]; |
83 | 83 | } |
84 | - if(!is_array($aOptions)) |
|
84 | + if (!is_array($aOptions)) |
|
85 | 85 | { |
86 | 86 | throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid-declaration')); |
87 | 87 | } |
88 | 88 | |
89 | 89 | $sDirectory = rtrim(trim($sDirectory), '/\\'); |
90 | - if(!is_dir($sDirectory)) |
|
90 | + if (!is_dir($sDirectory)) |
|
91 | 91 | { |
92 | 92 | return false; |
93 | 93 | } |
94 | 94 | $aOptions['directory'] = realpath($sDirectory); |
95 | 95 | |
96 | 96 | $sNamespace = key_exists('namespace', $aOptions) ? $aOptions['namespace'] : ''; |
97 | - if(!($sNamespace = trim($sNamespace, ' \\'))) |
|
97 | + if (!($sNamespace = trim($sNamespace, ' \\'))) |
|
98 | 98 | { |
99 | 99 | $sNamespace = ''; |
100 | 100 | } |
101 | 101 | |
102 | 102 | // Change the keys in $aOptions to have "\" as separator |
103 | 103 | $_aOptions = []; |
104 | - foreach($aOptions as $sName => $aOption) |
|
104 | + foreach ($aOptions as $sName => $aOption) |
|
105 | 105 | { |
106 | 106 | $sName = trim(str_replace('.', '\\', $sName), ' \\'); |
107 | 107 | $_aOptions[$sName] = $aOption; |
108 | 108 | } |
109 | 109 | $aOptions = $_aOptions; |
110 | 110 | |
111 | - if(($sNamespace)) |
|
111 | + if (($sNamespace)) |
|
112 | 112 | { |
113 | 113 | $this->xRepository->addNamespace($sNamespace, $aOptions); |
114 | 114 | } |
@@ -111,8 +111,7 @@ |
||
111 | 111 | if(($sNamespace)) |
112 | 112 | { |
113 | 113 | $this->xRepository->addNamespace($sNamespace, $aOptions); |
114 | - } |
|
115 | - else |
|
114 | + } else |
|
116 | 115 | { |
117 | 116 | $this->xRepository->addDirectory($sDirectory, $aOptions); |
118 | 117 | } |
@@ -64,19 +64,19 @@ discard block |
||
64 | 64 | { |
65 | 65 | $this->xRepository = $xRepository; |
66 | 66 | |
67 | - if(!empty($_GET['jxncls'])) |
|
67 | + if (!empty($_GET['jxncls'])) |
|
68 | 68 | { |
69 | 69 | $this->sRequestedClass = trim($_GET['jxncls']); |
70 | 70 | } |
71 | - if(!empty($_GET['jxnmthd'])) |
|
71 | + if (!empty($_GET['jxnmthd'])) |
|
72 | 72 | { |
73 | 73 | $this->sRequestedMethod = trim($_GET['jxnmthd']); |
74 | 74 | } |
75 | - if(!empty($_POST['jxncls'])) |
|
75 | + if (!empty($_POST['jxncls'])) |
|
76 | 76 | { |
77 | 77 | $this->sRequestedClass = trim($_POST['jxncls']); |
78 | 78 | } |
79 | - if(!empty($_POST['jxnmthd'])) |
|
79 | + if (!empty($_POST['jxnmthd'])) |
|
80 | 80 | { |
81 | 81 | $this->sRequestedMethod = trim($_POST['jxnmthd']); |
82 | 82 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | */ |
100 | 100 | public function getTarget() |
101 | 101 | { |
102 | - if(!$this->sRequestedClass || !$this->sRequestedMethod) |
|
102 | + if (!$this->sRequestedClass || !$this->sRequestedMethod) |
|
103 | 103 | { |
104 | 104 | return null; |
105 | 105 | } |
@@ -118,20 +118,20 @@ discard block |
||
118 | 118 | public function register($sType, $sClassName, $aOptions) |
119 | 119 | { |
120 | 120 | $sType = trim($sType); |
121 | - if($sType != $this->getName()) |
|
121 | + if ($sType != $this->getName()) |
|
122 | 122 | { |
123 | 123 | return false; |
124 | 124 | } |
125 | 125 | |
126 | - if(!is_string($sClassName)) |
|
126 | + if (!is_string($sClassName)) |
|
127 | 127 | { |
128 | 128 | throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid-declaration')); |
129 | 129 | } |
130 | - if(is_string($aOptions)) |
|
130 | + if (is_string($aOptions)) |
|
131 | 131 | { |
132 | 132 | $aOptions = ['include' => $aOptions]; |
133 | 133 | } |
134 | - if(!is_array($aOptions)) |
|
134 | + if (!is_array($aOptions)) |
|
135 | 135 | { |
136 | 136 | throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid-declaration')); |
137 | 137 | } |
@@ -154,11 +154,11 @@ discard block |
||
154 | 154 | $aCallableObjects = $this->xRepository->getCallableObjects(); |
155 | 155 | $sHash = ''; |
156 | 156 | |
157 | - foreach($aNamespaces as $sNamespace => $aOptions) |
|
157 | + foreach ($aNamespaces as $sNamespace => $aOptions) |
|
158 | 158 | { |
159 | 159 | $sHash .= $sNamespace . $aOptions['separator']; |
160 | 160 | } |
161 | - foreach($aCallableObjects as $sClassName => $xCallableObject) |
|
161 | + foreach ($aCallableObjects as $sClassName => $xCallableObject) |
|
162 | 162 | { |
163 | 163 | $sHash .= $sClassName . implode('|', $xCallableObject->getMethods()); |
164 | 164 | } |
@@ -183,21 +183,21 @@ discard block |
||
183 | 183 | |
184 | 184 | $xCallableClass = new \ReflectionClass(UserCallableClass::class); |
185 | 185 | $aCallableMethods = []; |
186 | - foreach($xCallableClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $xMethod) |
|
186 | + foreach ($xCallableClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $xMethod) |
|
187 | 187 | { |
188 | 188 | $aCallableMethods[] = $xMethod->getName(); |
189 | 189 | } |
190 | 190 | |
191 | - foreach(array_keys($aNamespaces) as $sNamespace) |
|
191 | + foreach (array_keys($aNamespaces) as $sNamespace) |
|
192 | 192 | { |
193 | 193 | $offset = 0; |
194 | 194 | $sJsNamespace = str_replace('\\', '.', $sNamespace); |
195 | 195 | $sJsNamespace .= '.Null'; // This is a sentinel. The last token is not processed in the while loop. |
196 | - while(($dotPosition = strpos($sJsNamespace, '.', $offset)) !== false) |
|
196 | + while (($dotPosition = strpos($sJsNamespace, '.', $offset)) !== false) |
|
197 | 197 | { |
198 | 198 | $sJsClass = substr($sJsNamespace, 0, $dotPosition); |
199 | 199 | // Generate code for this object |
200 | - if(!key_exists($sJsClass, $aJsClasses)) |
|
200 | + if (!key_exists($sJsClass, $aJsClasses)) |
|
201 | 201 | { |
202 | 202 | $sCode .= "$sPrefix$sJsClass = {};\n"; |
203 | 203 | $aJsClasses[$sJsClass] = $sJsClass; |
@@ -206,17 +206,17 @@ discard block |
||
206 | 206 | } |
207 | 207 | } |
208 | 208 | |
209 | - foreach($aCallableObjects as $sClassName => $xCallableObject) |
|
209 | + foreach ($aCallableObjects as $sClassName => $xCallableObject) |
|
210 | 210 | { |
211 | 211 | $aConfig = $aCallableOptions[$sClassName]; |
212 | 212 | $aCommonConfig = key_exists('*', $aConfig) ? $aConfig['*'] : []; |
213 | 213 | |
214 | 214 | $aProtectedMethods = is_subclass_of($sClassName, UserCallableClass::class) ? $aCallableMethods : []; |
215 | 215 | $aMethods = []; |
216 | - foreach($xCallableObject->getMethods() as $sMethodName) |
|
216 | + foreach ($xCallableObject->getMethods() as $sMethodName) |
|
217 | 217 | { |
218 | 218 | // Don't export methods of the CallableClass class |
219 | - if(in_array($sMethodName, $aProtectedMethods)) |
|
219 | + if (in_array($sMethodName, $aProtectedMethods)) |
|
220 | 220 | { |
221 | 221 | continue; |
222 | 222 | } |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | public function canProcessRequest() |
248 | 248 | { |
249 | 249 | // Check the validity of the class name |
250 | - if(($this->sRequestedClass !== null && !$this->validateClass($this->sRequestedClass)) || |
|
250 | + if (($this->sRequestedClass !== null && !$this->validateClass($this->sRequestedClass)) || |
|
251 | 251 | ($this->sRequestedMethod !== null && !$this->validateMethod($this->sRequestedMethod))) |
252 | 252 | { |
253 | 253 | $this->sRequestedClass = null; |
@@ -263,14 +263,14 @@ discard block |
||
263 | 263 | */ |
264 | 264 | public function processRequest() |
265 | 265 | { |
266 | - if(!$this->canProcessRequest()) |
|
266 | + if (!$this->canProcessRequest()) |
|
267 | 267 | { |
268 | 268 | return false; |
269 | 269 | } |
270 | 270 | |
271 | 271 | // Find the requested method |
272 | 272 | $xCallableObject = $this->xRepository->getCallableObject($this->sRequestedClass); |
273 | - if(!$xCallableObject || !$xCallableObject->hasMethod($this->sRequestedMethod)) |
|
273 | + if (!$xCallableObject || !$xCallableObject->hasMethod($this->sRequestedMethod)) |
|
274 | 274 | { |
275 | 275 | // Unable to find the requested object or method |
276 | 276 | throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid', |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | $di = jaxon()->di(); |
282 | 282 | $aArgs = $di->getRequestHandler()->processArguments(); |
283 | 283 | $xResponse = $xCallableObject->call($this->sRequestedMethod, $aArgs); |
284 | - if(($xResponse)) |
|
284 | + if (($xResponse)) |
|
285 | 285 | { |
286 | 286 | $di->getResponseManager()->append($xResponse); |
287 | 287 | } |
@@ -100,11 +100,11 @@ |
||
100 | 100 | return new Target(self::TYPE_CLASS, '', $sClassName, $sMethodName); |
101 | 101 | } |
102 | 102 | |
103 | - /** |
|
104 | - * Check if the target type is Function. |
|
105 | - * |
|
106 | - * @return bool |
|
107 | - */ |
|
103 | + /** |
|
104 | + * Check if the target type is Function. |
|
105 | + * |
|
106 | + * @return bool |
|
107 | + */ |
|
108 | 108 | public function isFunction() |
109 | 109 | { |
110 | 110 | return $this->sType == self::TYPE_FUNCTION; |
@@ -60,7 +60,7 @@ |
||
60 | 60 | { |
61 | 61 | $this->sDirectory = ''; |
62 | 62 | $this->sExtension = ''; |
63 | - if(key_exists($sNamespace, $this->aDirectories)) |
|
63 | + if (key_exists($sNamespace, $this->aDirectories)) |
|
64 | 64 | { |
65 | 65 | // Make sure there's only one '/' at the end of the string |
66 | 66 | $this->sDirectory = rtrim($this->aDirectories[$sNamespace]['path'], '/') . '/'; |