Passed
Push — main ( 87fed9...27211a )
by Thierry
04:04
created
jaxon-core/src/Script/CallFactory.php 1 patch
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -50,8 +50,7 @@
 block discarded – undo
50 50
     public function rq(string $sClassName = ''): ?JxnCall
51 51
     {
52 52
         $sClassName = trim($sClassName);
53
-        return $sClassName === '' ? $this->cdi->getFunctionRequestFactory() :
54
-            $this->cdi->getComponentRequestFactory($sClassName);
53
+        return $sClassName === '' ? $this->cdi->getFunctionRequestFactory() : $this->cdi->getComponentRequestFactory($sClassName);
55 54
     }
56 55
 
57 56
     /**
Please login to merge, or discard this patch.
jaxon-core/src/Di/ComponentContainer.php 4 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -138,7 +138,7 @@
 block discarded – undo
138 138
      */
139 139
     public function val(string $sKey, $xValue)
140 140
     {
141
-       $this->xContainer->offsetSet($sKey, $xValue);
141
+        $this->xContainer->offsetSet($sKey, $xValue);
142 142
     }
143 143
 
144 144
     /**
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -169,13 +169,13 @@  discard block
 block discarded – undo
169 169
         try
170 170
         {
171 171
             // Make sure the registered class exists
172
-            if(isset($aOptions['include']))
172
+            if (isset($aOptions['include']))
173 173
             {
174 174
                 require_once $aOptions['include'];
175 175
             }
176 176
             $xReflectionClass = new ReflectionClass($sClassName);
177 177
             // Check if the class is registrable
178
-            if(!$xReflectionClass->isInstantiable())
178
+            if (!$xReflectionClass->isInstantiable())
179 179
             {
180 180
                 return;
181 181
             }
@@ -185,12 +185,12 @@  discard block
 block discarded – undo
185 185
             $sClassKey = $this->getReflectionClassKey($sClassName);
186 186
             $this->val($sClassKey, $xReflectionClass);
187 187
             // Register the user class, but only if the user didn't already.
188
-            if(!$this->has($sClassName))
188
+            if (!$this->has($sClassName))
189 189
             {
190 190
                 $this->set($sClassName, fn() => $this->make($this->get($sClassKey)));
191 191
             }
192 192
         }
193
-        catch(ReflectionException $e)
193
+        catch (ReflectionException $e)
194 194
         {
195 195
             throw new SetupException($this->cn()->g(Translator::class)
196 196
                 ->trans('errors.class.invalid', ['name' => $sClassName]));
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 
213 213
         $sComponentObject = $this->getCallableObjectKey($sClassName);
214 214
         // Prevent duplication. It's important not to use the class name here.
215
-        if($this->has($sComponentObject))
215
+        if ($this->has($sComponentObject))
216 216
         {
217 217
             return $sClassName;
218 218
         }
@@ -238,14 +238,14 @@  discard block
 block discarded – undo
238 238
 
239 239
         // Initialize the user class instance
240 240
         $this->xContainer->extend($sClassName, function($xClassInstance) use($sClassName) {
241
-            if($xClassInstance instanceof AbstractComponent)
241
+            if ($xClassInstance instanceof AbstractComponent)
242 242
             {
243 243
                 $xHelper = $this->get($this->getCallableHelperKey($sClassName));
244 244
                 $xHelper->xTarget = $this->xTarget;
245 245
 
246 246
                 // Call the protected "initComponent()" method of the Component class.
247 247
                 $cSetter = function($di, $xHelper) {
248
-                    $this->initComponent($di, $xHelper);  // "$this" here refers to the Component class.
248
+                    $this->initComponent($di, $xHelper); // "$this" here refers to the Component class.
249 249
                 };
250 250
                 $cSetter = $cSetter->bindTo($xClassInstance, $xClassInstance);
251 251
                 call_user_func($cSetter, $this->di, $xHelper);
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
             /** @var CallableObject */
261 261
             $xCallableObject = $this->get($this->getCallableObjectKey($sClassName));
262 262
             $xCallableObject->setDiClassAttributes($xClassInstance);
263
-            if($this->xTarget !== null)
263
+            if ($this->xTarget !== null)
264 264
             {
265 265
                 $sMethodName = $this->xTarget->getMethodName();
266 266
                 $xCallableObject->setDiMethodAttributes($xClassInstance, $sMethodName);
@@ -323,17 +323,17 @@  discard block
 block discarded – undo
323 323
     public function getComponentRequestFactory(string $sClassName): ?JxnCall
324 324
     {
325 325
         $sClassName = trim($sClassName, " \t");
326
-        if($sClassName === '')
326
+        if ($sClassName === '')
327 327
         {
328 328
             return null;
329 329
         }
330 330
 
331 331
         $sFactoryKey = $this->getRequestFactoryKey($sClassName);
332
-        if(!$this->has($sFactoryKey))
332
+        if (!$this->has($sFactoryKey))
333 333
         {
334 334
             $this->xContainer->offsetSet($sFactoryKey, function() use($sClassName) {
335 335
                 $sComponentId = str_replace('\\', '.', $sClassName);
336
-                if(!($xCallable = $this->makeCallableObject($sComponentId)))
336
+                if (!($xCallable = $this->makeCallableObject($sComponentId)))
337 337
                 {
338 338
                     return null;
339 339
                 }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -189,8 +189,7 @@
 block discarded – undo
189 189
             {
190 190
                 $this->set($sClassName, fn() => $this->make($this->get($sClassKey)));
191 191
             }
192
-        }
193
-        catch(ReflectionException $e)
192
+        } catch(ReflectionException $e)
194 193
         {
195 194
             throw new SetupException($this->cn()->g(Translator::class)
196 195
                 ->trans('errors.class.invalid', ['name' => $sClassName]));
Please login to merge, or discard this patch.
Switch Indentation   +204 added lines, -204 removed lines patch added patch discarded remove patch
@@ -39,73 +39,73 @@  discard block
 block discarded – undo
39 39
 
40 40
 class ComponentContainer
41 41
 {
42
-    use Traits\DiAutoTrait;
43
-    use Traits\ComponentTrait;
42
+use Traits\DiAutoTrait;
43
+use Traits\ComponentTrait;
44 44
 
45
-    /**
45
+/**
46 46
      * The Dependency Injection Container for registered classes
47 47
      *
48 48
      * @var PimpleContainer
49 49
      */
50
-    private $xContainer;
50
+private $xContainer;
51 51
 
52
-    /**
52
+/**
53 53
      * This will be set only when getting the object targetted by the ajax request.
54 54
      *
55 55
      * @var Target
56 56
      */
57
-    private $xTarget = null;
57
+private $xTarget = null;
58 58
 
59
-    /**
59
+/**
60 60
      * The class constructor
61 61
      *
62 62
      * @param Container $di
63 63
      */
64
-    public function __construct(private Container $di)
65
-    {
66
-        $this->xContainer = new PimpleContainer();
67
-        $this->val(ComponentContainer::class, $this);
68
-
69
-        // Register the call factory for registered functions
70
-        $this->set($this->getRequestFactoryKey(JxnCall::class), fn() =>
71
-            new JxnCall($this->di->g(ConfigManager::class)
72
-                ->getOption('core.prefix.function', '')));
73
-
74
-        // Register the pagination component, but do not export to js.
75
-        $this->saveComponent(Pagination::class, [
76
-            'excluded' => true,
77
-            'separator' => '.',
78
-            // The namespace has the same name as the Component class.
79
-            'namespace' => Component::class,
80
-        ]);
81
-
82
-        $this->setComponentPublicMethods('node', NodeComponent::class);
83
-        $this->setComponentPublicMethods('func', FuncComponent::class);
84
-    }
64
+public function __construct(private Container $di)
65
+{
66
+$this->xContainer = new PimpleContainer();
67
+$this->val(ComponentContainer::class, $this);
68
+
69
+// Register the call factory for registered functions
70
+$this->set($this->getRequestFactoryKey(JxnCall::class), fn() =>
71
+new JxnCall($this->di->g(ConfigManager::class)
72
+    ->getOption('core.prefix.function', '')));
73
+
74
+// Register the pagination component, but do not export to js.
75
+$this->saveComponent(Pagination::class, [
76
+'excluded' => true,
77
+'separator' => '.',
78
+// The namespace has the same name as the Component class.
79
+'namespace' => Component::class,
80
+]);
81
+
82
+$this->setComponentPublicMethods('node', NodeComponent::class);
83
+$this->setComponentPublicMethods('func', FuncComponent::class);
84
+}
85 85
 
86
-    /**
86
+/**
87 87
      * The container for parameters
88 88
      *
89 89
      * @return Container
90 90
      */
91
-    protected function cn(): Container
92
-    {
93
-        return $this->di;
94
-    }
91
+protected function cn(): Container
92
+{
93
+return $this->di;
94
+}
95 95
 
96
-    /**
96
+/**
97 97
      * Check if a class is defined in the container
98 98
      *
99 99
      * @param class-string $sClass    The full class name
100 100
      *
101 101
      * @return bool
102 102
      */
103
-    public function has(string $sClass): bool
104
-    {
105
-        return $this->xContainer->offsetExists($sClass);
106
-    }
103
+public function has(string $sClass): bool
104
+{
105
+return $this->xContainer->offsetExists($sClass);
106
+}
107 107
 
108
-    /**
108
+/**
109 109
      * Save a closure in the container
110 110
      *
111 111
      * @param class-string $sClass    The full class name
@@ -113,12 +113,12 @@  discard block
 block discarded – undo
113 113
      *
114 114
      * @return void
115 115
      */
116
-    public function set(string $sClass, Closure $xClosure)
117
-    {
118
-        $this->xContainer->offsetSet($sClass, fn() => $xClosure($this));
119
-    }
116
+public function set(string $sClass, Closure $xClosure)
117
+{
118
+$this->xContainer->offsetSet($sClass, fn() => $xClosure($this));
119
+}
120 120
 
121
-    /**
121
+/**
122 122
      * Save a value in the container
123 123
      *
124 124
      * @param string|class-string $sKey    The key
@@ -126,12 +126,12 @@  discard block
 block discarded – undo
126 126
      *
127 127
      * @return void
128 128
      */
129
-    public function val(string $sKey, $xValue)
130
-    {
131
-       $this->xContainer->offsetSet($sKey, $xValue);
132
-    }
129
+public function val(string $sKey, $xValue)
130
+{
131
+$this->xContainer->offsetSet($sKey, $xValue);
132
+}
133 133
 
134
-    /**
134
+/**
135 135
      * Get a class instance
136 136
      *
137 137
      * @template T
@@ -139,12 +139,12 @@  discard block
 block discarded – undo
139 139
      *
140 140
      * @return T
141 141
      */
142
-    public function get(string $sClass)
143
-    {
144
-        return $this->xContainer->offsetGet($sClass);
145
-    }
142
+public function get(string $sClass)
143
+{
144
+return $this->xContainer->offsetGet($sClass);
145
+}
146 146
 
147
-    /**
147
+/**
148 148
      * Get a component when one of its method needs to be called
149 149
      *
150 150
      * @template T
@@ -153,17 +153,17 @@  discard block
 block discarded – undo
153 153
      *
154 154
      * @return T|null
155 155
      */
156
-    public function getTargetComponent(string $sClassName, Target $xTarget): mixed
157
-    {
158
-        // Set the target only when getting the object targetted by the ajax request.
159
-        $this->xTarget = $xTarget;
160
-        $xComponent = $this->get($sClassName);
161
-        $this->xTarget = null;
156
+public function getTargetComponent(string $sClassName, Target $xTarget): mixed
157
+{
158
+// Set the target only when getting the object targetted by the ajax request.
159
+$this->xTarget = $xTarget;
160
+$xComponent = $this->get($sClassName);
161
+$this->xTarget = null;
162 162
 
163
-        return $xComponent;
164
-    }
163
+return $xComponent;
164
+}
165 165
 
166
-    /**
166
+/**
167 167
      * Register a component and its options
168 168
      *
169 169
      * @param class-string $sClassName    The class name
@@ -171,40 +171,40 @@  discard block
 block discarded – undo
171 171
      *
172 172
      * @return void
173 173
      */
174
-    public function saveComponent(string $sClassName, array $aOptions): void
175
-    {
176
-        try
177
-        {
178
-            // Make sure the registered class exists
179
-            if(isset($aOptions['include']))
180
-            {
181
-                require_once $aOptions['include'];
182
-            }
183
-            $xReflectionClass = new ReflectionClass($sClassName);
184
-            // Check if the class is registrable
185
-            if(!$xReflectionClass->isInstantiable())
186
-            {
187
-                return;
188
-            }
189
-
190
-            $this->_saveClassOptions($sClassName, $aOptions);
191
-
192
-            $sClassKey = $this->getReflectionClassKey($sClassName);
193
-            $this->val($sClassKey, $xReflectionClass);
194
-            // Register the user class, but only if the user didn't already.
195
-            if(!$this->has($sClassName))
196
-            {
197
-                $this->set($sClassName, fn() => $this->make($this->get($sClassKey)));
198
-            }
199
-        }
200
-        catch(ReflectionException $e)
201
-        {
202
-            throw new SetupException($this->cn()->g(Translator::class)
203
-                ->trans('errors.class.invalid', ['name' => $sClassName]));
204
-        }
205
-    }
174
+public function saveComponent(string $sClassName, array $aOptions): void
175
+{
176
+try
177
+{
178
+// Make sure the registered class exists
179
+if(isset($aOptions['include']))
180
+{
181
+    require_once $aOptions['include'];
182
+}
183
+$xReflectionClass = new ReflectionClass($sClassName);
184
+// Check if the class is registrable
185
+if(!$xReflectionClass->isInstantiable())
186
+{
187
+    return;
188
+}
189
+
190
+$this->_saveClassOptions($sClassName, $aOptions);
206 191
 
207
-    /**
192
+$sClassKey = $this->getReflectionClassKey($sClassName);
193
+$this->val($sClassKey, $xReflectionClass);
194
+// Register the user class, but only if the user didn't already.
195
+if(!$this->has($sClassName))
196
+{
197
+    $this->set($sClassName, fn() => $this->make($this->get($sClassKey)));
198
+}
199
+}
200
+catch(ReflectionException $e)
201
+{
202
+throw new SetupException($this->cn()->g(Translator::class)
203
+    ->trans('errors.class.invalid', ['name' => $sClassName]));
204
+}
205
+}
206
+
207
+/**
208 208
      * Register a component
209 209
      *
210 210
      * @param string $sComponentId The component name
@@ -212,74 +212,74 @@  discard block
 block discarded – undo
212 212
      * @return string
213 213
      * @throws SetupException
214 214
      */
215
-    private function _registerComponent(string $sComponentId): string
216
-    {
217
-        // Replace all separators ('.' or '_') with antislashes, and trim the class name.
218
-        $sClassName = trim(str_replace(['.', '_'], '\\', $sComponentId), '\\');
219
-
220
-        $sComponentObject = $this->getCallableObjectKey($sClassName);
221
-        // Prevent duplication. It's important not to use the class name here.
222
-        if($this->has($sComponentObject))
223
-        {
224
-            return $sClassName;
225
-        }
226
-
227
-        // Register the helper class
228
-        $this->set($this->getCallableHelperKey($sClassName), function() use($sClassName) {
229
-            $xFactory = $this->di->getCallFactory();
230
-            return new ComponentHelper($this, $xFactory->rq($sClassName),
231
-                $xFactory, $this->di->getViewRenderer(),
232
-                $this->di->getLogger(), $this->di->getSessionManager(),
233
-                $this->di->getStash(), $this->di->getUploadHandler());
234
-        });
235
-
236
-        $this->discoverComponent($sClassName);
237
-
238
-        // Register the callable object
239
-        $this->set($sComponentObject, function() use($sComponentId, $sClassName) {
240
-            $aOptions = $this->_getClassOptions($sComponentId);
241
-            $xReflectionClass = $this->get($this->getReflectionClassKey($sClassName));
242
-            $xOptions = $this->getComponentOptions($xReflectionClass, $aOptions);
243
-            return new CallableObject($this, $this->di, $xReflectionClass, $xOptions);
244
-        });
245
-
246
-        // Initialize the user class instance
247
-        $this->xContainer->extend($sClassName, function($xClassInstance) use($sClassName) {
248
-            if($xClassInstance instanceof AbstractComponent)
249
-            {
250
-                $xHelper = $this->get($this->getCallableHelperKey($sClassName));
251
-                $xHelper->xTarget = $this->xTarget;
252
-
253
-                // Call the protected "initComponent()" method of the Component class.
254
-                $cSetter = function($di, $xHelper) {
255
-                    $this->initComponent($di, $xHelper);  // "$this" here refers to the Component class.
256
-                };
257
-                $cSetter = $cSetter->bindTo($xClassInstance, $xClassInstance);
258
-                call_user_func($cSetter, $this->di, $xHelper);
259
-            }
260
-
261
-            // Run the callbacks for class initialisation
262
-            $this->di->g(CallbackManager::class)->onInit($xClassInstance);
263
-
264
-            // Set attributes from the DI container.
265
-            // The class level DI options are set on any component.
266
-            // The method level DI options are set only on the targetted component.
267
-            /** @var CallableObject */
268
-            $xCallableObject = $this->get($this->getCallableObjectKey($sClassName));
269
-            $xCallableObject->setDiClassAttributes($xClassInstance);
270
-            if($this->xTarget !== null)
271
-            {
272
-                $sMethodName = $this->xTarget->getMethodName();
273
-                $xCallableObject->setDiMethodAttributes($xClassInstance, $sMethodName);
274
-            }
275
-
276
-            return $xClassInstance;
277
-        });
278
-
279
-        return $sClassName;
280
-    }
215
+private function _registerComponent(string $sComponentId): string
216
+{
217
+// Replace all separators ('.' or '_') with antislashes, and trim the class name.
218
+$sClassName = trim(str_replace(['.', '_'], '\\', $sComponentId), '\\');
219
+
220
+$sComponentObject = $this->getCallableObjectKey($sClassName);
221
+// Prevent duplication. It's important not to use the class name here.
222
+if($this->has($sComponentObject))
223
+{
224
+return $sClassName;
225
+}
226
+
227
+// Register the helper class
228
+$this->set($this->getCallableHelperKey($sClassName), function() use($sClassName) {
229
+$xFactory = $this->di->getCallFactory();
230
+return new ComponentHelper($this, $xFactory->rq($sClassName),
231
+    $xFactory, $this->di->getViewRenderer(),
232
+    $this->di->getLogger(), $this->di->getSessionManager(),
233
+    $this->di->getStash(), $this->di->getUploadHandler());
234
+});
235
+
236
+$this->discoverComponent($sClassName);
237
+
238
+// Register the callable object
239
+$this->set($sComponentObject, function() use($sComponentId, $sClassName) {
240
+$aOptions = $this->_getClassOptions($sComponentId);
241
+$xReflectionClass = $this->get($this->getReflectionClassKey($sClassName));
242
+$xOptions = $this->getComponentOptions($xReflectionClass, $aOptions);
243
+return new CallableObject($this, $this->di, $xReflectionClass, $xOptions);
244
+});
245
+
246
+// Initialize the user class instance
247
+$this->xContainer->extend($sClassName, function($xClassInstance) use($sClassName) {
248
+if($xClassInstance instanceof AbstractComponent)
249
+{
250
+    $xHelper = $this->get($this->getCallableHelperKey($sClassName));
251
+    $xHelper->xTarget = $this->xTarget;
252
+
253
+    // Call the protected "initComponent()" method of the Component class.
254
+    $cSetter = function($di, $xHelper) {
255
+        $this->initComponent($di, $xHelper);  // "$this" here refers to the Component class.
256
+    };
257
+    $cSetter = $cSetter->bindTo($xClassInstance, $xClassInstance);
258
+    call_user_func($cSetter, $this->di, $xHelper);
259
+}
260
+
261
+// Run the callbacks for class initialisation
262
+$this->di->g(CallbackManager::class)->onInit($xClassInstance);
263
+
264
+// Set attributes from the DI container.
265
+// The class level DI options are set on any component.
266
+// The method level DI options are set only on the targetted component.
267
+/** @var CallableObject */
268
+$xCallableObject = $this->get($this->getCallableObjectKey($sClassName));
269
+$xCallableObject->setDiClassAttributes($xClassInstance);
270
+if($this->xTarget !== null)
271
+{
272
+    $sMethodName = $this->xTarget->getMethodName();
273
+    $xCallableObject->setDiMethodAttributes($xClassInstance, $sMethodName);
274
+}
275
+
276
+return $xClassInstance;
277
+});
281 278
 
282
-    /**
279
+return $sClassName;
280
+}
281
+
282
+/**
283 283
      * Get the callable object for a given class
284 284
      * The callable object is registered if it is not already in the DI.
285 285
      *
@@ -288,13 +288,13 @@  discard block
 block discarded – undo
288 288
      * @return CallableObject|null
289 289
      * @throws SetupException
290 290
      */
291
-    public function makeCallableObject(string $sComponentId): ?CallableObject
292
-    {
293
-        $sClassName = $this->_registerComponent($sComponentId);
294
-        return $this->get($this->getCallableObjectKey($sClassName));
295
-    }
291
+public function makeCallableObject(string $sComponentId): ?CallableObject
292
+{
293
+$sClassName = $this->_registerComponent($sComponentId);
294
+return $this->get($this->getCallableObjectKey($sClassName));
295
+}
296 296
 
297
-    /**
297
+/**
298 298
      * Get an instance of a component by name
299 299
      *
300 300
      * @template T
@@ -303,53 +303,53 @@  discard block
 block discarded – undo
303 303
      * @return T|null
304 304
      * @throws SetupException
305 305
      */
306
-    public function makeComponent(string $sClassName): mixed
307
-    {
308
-        $sComponentId = str_replace('\\', '.', $sClassName);
309
-        $sClassName = $this->_registerComponent($sComponentId);
310
-        return $this->get($sClassName);
311
-    }
306
+public function makeComponent(string $sClassName): mixed
307
+{
308
+$sComponentId = str_replace('\\', '.', $sClassName);
309
+$sClassName = $this->_registerComponent($sComponentId);
310
+return $this->get($sClassName);
311
+}
312 312
 
313
-    /**
313
+/**
314 314
      * Get a factory for a call to a registered function.
315 315
      *
316 316
      * @return JxnCall
317 317
      */
318
-    public function getFunctionRequestFactory(): JxnCall
319
-    {
320
-        return $this->get($this->getRequestFactoryKey(JxnCall::class));
321
-    }
318
+public function getFunctionRequestFactory(): JxnCall
319
+{
320
+return $this->get($this->getRequestFactoryKey(JxnCall::class));
321
+}
322 322
 
323
-    /**
323
+/**
324 324
      * Get a factory for a call to a registered component.
325 325
      *
326 326
      * @param class-string $sClassName
327 327
      *
328 328
      * @return JxnCall|null
329 329
      */
330
-    public function getComponentRequestFactory(string $sClassName): ?JxnCall
330
+public function getComponentRequestFactory(string $sClassName): ?JxnCall
331
+{
332
+$sClassName = trim($sClassName, " \t");
333
+if($sClassName === '')
334
+{
335
+return null;
336
+}
337
+
338
+$sFactoryKey = $this->getRequestFactoryKey($sClassName);
339
+if(!$this->has($sFactoryKey))
340
+{
341
+$this->xContainer->offsetSet($sFactoryKey, function() use($sClassName) {
342
+    $sComponentId = str_replace('\\', '.', $sClassName);
343
+    if(!($xCallable = $this->makeCallableObject($sComponentId)))
331 344
     {
332
-        $sClassName = trim($sClassName, " \t");
333
-        if($sClassName === '')
334
-        {
335
-            return null;
336
-        }
337
-
338
-        $sFactoryKey = $this->getRequestFactoryKey($sClassName);
339
-        if(!$this->has($sFactoryKey))
340
-        {
341
-            $this->xContainer->offsetSet($sFactoryKey, function() use($sClassName) {
342
-                $sComponentId = str_replace('\\', '.', $sClassName);
343
-                if(!($xCallable = $this->makeCallableObject($sComponentId)))
344
-                {
345
-                    return null;
346
-                }
347
-
348
-                $xConfigManager = $this->di->g(ConfigManager::class);
349
-                $sPrefix = $xConfigManager->getOption('core.prefix.class', '');
350
-                return new JxnClassCall($sPrefix . $xCallable->getJsName());
351
-            });
352
-        }
353
-        return $this->get($sFactoryKey);
345
+        return null;
354 346
     }
347
+
348
+    $xConfigManager = $this->di->g(ConfigManager::class);
349
+    $sPrefix = $xConfigManager->getOption('core.prefix.class', '');
350
+    return new JxnClassCall($sPrefix . $xCallable->getJsName());
351
+});
352
+}
353
+return $this->get($sFactoryKey);
354
+}
355 355
 }
Please login to merge, or discard this patch.
jaxon-core/src/App/Metadata/MetadataCache.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -51,12 +51,12 @@
 block discarded – undo
51 51
         $sMetadataVar = '$xMetadata';
52 52
         $sDataVar = '$xData';
53 53
         $aCalls = ["$sMetadataVar = new " . Metadata::class . '();'];
54
-        foreach($xMetadata->getAttributes() as $sType => $aValues)
54
+        foreach ($xMetadata->getAttributes() as $sType => $aValues)
55 55
         {
56
-            foreach($aValues as $sMethod => $xData)
56
+            foreach ($aValues as $sMethod => $xData)
57 57
             {
58 58
                 $aCalls[] = "$sDataVar = {$sMetadataVar}->{$sType}('{$sMethod}');";
59
-                foreach($xData->encode($sDataVar) as $sCall)
59
+                foreach ($xData->encode($sDataVar) as $sCall)
60 60
                 {
61 61
                     $aCalls[] = $sCall;
62 62
                 }
Please login to merge, or discard this patch.
Switch Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -28,60 +28,60 @@  discard block
 block discarded – undo
28 28
 
29 29
 class MetadataCache
30 30
 {
31
-    /**
31
+/**
32 32
      * @param string $sCacheDir
33 33
      */
34
-    public function __construct(private string $sCacheDir)
35
-    {}
34
+public function __construct(private string $sCacheDir)
35
+{}
36 36
 
37
-    /**
37
+/**
38 38
      * @param string $sClass
39 39
      *
40 40
      * @return string
41 41
      */
42
-    private function filepath(string $sClass): string
43
-    {
44
-        $sFilename = trim(str_replace(['\\', '.'], DIRECTORY_SEPARATOR,
45
-            strtolower($sClass)), DIRECTORY_SEPARATOR);
46
-        return rtrim($this->sCacheDir, "/\\") . DIRECTORY_SEPARATOR .
47
-            "metadata" . DIRECTORY_SEPARATOR . "{$sFilename}.php";
48
-    }
42
+private function filepath(string $sClass): string
43
+{
44
+$sFilename = trim(str_replace(['\\', '.'], DIRECTORY_SEPARATOR,
45
+strtolower($sClass)), DIRECTORY_SEPARATOR);
46
+return rtrim($this->sCacheDir, "/\\") . DIRECTORY_SEPARATOR .
47
+"metadata" . DIRECTORY_SEPARATOR . "{$sFilename}.php";
48
+}
49 49
 
50
-    /**
50
+/**
51 51
      * Generate the PHP code to create a metadata object.
52 52
      *
53 53
      * @return array
54 54
      */
55
-    private function encode(Metadata $xMetadata): array
55
+private function encode(Metadata $xMetadata): array
56
+{
57
+$sMetadataVar = '$xMetadata';
58
+$sDataVar = '$xData';
59
+$aCalls = ["$sMetadataVar = new " . Metadata::class . '();'];
60
+foreach($xMetadata->getAttributes() as $sType => $aValues)
61
+{
62
+foreach($aValues as $sMethod => $xData)
63
+{
64
+    $aCalls[] = "$sDataVar = {$sMetadataVar}->{$sType}('{$sMethod}');";
65
+    foreach($xData->encode($sDataVar) as $sCall)
56 66
     {
57
-        $sMetadataVar = '$xMetadata';
58
-        $sDataVar = '$xData';
59
-        $aCalls = ["$sMetadataVar = new " . Metadata::class . '();'];
60
-        foreach($xMetadata->getAttributes() as $sType => $aValues)
61
-        {
62
-            foreach($aValues as $sMethod => $xData)
63
-            {
64
-                $aCalls[] = "$sDataVar = {$sMetadataVar}->{$sType}('{$sMethod}');";
65
-                foreach($xData->encode($sDataVar) as $sCall)
66
-                {
67
-                    $aCalls[] = $sCall;
68
-                }
69
-            }
70
-        }
71
-        $aCalls[] = "return $sMetadataVar;";
72
-        return $aCalls;
67
+        $aCalls[] = $sCall;
73 68
     }
69
+}
70
+}
71
+$aCalls[] = "return $sMetadataVar;";
72
+return $aCalls;
73
+}
74 74
 
75
-    /**
75
+/**
76 76
      * @param string $sClass
77 77
      * @param Metadata $xMetadata
78 78
      *
79 79
      * @return void
80 80
      */
81
-    public function save(string $sClass, Metadata $xMetadata): void
82
-    {
83
-        $sDataCode = implode("\n    ", $this->encode($xMetadata));
84
-        $sPhpCode = <<<CODE
81
+public function save(string $sClass, Metadata $xMetadata): void
82
+{
83
+$sDataCode = implode("\n    ", $this->encode($xMetadata));
84
+$sPhpCode = <<<CODE
85 85
 <?php
86 86
 
87 87
 return function() {
@@ -89,21 +89,21 @@  discard block
 block discarded – undo
89 89
 };
90 90
 
91 91
 CODE;
92
-        // Recursively create the directories.
93
-        $sPath = $this->filepath($sClass);
94
-        @mkdir(dirname($sPath), 0755, true);
95
-        file_put_contents($sPath, $sPhpCode);
96
-    }
92
+// Recursively create the directories.
93
+$sPath = $this->filepath($sClass);
94
+@mkdir(dirname($sPath), 0755, true);
95
+file_put_contents($sPath, $sPhpCode);
96
+}
97 97
 
98
-    /**
98
+/**
99 99
      * @param string $sClass
100 100
      *
101 101
      * @return Metadata|null
102 102
      */
103
-    public function read(string $sClass): ?Metadata
104
-    {
105
-        $sPath = $this->filepath($sClass);
106
-        $fCreator = file_exists($sPath) ? require $sPath : null;
107
-        return $fCreator instanceof Closure ? $fCreator() : null;
108
-    }
103
+public function read(string $sClass): ?Metadata
104
+{
105
+$sPath = $this->filepath($sClass);
106
+$fCreator = file_exists($sPath) ? require $sPath : null;
107
+return $fCreator instanceof Closure ? $fCreator() : null;
108
+}
109 109
 }
Please login to merge, or discard this patch.
jaxon-core/src/App/Metadata/Data/ContainerData.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
      */
52 52
     protected function validateAttr(string $sAttr): void
53 53
     {
54
-        if(preg_match('/^[a-zA-Z][a-zA-Z0-9_]*$/', $sAttr) > 0)
54
+        if (preg_match('/^[a-zA-Z][a-zA-Z0-9_]*$/', $sAttr) > 0)
55 55
         {
56 56
             return;
57 57
         }
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
      */
66 66
     protected function validateClass(string $sClass): void
67 67
     {
68
-        if(preg_match('/^(\\\)?([a-zA-Z][a-zA-Z0-9_]*)(\\\[a-zA-Z][a-zA-Z0-9_]*)*$/', $sClass) > 0)
68
+        if (preg_match('/^(\\\)?([a-zA-Z][a-zA-Z0-9_]*)(\\\[a-zA-Z][a-zA-Z0-9_]*)*$/', $sClass) > 0)
69 69
         {
70 70
             return;
71 71
         }
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
     public function encode(string $sVarName): array
93 93
     {
94 94
         $aCalls = [];
95
-        foreach($this->aProperties as $sAttr => $sClass)
95
+        foreach ($this->aProperties as $sAttr => $sClass)
96 96
         {
97 97
             $aCalls[] = "{$sVarName}->addValue('$sAttr', '" . addslashes($sClass) . "');";
98 98
         }
Please login to merge, or discard this patch.
Switch Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -21,81 +21,81 @@
 block discarded – undo
21 21
 
22 22
 class ContainerData extends AbstractData
23 23
 {
24
-    /**
24
+/**
25 25
      * The properties to get from the container
26 26
      *
27 27
      * @var string
28 28
      */
29
-    protected $aProperties = [];
29
+protected $aProperties = [];
30 30
 
31
-    /**
31
+/**
32 32
      * @return string
33 33
      */
34
-    public function getName(): string
35
-    {
36
-        return '__di';
37
-    }
34
+public function getName(): string
35
+{
36
+return '__di';
37
+}
38 38
 
39
-    /**
39
+/**
40 40
      * @return mixed
41 41
      */
42
-    public function getValue(): mixed
43
-    {
44
-        return $this->aProperties;
45
-    }
42
+public function getValue(): mixed
43
+{
44
+return $this->aProperties;
45
+}
46 46
 
47
-    /**
47
+/**
48 48
      * @param string $sAttr
49 49
      *
50 50
      * @return void
51 51
      */
52
-    protected function validateAttr(string $sAttr): void
53
-    {
54
-        if(preg_match('/^[a-zA-Z][a-zA-Z0-9_]*$/', $sAttr) > 0)
55
-        {
56
-            return;
57
-        }
58
-        throw new SetupException("$sAttr is not a valid \"attr\" value for di");
59
-    }
52
+protected function validateAttr(string $sAttr): void
53
+{
54
+if(preg_match('/^[a-zA-Z][a-zA-Z0-9_]*$/', $sAttr) > 0)
55
+{
56
+return;
57
+}
58
+throw new SetupException("$sAttr is not a valid \"attr\" value for di");
59
+}
60 60
 
61
-    /**
61
+/**
62 62
      * @param string $sClass
63 63
      *
64 64
      * @return void
65 65
      */
66
-    protected function validateClass(string $sClass): void
67
-    {
68
-        if(preg_match('/^(\\\)?([a-zA-Z][a-zA-Z0-9_]*)(\\\[a-zA-Z][a-zA-Z0-9_]*)*$/', $sClass) > 0)
69
-        {
70
-            return;
71
-        }
72
-        throw new SetupException("$sClass is not a valid \"class\" value for di");
73
-    }
66
+protected function validateClass(string $sClass): void
67
+{
68
+if(preg_match('/^(\\\)?([a-zA-Z][a-zA-Z0-9_]*)(\\\[a-zA-Z][a-zA-Z0-9_]*)*$/', $sClass) > 0)
69
+{
70
+return;
71
+}
72
+throw new SetupException("$sClass is not a valid \"class\" value for di");
73
+}
74 74
 
75
-    /**
75
+/**
76 76
      * @param string $sAttr
77 77
      * @param string $sClass
78 78
      *
79 79
      * @return void
80 80
      */
81
-    public function addValue(string $sAttr, string $sClass): void
82
-    {
83
-        $this->validateAttr($sAttr);
84
-        $this->validateClass($sClass);
81
+public function addValue(string $sAttr, string $sClass): void
82
+{
83
+$this->validateAttr($sAttr);
84
+$this->validateClass($sClass);
85 85
 
86
-        $this->aProperties[$sAttr] = $sClass;
87
-    }
86
+$this->aProperties[$sAttr] = $sClass;
87
+}
88 88
 
89
-    /**
89
+/**
90 90
      * @inheritDoc
91 91
      */
92
-    public function encode(string $sVarName): array
93
-    {
94
-        $aCalls = [];
95
-        foreach($this->aProperties as $sAttr => $sClass)
96
-        {
97
-            $aCalls[] = "{$sVarName}->addValue('$sAttr', '" . addslashes($sClass) . "');";
98
-        }
99
-        return $aCalls;
100
-    }
92
+public function encode(string $sVarName): array
93
+{
94
+$aCalls = [];
95
+foreach($this->aProperties as $sAttr => $sClass)
96
+{
97
+$aCalls[] = "{$sVarName}->addValue('$sAttr', '" . addslashes($sClass) . "');";
98
+}
99
+return $aCalls;
100
+}
101 101
 }
Please login to merge, or discard this patch.
jaxon-core/src/Plugin/ResponsePluginInterface.php 1 patch
Switch Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -6,17 +6,17 @@
 block discarded – undo
6 6
 
7 7
 interface ResponsePluginInterface
8 8
 {
9
-    /**
9
+/**
10 10
      * Get the attached response
11 11
      *
12 12
      * @return AbstractResponse|null
13 13
      */
14
-    public function response(): ?AbstractResponse;
14
+public function response(): ?AbstractResponse;
15 15
 
16
-    /**
16
+/**
17 17
      * @param AbstractResponse $xResponse   The response
18 18
      *
19 19
      * @return static
20 20
      */
21
-    public function initPlugin(AbstractResponse $xResponse): static;
21
+public function initPlugin(AbstractResponse $xResponse): static;
22 22
 }
Please login to merge, or discard this patch.
jaxon-core/src/Plugin/CallableRegistryInterface.php 1 patch
Switch Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 
5 5
 interface CallableRegistryInterface
6 6
 {
7
-    /**
7
+/**
8 8
      * Check if the provided options are correct, and convert them into an array.
9 9
      *
10 10
      * @param string $sCallable
@@ -12,9 +12,9 @@  discard block
 block discarded – undo
12 12
      *
13 13
      * @return array
14 14
      */
15
-    public function checkOptions(string $sCallable, $xOptions): array;
15
+public function checkOptions(string $sCallable, $xOptions): array;
16 16
 
17
-    /**
17
+/**
18 18
      * Register a callable entity: a function or a class.
19 19
      *
20 20
      * Called by the <Jaxon\Plugin\RequestManager> when a user script
@@ -27,14 +27,14 @@  discard block
 block discarded – undo
27 27
      *
28 28
      * @return bool
29 29
      */
30
-    public function register(string $sType, string $sCallable, array $aOptions): bool;
30
+public function register(string $sType, string $sCallable, array $aOptions): bool;
31 31
 
32
-    /**
32
+/**
33 33
      * Get the callable object for a registered item
34 34
      *
35 35
      * @param string $sCallable
36 36
      *
37 37
      * @return mixed
38 38
      */
39
-    public function getCallable(string $sCallable): mixed;
39
+public function getCallable(string $sCallable): mixed;
40 40
 }
Please login to merge, or discard this patch.
jaxon-core/src/Plugin/Code/JsCode.php 1 patch
Switch Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -16,31 +16,31 @@
 block discarded – undo
16 16
 
17 17
 class JsCode
18 18
 {
19
-    /**
19
+/**
20 20
      * The main javascript code
21 21
      *
22 22
      * @var string
23 23
      */
24
-    public $sJs = '';
24
+public $sJs = '';
25 25
 
26
-    /**
26
+/**
27 27
      * The js files
28 28
      *
29 29
      * @var array
30 30
      */
31
-    public $aFiles = [];
31
+public $aFiles = [];
32 32
 
33
-    /**
33
+/**
34 34
      * The javascript code to be inserted inline before the main code
35 35
      *
36 36
      * @var string
37 37
      */
38
-    public $sJsBefore = '';
38
+public $sJsBefore = '';
39 39
 
40
-    /**
40
+/**
41 41
      * The javascript code to be inserted inline after the main code
42 42
      *
43 43
      * @var string
44 44
      */
45
-    public $sJsAfter = '';
45
+public $sJsAfter = '';
46 46
 }
Please login to merge, or discard this patch.
jaxon-core/src/Plugin/Code/ReadyScriptGenerator.php 1 patch
Switch Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -18,11 +18,11 @@
 block discarded – undo
18 18
 
19 19
 class ReadyScriptGenerator extends AbstractCodeGenerator
20 20
 {
21
-    /**
21
+/**
22 22
      * @inheritDoc
23 23
      */
24
-    public function getScript(): string
25
-    {
26
-        return "jaxon.dom.ready(() => jaxon.processCustomAttrs());";
27
-    }
24
+public function getScript(): string
25
+{
26
+return "jaxon.dom.ready(() => jaxon.processCustomAttrs());";
27
+}
28 28
 }
Please login to merge, or discard this patch.
jaxon-core/src/Plugin/Code/MinifierInterface.php 1 patch
Switch Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 
5 5
 interface MinifierInterface
6 6
 {
7
-    /**
7
+/**
8 8
      * Minify javascript code
9 9
      *
10 10
      * @param string $sJsFile The javascript file to be minified
@@ -12,5 +12,5 @@  discard block
 block discarded – undo
12 12
      *
13 13
      * @return bool
14 14
      */
15
-    public function minify(string $sJsFile, string $sMinFile): bool;
15
+public function minify(string $sJsFile, string $sMinFile): bool;
16 16
 }
Please login to merge, or discard this patch.