Completed
Push — master ( 1cd1d8...dbc4d9 )
by Thierry
02:53
created
src/Factory/Request.php 3 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     public function setClassName($sClass)
41 41
     {
42 42
         $sClass = trim($sClass, '.\\ ');
43
-        if(($sClass))
43
+        if (($sClass))
44 44
         {
45 45
             $xCallable = jaxon()->di()->get($sClass);
46 46
             $this->sPrefix = $this->getOption('core.prefix.class') . $xCallable->getJsName() . '.';
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
         array_shift($aArguments);
84 84
 
85 85
         // Makes legacy code works
86
-        if(strpos($sFunction, '.') !== false)
86
+        if (strpos($sFunction, '.') !== false)
87 87
         {
88 88
             // If there is a dot in the name, then it is a call to a class
89 89
             $this->sPrefix = $this->getOption('core.prefix.class');
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -44,8 +44,7 @@
 block discarded – undo
44 44
         {
45 45
             $xCallable = jaxon()->di()->get($sClass);
46 46
             $this->sPrefix = $this->getOption('core.prefix.class') . $xCallable->getJsName() . '.';
47
-        }
48
-        else
47
+        } else
49 48
         {
50 49
             $this->sPrefix = $this->getOption('core.prefix.function');
51 50
         }
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -5 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
      *
36 36
      * @param string|null            $sClass              The callable class
37 37
      *
38
-     * @return Factory
38
+     * @return Request
39 39
      */
40 40
     public function setClassName($sClass)
41 41
     {
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
      *
59 59
      * @param CallableObject          $xCallable              The callable object
60 60
      *
61
-     * @return Factory
61
+     * @return Request
62 62
      */
63 63
     public function setCallable(CallableObject $xCallable)
64 64
     {
@@ -71,7 +71,6 @@  discard block
 block discarded – undo
71 71
      * Return the javascript call to a Jaxon function or object method
72 72
      *
73 73
      * @param string            $sFunction          The function or method (without class) name
74
-     * @param ...               $xParams            The parameters of the function or method
75 74
      *
76 75
      * @return \Jaxon\Request\Request
77 76
      */
@@ -100,7 +99,6 @@  discard block
 block discarded – undo
100 99
      * Return the javascript call to a generic function
101 100
      *
102 101
      * @param string            $sFunction          The function or method (with class) name
103
-     * @param ...               $xParams            The parameters of the function or method
104 102
      *
105 103
      * @return \Jaxon\Request\Request
106 104
      */
@@ -124,7 +122,6 @@  discard block
 block discarded – undo
124 122
      * @param integer       $nItemsPerPage          The number of items per page page
125 123
      * @param integer       $nCurrentPage           The current page
126 124
      * @param string        $sMethod                The name of function or a method prepended with its class name
127
-     * @param ...           $xParams                The parameters of the function or method
128 125
      *
129 126
      * @return string the pagination links
130 127
      */
Please login to merge, or discard this patch.
src/Request/Plugin/CallableDir.php 2 patches
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -97,68 +97,68 @@  discard block
 block discarded – undo
97 97
      */
98 98
     public function register($sType, $sDirectory, $aOptions)
99 99
     {
100
-        if($sType != $this->getName())
100
+        if ($sType != $this->getName())
101 101
         {
102 102
             return false;
103 103
         }
104 104
 
105
-        if(!is_string($sDirectory) || !is_dir($sDirectory))
105
+        if (!is_string($sDirectory) || !is_dir($sDirectory))
106 106
         {
107 107
             throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid-declaration'));
108 108
         }
109 109
         $sDirectory = trim($sDirectory, DIRECTORY_SEPARATOR);
110 110
         $this->aCallableDirs[] = $sDirectory;
111 111
 
112
-        if(is_string($aOptions))
112
+        if (is_string($aOptions))
113 113
         {
114 114
             $aOptions = ['namespace' => $aOptions];
115 115
         }
116
-        if(!is_array($aOptions))
116
+        if (!is_array($aOptions))
117 117
         {
118 118
             throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid-declaration'));
119 119
         }
120 120
 
121
-        if(!is_dir(($sDirectory = trim($sDirectory))))
121
+        if (!is_dir(($sDirectory = trim($sDirectory))))
122 122
         {
123 123
             return false;
124 124
         }
125 125
 
126 126
         $aProtected = key_exists('protected', $aOptions) ? $aOptions['protected'] : [];
127
-        if(!is_array($aProtected))
127
+        if (!is_array($aProtected))
128 128
         {
129 129
             throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid-declaration'));
130 130
         }
131 131
 
132 132
         $sSeparator = key_exists('separator', $aOptions) ? $aOptions['separator'] : '.';
133 133
         // Only '.' and '_' are allowed to be used as separator. Any other value is ignored and '.' is used instead.
134
-        if(($sSeparator = trim($sSeparator)) != '_')
134
+        if (($sSeparator = trim($sSeparator)) != '_')
135 135
         {
136 136
             $sSeparator = '.';
137 137
         }
138 138
 
139 139
         $sNamespace = key_exists('namespace', $aOptions) ? $aOptions['namespace'] : '';
140
-        if(!($sNamespace = trim($sNamespace, ' \\')))
140
+        if (!($sNamespace = trim($sNamespace, ' \\')))
141 141
         {
142 142
             $sNamespace = '';
143 143
         }
144
-        if(($sNamespace))
144
+        if (($sNamespace))
145 145
         {
146 146
             // If there is an autoloader, register the dir with PSR4 autoloading
147
-            if(($this->xAutoloader))
147
+            if (($this->xAutoloader))
148 148
             {
149 149
                 $this->xAutoloader->setPsr4($sNamespace . '\\', $sDirectory);
150 150
             }
151 151
         }
152
-        elseif(($this->xAutoloader))
152
+        elseif (($this->xAutoloader))
153 153
         {
154 154
             // If there is an autoloader, register the dir with classmap autoloading
155 155
             $itDir = new RecursiveDirectoryIterator($sDirectory);
156 156
             $itFile = new RecursiveIteratorIterator($itDir);
157 157
             // Iterate on dir content
158
-            foreach($itFile as $xFile)
158
+            foreach ($itFile as $xFile)
159 159
             {
160 160
                 // skip everything except PHP files
161
-                if(!$xFile->isFile() || $xFile->getExtension() != 'php')
161
+                if (!$xFile->isFile() || $xFile->getExtension() != 'php')
162 162
                 {
163 163
                     continue;
164 164
                 }
@@ -195,33 +195,33 @@  discard block
 block discarded – undo
195 195
         $sClassPath = substr($xFile->getPath(), strlen($sDirectory));
196 196
         $sClassPath = str_replace($sDS, '\\', trim($sClassPath, $sDS));
197 197
         $sClassName = $xFile->getBasename('.php');
198
-        if(($sNamespace))
198
+        if (($sNamespace))
199 199
         {
200 200
             $sClassPath = ($sClassPath) ? $sNamespace . '\\' . $sClassPath : $sNamespace;
201 201
             $sClassName = '\\' . $sClassPath . '\\' . $sClassName;
202 202
         }
203 203
         // Require the file only if autoload is enabled but there is no autoloader
204
-        if(($this->bAutoloadEnabled) && !($this->xAutoloader))
204
+        if (($this->bAutoloadEnabled) && !($this->xAutoloader))
205 205
         {
206 206
             require_once($xFile->getPathname());
207 207
         }
208 208
         // Create and register an instance of the class
209
-        if(!array_key_exists('*', $aOptions) || !is_array($aOptions['*']))
209
+        if (!array_key_exists('*', $aOptions) || !is_array($aOptions['*']))
210 210
         {
211 211
             $aOptions['*'] = [];
212 212
         }
213 213
         $aOptions['*']['separator'] = $sSeparator;
214
-        if(($sNamespace))
214
+        if (($sNamespace))
215 215
         {
216 216
             $aOptions['*']['namespace'] = $sNamespace;
217 217
         }
218
-        if(($sClassPath))
218
+        if (($sClassPath))
219 219
         {
220 220
             $aOptions['*']['classpath'] = $sClassPath;
221 221
         }
222 222
         // Filter excluded methods
223
-        $aProtected = array_filter($aProtected, function ($sName) {return is_string($sName);});
224
-        if(count($aProtected) > 0)
223
+        $aProtected = array_filter($aProtected, function($sName) {return is_string($sName); });
224
+        if (count($aProtected) > 0)
225 225
         {
226 226
             $aOptions['*']['protected'] = $aProtected;
227 227
         }
@@ -244,13 +244,13 @@  discard block
 block discarded – undo
244 244
         $sDS = DIRECTORY_SEPARATOR;
245 245
         // Change the keys in $aOptions to have "\" as separator
246 246
         $aNewOptions = [];
247
-        foreach($aOptions as $key => $aOption)
247
+        foreach ($aOptions as $key => $aOption)
248 248
         {
249 249
             $key = trim(str_replace(['.', '_'], ['\\', '\\'], $key), ' \\');
250 250
             $aNewOptions[$key] = $aOption;
251 251
         }
252 252
 
253
-        foreach($this->aCallableDirs as $sDirectory => $aDirOptions)
253
+        foreach ($this->aCallableDirs as $sDirectory => $aDirOptions)
254 254
         {
255 255
             // Get the namespace
256 256
             $sNamespace = $aDirOptions['namespace'];
@@ -258,10 +258,10 @@  discard block
 block discarded – undo
258 258
             $itDir = new RecursiveDirectoryIterator($sDirectory);
259 259
             $itFile = new RecursiveIteratorIterator($itDir);
260 260
             // Iterate on dir content
261
-            foreach($itFile as $xFile)
261
+            foreach ($itFile as $xFile)
262 262
             {
263 263
                 // skip everything except PHP files
264
-                if(!$xFile->isFile() || $xFile->getExtension() != 'php')
264
+                if (!$xFile->isFile() || $xFile->getExtension() != 'php')
265 265
                 {
266 266
                     continue;
267 267
                 }
@@ -270,17 +270,17 @@  discard block
 block discarded – undo
270 270
                 $sClassPath = substr($xFile->getPath(), strlen($sDirectory));
271 271
                 $sClassPath = trim(str_replace($sDS, '\\', $sClassPath), '\\');
272 272
                 $sClassName = $xFile->getBasename('.php');
273
-                if(($sClassPath))
273
+                if (($sClassPath))
274 274
                 {
275 275
                     $sClassName = $sClassPath . '\\' . $sClassName;
276 276
                 }
277
-                if(($sNamespace))
277
+                if (($sNamespace))
278 278
                 {
279 279
                     $sClassName = $sNamespace . '\\' . $sClassName;
280 280
                 }
281 281
                 // Get the class options
282 282
                 $aClassOptions = [];
283
-                if(array_key_exists($sClassName, $aNewOptions))
283
+                if (array_key_exists($sClassName, $aNewOptions))
284 284
                 {
285 285
                     $aClassOptions = $aNewOptions[$sClassName];
286 286
                 }
@@ -298,12 +298,12 @@  discard block
 block discarded – undo
298 298
      */
299 299
     public function generateHash()
300 300
     {
301
-        if(count($this->aCallableDirs) == 0)
301
+        if (count($this->aCallableDirs) == 0)
302 302
         {
303 303
             return '';
304 304
         }
305 305
         $sHash = '';
306
-        foreach($this->aCallableDirs as $sDirectory => $aDirOptions)
306
+        foreach ($this->aCallableDirs as $sDirectory => $aDirOptions)
307 307
         {
308 308
             $sHash .= $sDirectory . $aDirOptions['namespace'] . $aDirOptions['separator'];
309 309
         }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -148,8 +148,7 @@
 block discarded – undo
148 148
             {
149 149
                 $this->xAutoloader->setPsr4($sNamespace . '\\', $sDirectory);
150 150
             }
151
-        }
152
-        elseif(($this->xAutoloader))
151
+        } elseif(($this->xAutoloader))
153 152
         {
154 153
             // If there is an autoloader, register the dir with classmap autoloading
155 154
             $itDir = new RecursiveDirectoryIterator($sDirectory);
Please login to merge, or discard this patch.
src/Request/Plugin/CallableClass.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -61,19 +61,19 @@  discard block
 block discarded – undo
61 61
 
62 62
     public function __construct()
63 63
     {
64
-        if(!empty($_GET['jxncls']))
64
+        if (!empty($_GET['jxncls']))
65 65
         {
66 66
             $this->sRequestedClass = $_GET['jxncls'];
67 67
         }
68
-        if(!empty($_GET['jxnmthd']))
68
+        if (!empty($_GET['jxnmthd']))
69 69
         {
70 70
             $this->sRequestedMethod = $_GET['jxnmthd'];
71 71
         }
72
-        if(!empty($_POST['jxncls']))
72
+        if (!empty($_POST['jxncls']))
73 73
         {
74 74
             $this->sRequestedClass = $_POST['jxncls'];
75 75
         }
76
-        if(!empty($_POST['jxnmthd']))
76
+        if (!empty($_POST['jxnmthd']))
77 77
         {
78 78
             $this->sRequestedMethod = $_POST['jxnmthd'];
79 79
         }
@@ -100,39 +100,39 @@  discard block
 block discarded – undo
100 100
      */
101 101
     public function register($sType, $sClassName, $aOptions)
102 102
     {
103
-        if($sType != $this->getName())
103
+        if ($sType != $this->getName())
104 104
         {
105 105
             return false;
106 106
         }
107 107
 
108
-        if(!is_string($sClassName) || !class_exists($sClassName))
108
+        if (!is_string($sClassName) || !class_exists($sClassName))
109 109
         {
110 110
             throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid-declaration'));
111 111
         }
112 112
         $sClassName = trim($sClassName, '\\');
113 113
         $this->aCallableClasses[] = $sClassName;
114 114
 
115
-        if(!is_array($aOptions))
115
+        if (!is_array($aOptions))
116 116
         {
117 117
             throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid-declaration'));
118 118
         }
119 119
 
120 120
         // Save the classpath and the separator in this class
121
-        if(key_exists('*', $aOptions) && is_array($aOptions['*']))
121
+        if (key_exists('*', $aOptions) && is_array($aOptions['*']))
122 122
         {
123 123
             $_aOptions = $aOptions['*'];
124 124
             $sSeparator = '.';
125
-            if(key_exists('separator', $_aOptions))
125
+            if (key_exists('separator', $_aOptions))
126 126
             {
127 127
                 $sSeparator = trim($_aOptions['separator']);
128 128
             }
129
-            if(!in_array($sSeparator, ['.', '_']))
129
+            if (!in_array($sSeparator, ['.', '_']))
130 130
             {
131 131
                 $sSeparator = '.';
132 132
             }
133 133
             $_aOptions['separator'] = $sSeparator;
134 134
 
135
-            if(array_key_exists('classpath', $_aOptions))
135
+            if (array_key_exists('classpath', $_aOptions))
136 136
             {
137 137
                 $_aOptions['classpath'] = trim($_aOptions['classpath'], ' \\._');
138 138
                 // Save classpath with "\" in the parameters
@@ -143,12 +143,12 @@  discard block
 block discarded – undo
143 143
         }
144 144
 
145 145
         // Register the callable object
146
-        jaxon()->di()->set($sClassName, function () use ($sClassName, $aOptions) {
146
+        jaxon()->di()->set($sClassName, function() use ($sClassName, $aOptions) {
147 147
             $xCallableObject = new \Jaxon\Request\Support\CallableObject($sClassName);
148 148
 
149
-            foreach($aOptions as $sMethod => $aValue)
149
+            foreach ($aOptions as $sMethod => $aValue)
150 150
             {
151
-                foreach($aValue as $sName => $sValue)
151
+                foreach ($aValue as $sName => $sValue)
152 152
                 {
153 153
                     $xCallableObject->configure($sMethod, $sName, $sValue);
154 154
                 }
@@ -158,13 +158,13 @@  discard block
 block discarded – undo
158 158
         });
159 159
 
160 160
         // Register the request factory for this callable object
161
-        jaxon()->di()->set($sClassName . '\Factory\Rq', function ($di) use ($sClassName) {
161
+        jaxon()->di()->set($sClassName . '\Factory\Rq', function($di) use ($sClassName) {
162 162
             $xCallableObject = $di->get($sClassName);
163 163
             return new \Jaxon\Factory\Request\Portable($xCallableObject);
164 164
         });
165 165
 
166 166
         // Register the paginator factory for this callable object
167
-        jaxon()->di()->set($sClassName . '\Factory\Pg', function ($di) use ($sClassName) {
167
+        jaxon()->di()->set($sClassName . '\Factory\Pg', function($di) use ($sClassName) {
168 168
             $xCallableObject = $di->get($sClassName);
169 169
             return new \Jaxon\Factory\Request\Paginator($xCallableObject);
170 170
         });
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
     {
182 182
         $di = jaxon()->di();
183 183
         $sHash = '';
184
-        foreach($this->aCallableClasses as $sName)
184
+        foreach ($this->aCallableClasses as $sName)
185 185
         {
186 186
             $xCallableObject = $di->get($sName);
187 187
             $sHash .= $sName . implode('|', $xCallableObject->getMethods());
@@ -201,15 +201,15 @@  discard block
 block discarded – undo
201 201
         // Generate code for javascript objects declaration
202 202
         $sJaxonPrefix = $this->getOption('core.prefix.class');
203 203
         $classes = [];
204
-        foreach($this->aClassPaths as $sClassPath)
204
+        foreach ($this->aClassPaths as $sClassPath)
205 205
         {
206 206
             $offset = 0;
207 207
             $sClassPath .= '.Null'; // This is a sentinel. The last token is not processed in the while loop.
208
-            while(($dotPosition = strpos($sClassPath, '.', $offset)) !== false)
208
+            while (($dotPosition = strpos($sClassPath, '.', $offset)) !== false)
209 209
             {
210 210
                 $class = substr($sClassPath, 0, $dotPosition);
211 211
                 // Generate code for this object
212
-                if(!key_exists($class, $classes))
212
+                if (!key_exists($class, $classes))
213 213
                 {
214 214
                     $code .= "$sJaxonPrefix$class = {};\n";
215 215
                     $classes[$class] = $class;
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 
221 221
         // Generate code for javascript methods
222 222
         $di = jaxon()->di();
223
-        foreach($this->aCallableClasses as $sName)
223
+        foreach ($this->aCallableClasses as $sName)
224 224
         {
225 225
             $xCallableObject = $di->get($sName);
226 226
             $code .= $xCallableObject->getScript();
@@ -236,13 +236,13 @@  discard block
 block discarded – undo
236 236
     public function canProcessRequest()
237 237
     {
238 238
         // Check the validity of the class name
239
-        if(($this->sRequestedClass) && !$this->validateClass($this->sRequestedClass))
239
+        if (($this->sRequestedClass) && !$this->validateClass($this->sRequestedClass))
240 240
         {
241 241
             $this->sRequestedClass = null;
242 242
             $this->sRequestedMethod = null;
243 243
         }
244 244
         // Check the validity of the method name
245
-        if(($this->sRequestedMethod) && !$this->validateMethod($this->sRequestedMethod))
245
+        if (($this->sRequestedMethod) && !$this->validateMethod($this->sRequestedMethod))
246 246
         {
247 247
             $this->sRequestedClass = null;
248 248
             $this->sRequestedMethod = null;
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
      */
258 258
     public function processRequest()
259 259
     {
260
-        if(!$this->canProcessRequest())
260
+        if (!$this->canProcessRequest())
261 261
         {
262 262
             return false;
263 263
         }
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 
267 267
         // Find the requested method
268 268
         $xCallableObject = $this->getCallableObject($this->sRequestedClass);
269
-        if(!$xCallableObject || !$xCallableObject->hasMethod($this->sRequestedMethod))
269
+        if (!$xCallableObject || !$xCallableObject->hasMethod($this->sRequestedMethod))
270 270
         {
271 271
             // Unable to find the requested object or method
272 272
             throw new \Jaxon\Exception\Error($this->trans('errors.objects.invalid',
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
         // at the beginning and the end of the class name.
292 292
         $sClassName = trim(str_replace(['.', '_'], ['\\', '\\'], (string)$sClassName), '\\');
293 293
         // Register an instance of the requested class, if it isn't yet
294
-        if(!key_exists($sClassName, $this->aCallableClasses))
294
+        if (!key_exists($sClassName, $this->aCallableClasses))
295 295
         {
296 296
             $this->getPluginManager()->registerClass($sClassName);
297 297
         }
Please login to merge, or discard this patch.