Passed
Push — main ( 0dcad8...87fed9 )
by Thierry
04:24
created
jaxon-core/src/Response/AbstractResponse.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -91,15 +91,15 @@
 block discarded – undo
91 91
         return $this->xManager->getErrorMessage();
92 92
     }
93 93
 
94
-     /**
95
-     * Add a response command to the array of commands
96
-     *
97
-     * @param string $sName    The command name
98
-     * @param array|JsonSerializable $aArgs    The command arguments
99
-     * @param bool $bRemoveEmpty
100
-     *
101
-     * @return Command
102
-     */
94
+        /**
95
+         * Add a response command to the array of commands
96
+         *
97
+         * @param string $sName    The command name
98
+         * @param array|JsonSerializable $aArgs    The command arguments
99
+         * @param bool $bRemoveEmpty
100
+         *
101
+         * @return Command
102
+         */
103 103
     public function addCommand(string $sName, array|JsonSerializable $aArgs = [],
104 104
         bool $bRemoveEmpty = false): Command
105 105
     {
Please login to merge, or discard this patch.
jaxon-core/src/Plugin/Manager/PackageManager.php 3 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -218,8 +218,7 @@
 block discarded – undo
218 218
         {
219 219
             // A string is supposed to be the path to a config file.
220 220
             $aLibOptions = $this->xConfigManager->read($aLibOptions);
221
-        }
222
-        elseif(!is_array($aLibOptions))
221
+        } elseif(!is_array($aLibOptions))
223 222
         {
224 223
             // Otherwise, anything else than an array is not accepted.
225 224
             $sMessage = $this->xTranslator->trans('errors.register.invalid', ['name' => $sClassName]);
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -62,25 +62,25 @@  discard block
 block discarded – undo
62 62
     private function updateContainer(Config $xConfig): void
63 63
     {
64 64
         $aOptions = $xConfig->getOption('container.set', []);
65
-        foreach($aOptions as $xKey => $xValue)
65
+        foreach ($aOptions as $xKey => $xValue)
66 66
         {
67 67
             // The key is the class name. It must be a string.
68 68
             $this->di->set((string)$xKey, $xValue);
69 69
         }
70 70
         $aOptions = $xConfig->getOption('container.val', []);
71
-        foreach($aOptions as $xKey => $xValue)
71
+        foreach ($aOptions as $xKey => $xValue)
72 72
         {
73 73
             // The key is the class name. It must be a string.
74 74
             $this->di->val((string)$xKey, $xValue);
75 75
         }
76 76
         $aOptions = $xConfig->getOption('container.auto', []);
77
-        foreach($aOptions as $xValue)
77
+        foreach ($aOptions as $xValue)
78 78
         {
79 79
             // The key is the class name. It must be a string.
80 80
             $this->di->auto((string)$xValue);
81 81
         }
82 82
         $aOptions = $xConfig->getOption('container.alias', []);
83
-        foreach($aOptions as $xKey => $xValue)
83
+        foreach ($aOptions as $xKey => $xValue)
84 84
         {
85 85
             // The key is the class name. It must be a string.
86 86
             $this->di->alias((string)$xKey, (string)$xValue);
@@ -98,16 +98,16 @@  discard block
 block discarded – undo
98 98
      */
99 99
     private function registerCallables(array $aOptions, string $sCallableType): void
100 100
     {
101
-        foreach($aOptions as $xKey => $xValue)
101
+        foreach ($aOptions as $xKey => $xValue)
102 102
         {
103
-            if(is_integer($xKey) && is_string($xValue))
103
+            if (is_integer($xKey) && is_string($xValue))
104 104
             {
105 105
                 // Register a function without options
106 106
                 $this->xPluginManager->registerCallable($sCallableType, $xValue);
107 107
                 continue;
108 108
             }
109 109
 
110
-            if(is_string($xKey) && (is_array($xValue) || is_string($xValue)))
110
+            if (is_string($xKey) && (is_array($xValue) || is_string($xValue)))
111 111
             {
112 112
                 // Register a function with options
113 113
                 $this->xPluginManager->registerCallable($sCallableType, $xKey, $xValue);
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
      */
125 125
     private function registerExceptionHandlers(Config $xConfig): void
126 126
     {
127
-        foreach($xConfig->getOption('exceptions', []) as $sExClass => $xExHandler)
127
+        foreach ($xConfig->getOption('exceptions', []) as $sExClass => $xExHandler)
128 128
         {
129 129
             $this->xCallbackManager->error($xExHandler, is_string($sExClass) ? $sExClass : '');
130 130
         }
@@ -147,20 +147,20 @@  discard block
 block discarded – undo
147 147
         // key of the array item, a string as the value of an entry without a key,
148 148
         // or set with the key $sOptionKey in an array entry without a key.
149 149
         $aCallables = [];
150
-        foreach($xConfig->getOption($sOptionName, []) as $xKey => $xValue)
150
+        foreach ($xConfig->getOption($sOptionName, []) as $xKey => $xValue)
151 151
         {
152
-            if(is_string($xKey))
152
+            if (is_string($xKey))
153 153
             {
154 154
                 $aCallables[$xKey] = $xValue;
155 155
                 continue;
156 156
             }
157
-            if(is_string($xValue))
157
+            if (is_string($xValue))
158 158
             {
159 159
                 $aCallables[] = $xValue;
160 160
                 continue;
161 161
             }
162 162
 
163
-            if(is_array($xValue) && isset($xValue[$sOptionKey]))
163
+            if (is_array($xValue) && isset($xValue[$sOptionKey]))
164 164
             {
165 165
                 $aCallables[$xValue[$sOptionKey]] = $xValue;
166 166
             }
@@ -215,12 +215,12 @@  discard block
 block discarded – undo
215 215
     {
216 216
         // $this->aPackages contains packages config file paths.
217 217
         $aLibOptions = $sClassName::config();
218
-        if(is_string($aLibOptions))
218
+        if (is_string($aLibOptions))
219 219
         {
220 220
             // A string is supposed to be the path to a config file.
221 221
             $aLibOptions = $this->xConfigManager->read($aLibOptions);
222 222
         }
223
-        elseif(!is_array($aLibOptions))
223
+        elseif (!is_array($aLibOptions))
224 224
         {
225 225
             // Otherwise, anything else than an array is not accepted.
226 226
             $sMessage = $this->xTranslator->trans('errors.register.invalid', ['name' => $sClassName]);
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
     public function registerPackage(string $sClassName, array $aUserOptions = []): void
244 244
     {
245 245
         $sClassName = trim($sClassName, '\\ ');
246
-        if(!is_subclass_of($sClassName, AbstractPackage::class))
246
+        if (!is_subclass_of($sClassName, AbstractPackage::class))
247 247
         {
248 248
             $sMessage = $this->xTranslator->trans('errors.register.invalid', ['name' => $sClassName]);
249 249
             throw new SetupException($sMessage);
@@ -287,9 +287,9 @@  discard block
 block discarded – undo
287 287
 
288 288
         // Register packages
289 289
         $aPackageConfig = $xAppConfig->getOption('packages', []);
290
-        foreach($aPackageConfig as $xKey => $xValue)
290
+        foreach ($aPackageConfig as $xKey => $xValue)
291 291
         {
292
-            if(is_integer($xKey) && is_string($xValue))
292
+            if (is_integer($xKey) && is_string($xValue))
293 293
             {
294 294
                 // Register a package without options
295 295
                 $sClassName = $xValue;
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
                 continue;
298 298
             }
299 299
 
300
-            if(is_string($xKey) && is_array($xValue))
300
+            if (is_string($xKey) && is_array($xValue))
301 301
             {
302 302
                 // Register a package with options
303 303
                 $sClassName = $xKey;
Please login to merge, or discard this patch.
Switch Indentation   +179 added lines, -179 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 
35 35
 class PackageManager
36 36
 {
37
-    /**
37
+/**
38 38
      * The constructor
39 39
      *
40 40
      * @param Container $di
@@ -46,48 +46,48 @@  discard block
 block discarded – undo
46 46
      * @param CallbackManager $xCallbackManager
47 47
      * @param ComponentRegistry $xRegistry
48 48
      */
49
-    public function __construct(private Container $di, private Translator $xTranslator,
50
-        private PluginManager $xPluginManager, private ConfigManager $xConfigManager,
51
-        private CodeGenerator $xCodeGenerator, private ViewRenderer $xViewRenderer,
52
-        private CallbackManager $xCallbackManager, private ComponentRegistry $xRegistry)
53
-    {}
49
+public function __construct(private Container $di, private Translator $xTranslator,
50
+private PluginManager $xPluginManager, private ConfigManager $xConfigManager,
51
+private CodeGenerator $xCodeGenerator, private ViewRenderer $xViewRenderer,
52
+private CallbackManager $xCallbackManager, private ComponentRegistry $xRegistry)
53
+{}
54 54
 
55
-    /**
55
+/**
56 56
      * Save items in the DI container
57 57
      *
58 58
      * @param Config $xConfig
59 59
      *
60 60
      * @return void
61 61
      */
62
-    private function updateContainer(Config $xConfig): void
63
-    {
64
-        $aOptions = $xConfig->getOption('container.set', []);
65
-        foreach($aOptions as $xKey => $xValue)
66
-        {
67
-            // The key is the class name. It must be a string.
68
-            $this->di->set((string)$xKey, $xValue);
69
-        }
70
-        $aOptions = $xConfig->getOption('container.val', []);
71
-        foreach($aOptions as $xKey => $xValue)
72
-        {
73
-            // The key is the class name. It must be a string.
74
-            $this->di->val((string)$xKey, $xValue);
75
-        }
76
-        $aOptions = $xConfig->getOption('container.auto', []);
77
-        foreach($aOptions as $xValue)
78
-        {
79
-            // The key is the class name. It must be a string.
80
-            $this->di->auto((string)$xValue);
81
-        }
82
-        $aOptions = $xConfig->getOption('container.alias', []);
83
-        foreach($aOptions as $xKey => $xValue)
84
-        {
85
-            // The key is the class name. It must be a string.
86
-            $this->di->alias((string)$xKey, (string)$xValue);
87
-        }
88
-    }
62
+private function updateContainer(Config $xConfig): void
63
+{
64
+$aOptions = $xConfig->getOption('container.set', []);
65
+foreach($aOptions as $xKey => $xValue)
66
+{
67
+// The key is the class name. It must be a string.
68
+$this->di->set((string)$xKey, $xValue);
69
+}
70
+$aOptions = $xConfig->getOption('container.val', []);
71
+foreach($aOptions as $xKey => $xValue)
72
+{
73
+// The key is the class name. It must be a string.
74
+$this->di->val((string)$xKey, $xValue);
75
+}
76
+$aOptions = $xConfig->getOption('container.auto', []);
77
+foreach($aOptions as $xValue)
78
+{
79
+// The key is the class name. It must be a string.
80
+$this->di->auto((string)$xValue);
81
+}
82
+$aOptions = $xConfig->getOption('container.alias', []);
83
+foreach($aOptions as $xKey => $xValue)
84
+{
85
+// The key is the class name. It must be a string.
86
+$this->di->alias((string)$xKey, (string)$xValue);
87
+}
88
+}
89 89
 
90
-    /**
90
+/**
91 91
      * Register callables from a section of the config
92 92
      *
93 93
      * @param array $aOptions    The content of the config section
@@ -96,41 +96,41 @@  discard block
 block discarded – undo
96 96
      * @return void
97 97
      * @throws SetupException
98 98
      */
99
-    private function registerCallables(array $aOptions, string $sCallableType): void
100
-    {
101
-        foreach($aOptions as $xKey => $xValue)
102
-        {
103
-            if(is_integer($xKey) && is_string($xValue))
104
-            {
105
-                // Register a function without options
106
-                $this->xPluginManager->registerCallable($sCallableType, $xValue);
107
-                continue;
108
-            }
99
+private function registerCallables(array $aOptions, string $sCallableType): void
100
+{
101
+foreach($aOptions as $xKey => $xValue)
102
+{
103
+if(is_integer($xKey) && is_string($xValue))
104
+{
105
+    // Register a function without options
106
+    $this->xPluginManager->registerCallable($sCallableType, $xValue);
107
+    continue;
108
+}
109 109
 
110
-            if(is_string($xKey) && (is_array($xValue) || is_string($xValue)))
111
-            {
112
-                // Register a function with options
113
-                $this->xPluginManager->registerCallable($sCallableType, $xKey, $xValue);
114
-            }
115
-        }
116
-    }
110
+if(is_string($xKey) && (is_array($xValue) || is_string($xValue)))
111
+{
112
+    // Register a function with options
113
+    $this->xPluginManager->registerCallable($sCallableType, $xKey, $xValue);
114
+}
115
+}
116
+}
117 117
 
118
-    /**
118
+/**
119 119
      * Register exceptions handlers
120 120
      *
121 121
      * @param Config $xConfig
122 122
      *
123 123
      * @return void
124 124
      */
125
-    private function registerExceptionHandlers(Config $xConfig): void
126
-    {
127
-        foreach($xConfig->getOption('exceptions', []) as $sExClass => $xExHandler)
128
-        {
129
-            $this->xCallbackManager->error($xExHandler, is_string($sExClass) ? $sExClass : '');
130
-        }
131
-    }
125
+private function registerExceptionHandlers(Config $xConfig): void
126
+{
127
+foreach($xConfig->getOption('exceptions', []) as $sExClass => $xExHandler)
128
+{
129
+$this->xCallbackManager->error($xExHandler, is_string($sExClass) ? $sExClass : '');
130
+}
131
+}
132 132
 
133
-    /**
133
+/**
134 134
      * Get a callable list from config
135 135
      *
136 136
      * @param Config $xConfig
@@ -140,36 +140,36 @@  discard block
 block discarded – undo
140 140
      *
141 141
      * @return void
142 142
      */
143
-    private function registerCallablesFromConfig(Config $xConfig,
144
-        string $sOptionName, string $sOptionKey, string $sCallableType): void
145
-    {
146
-        // The callable (directory path, class or function name) can be used as the
147
-        // key of the array item, a string as the value of an entry without a key,
148
-        // or set with the key $sOptionKey in an array entry without a key.
149
-        $aCallables = [];
150
-        foreach($xConfig->getOption($sOptionName, []) as $xKey => $xValue)
151
-        {
152
-            if(is_string($xKey))
153
-            {
154
-                $aCallables[$xKey] = $xValue;
155
-                continue;
156
-            }
157
-            if(is_string($xValue))
158
-            {
159
-                $aCallables[] = $xValue;
160
-                continue;
161
-            }
143
+private function registerCallablesFromConfig(Config $xConfig,
144
+string $sOptionName, string $sOptionKey, string $sCallableType): void
145
+{
146
+// The callable (directory path, class or function name) can be used as the
147
+// key of the array item, a string as the value of an entry without a key,
148
+// or set with the key $sOptionKey in an array entry without a key.
149
+$aCallables = [];
150
+foreach($xConfig->getOption($sOptionName, []) as $xKey => $xValue)
151
+{
152
+if(is_string($xKey))
153
+{
154
+    $aCallables[$xKey] = $xValue;
155
+    continue;
156
+}
157
+if(is_string($xValue))
158
+{
159
+    $aCallables[] = $xValue;
160
+    continue;
161
+}
162 162
 
163
-            if(is_array($xValue) && isset($xValue[$sOptionKey]))
164
-            {
165
-                $aCallables[$xValue[$sOptionKey]] = $xValue;
166
-            }
167
-            // Invalid values are ignored.
168
-        }
169
-        $this->registerCallables($aCallables, $sCallableType);
170
-    }
163
+if(is_array($xValue) && isset($xValue[$sOptionKey]))
164
+{
165
+    $aCallables[$xValue[$sOptionKey]] = $xValue;
166
+}
167
+// Invalid values are ignored.
168
+}
169
+$this->registerCallables($aCallables, $sCallableType);
170
+}
171 171
 
172
-    /**
172
+/**
173 173
      * Read and set Jaxon options from a JSON config file
174 174
      *
175 175
      * @param Config $xConfig The config options
@@ -177,33 +177,33 @@  discard block
 block discarded – undo
177 177
      * @return void
178 178
      * @throws SetupException
179 179
      */
180
-    private function registerItemsFromConfig(Config $xConfig): void
181
-    {
182
-        // Set the config for the registered callables.
183
-        $this->xRegistry->setPackageConfig($xConfig);
180
+private function registerItemsFromConfig(Config $xConfig): void
181
+{
182
+// Set the config for the registered callables.
183
+$this->xRegistry->setPackageConfig($xConfig);
184 184
 
185
-        // Register functions, classes and directories
186
-        $this->registerCallablesFromConfig($xConfig,
187
-            'functions', 'name', Jaxon::CALLABLE_FUNCTION);
188
-        $this->registerCallablesFromConfig($xConfig,
189
-            'classes', 'name', Jaxon::CALLABLE_CLASS);
190
-        $this->registerCallablesFromConfig($xConfig,
191
-            'directories', 'path', Jaxon::CALLABLE_DIR);
185
+// Register functions, classes and directories
186
+$this->registerCallablesFromConfig($xConfig,
187
+'functions', 'name', Jaxon::CALLABLE_FUNCTION);
188
+$this->registerCallablesFromConfig($xConfig,
189
+'classes', 'name', Jaxon::CALLABLE_CLASS);
190
+$this->registerCallablesFromConfig($xConfig,
191
+'directories', 'path', Jaxon::CALLABLE_DIR);
192 192
 
193
-        // Unset the current config.
194
-        $this->xRegistry->unsetPackageConfig();
193
+// Unset the current config.
194
+$this->xRegistry->unsetPackageConfig();
195 195
 
196
-        // Register the view namespaces
197
-        // Note: the $xUserConfig can provide a "template" option, which is used to customize
198
-        // the user defined view namespaces. That's why it is needed here.
199
-        $this->xViewRenderer->addNamespaces($xConfig);
200
-        // Save items in the DI container
201
-        $this->updateContainer($xConfig);
202
-        // Register the exception handlers
203
-        $this->registerExceptionHandlers($xConfig);
204
-    }
196
+// Register the view namespaces
197
+// Note: the $xUserConfig can provide a "template" option, which is used to customize
198
+// the user defined view namespaces. That's why it is needed here.
199
+$this->xViewRenderer->addNamespaces($xConfig);
200
+// Save items in the DI container
201
+$this->updateContainer($xConfig);
202
+// Register the exception handlers
203
+$this->registerExceptionHandlers($xConfig);
204
+}
205 205
 
206
-    /**
206
+/**
207 207
      * Get the options provided by the package library
208 208
      *
209 209
      * @param class-string $sClassName    The package class
@@ -211,27 +211,27 @@  discard block
 block discarded – undo
211 211
      * @return Config
212 212
      * @throws SetupException
213 213
      */
214
-    private function getPackageLibConfig(string $sClassName): Config
215
-    {
216
-        // $this->aPackages contains packages config file paths.
217
-        $aLibOptions = $sClassName::config();
218
-        if(is_string($aLibOptions))
219
-        {
220
-            // A string is supposed to be the path to a config file.
221
-            $aLibOptions = $this->xConfigManager->read($aLibOptions);
222
-        }
223
-        elseif(!is_array($aLibOptions))
224
-        {
225
-            // Otherwise, anything else than an array is not accepted.
226
-            $sMessage = $this->xTranslator->trans('errors.register.invalid', ['name' => $sClassName]);
227
-            throw new SetupException($sMessage);
228
-        }
229
-        // Add the package name to the config
230
-        $aLibOptions['package'] = $sClassName;
231
-        return $this->xConfigManager->newConfig($aLibOptions);
232
-    }
214
+private function getPackageLibConfig(string $sClassName): Config
215
+{
216
+// $this->aPackages contains packages config file paths.
217
+$aLibOptions = $sClassName::config();
218
+if(is_string($aLibOptions))
219
+{
220
+// A string is supposed to be the path to a config file.
221
+$aLibOptions = $this->xConfigManager->read($aLibOptions);
222
+}
223
+elseif(!is_array($aLibOptions))
224
+{
225
+// Otherwise, anything else than an array is not accepted.
226
+$sMessage = $this->xTranslator->trans('errors.register.invalid', ['name' => $sClassName]);
227
+throw new SetupException($sMessage);
228
+}
229
+// Add the package name to the config
230
+$aLibOptions['package'] = $sClassName;
231
+return $this->xConfigManager->newConfig($aLibOptions);
232
+}
233 233
 
234
-    /**
234
+/**
235 235
      * Register a package
236 236
      *
237 237
      * @param class-string $sClassName    The package class
@@ -240,27 +240,27 @@  discard block
 block discarded – undo
240 240
      * @return void
241 241
      * @throws SetupException
242 242
      */
243
-    public function registerPackage(string $sClassName, array $aUserOptions = []): void
244
-    {
245
-        $sClassName = trim($sClassName, '\\ ');
246
-        if(!is_subclass_of($sClassName, AbstractPackage::class))
247
-        {
248
-            $sMessage = $this->xTranslator->trans('errors.register.invalid', ['name' => $sClassName]);
249
-            throw new SetupException($sMessage);
250
-        }
243
+public function registerPackage(string $sClassName, array $aUserOptions = []): void
244
+{
245
+$sClassName = trim($sClassName, '\\ ');
246
+if(!is_subclass_of($sClassName, AbstractPackage::class))
247
+{
248
+$sMessage = $this->xTranslator->trans('errors.register.invalid', ['name' => $sClassName]);
249
+throw new SetupException($sMessage);
250
+}
251 251
 
252
-        // Register the declarations in the package config.
253
-        $xAppConfig = $this->getPackageLibConfig($sClassName);
254
-        $this->registerItemsFromConfig($xAppConfig);
252
+// Register the declarations in the package config.
253
+$xAppConfig = $this->getPackageLibConfig($sClassName);
254
+$this->registerItemsFromConfig($xAppConfig);
255 255
 
256
-        // Register the package and its options in the DI
257
-        $this->di->registerPackage($sClassName, $aUserOptions);
256
+// Register the package and its options in the DI
257
+$this->di->registerPackage($sClassName, $aUserOptions);
258 258
 
259
-        // Register the package as a code generator.
260
-        $this->xCodeGenerator->addCodeGenerator($sClassName, 500);
261
-    }
259
+// Register the package as a code generator.
260
+$this->xCodeGenerator->addCodeGenerator($sClassName, 500);
261
+}
262 262
 
263
-    /**
263
+/**
264 264
      * Get a package instance
265 265
      *
266 266
      * @template T of AbstractPackage
@@ -268,42 +268,42 @@  discard block
 block discarded – undo
268 268
      *
269 269
      * @return T|null
270 270
      */
271
-    public function getPackage(string $sClassName): ?AbstractPackage
272
-    {
273
-        $sClassName = trim($sClassName, '\\ ');
274
-        return $this->di->h($sClassName) ? $this->di->g($sClassName) : null;
275
-    }
271
+public function getPackage(string $sClassName): ?AbstractPackage
272
+{
273
+$sClassName = trim($sClassName, '\\ ');
274
+return $this->di->h($sClassName) ? $this->di->g($sClassName) : null;
275
+}
276 276
 
277
-    /**
277
+/**
278 278
      * Read and set Jaxon options from the config
279 279
      *
280 280
      * @return void
281 281
      * @throws SetupException
282 282
      */
283
-    public function registerFromConfig(): void
284
-    {
285
-        $xAppConfig = $this->xConfigManager->getAppConfig();
286
-        $this->registerItemsFromConfig($xAppConfig);
283
+public function registerFromConfig(): void
284
+{
285
+$xAppConfig = $this->xConfigManager->getAppConfig();
286
+$this->registerItemsFromConfig($xAppConfig);
287 287
 
288
-        // Register packages
289
-        $aPackageConfig = $xAppConfig->getOption('packages', []);
290
-        foreach($aPackageConfig as $xKey => $xValue)
291
-        {
292
-            if(is_integer($xKey) && is_string($xValue))
293
-            {
294
-                // Register a package without options
295
-                $sClassName = $xValue;
296
-                $this->registerPackage($sClassName);
297
-                continue;
298
-            }
288
+// Register packages
289
+$aPackageConfig = $xAppConfig->getOption('packages', []);
290
+foreach($aPackageConfig as $xKey => $xValue)
291
+{
292
+if(is_integer($xKey) && is_string($xValue))
293
+{
294
+    // Register a package without options
295
+    $sClassName = $xValue;
296
+    $this->registerPackage($sClassName);
297
+    continue;
298
+}
299 299
 
300
-            if(is_string($xKey) && is_array($xValue))
301
-            {
302
-                // Register a package with options
303
-                $sClassName = $xKey;
304
-                $aPkgOptions = $xValue;
305
-                $this->registerPackage($sClassName, $aPkgOptions);
306
-            }
307
-        }
308
-    }
300
+if(is_string($xKey) && is_array($xValue))
301
+{
302
+    // Register a package with options
303
+    $sClassName = $xKey;
304
+    $aPkgOptions = $xValue;
305
+    $this->registerPackage($sClassName, $aPkgOptions);
306
+}
307
+}
308
+}
309 309
 }
Please login to merge, or discard this patch.
jaxon-core/src/Plugin/Manager/PluginManager.php 2 patches
Spacing   +9 added lines, -10 removed lines patch added patch discarded remove patch
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
     private function _registerPlugin(string $sClassName, string $sPluginName, array $aInterfaces): int
101 101
     {
102 102
         // Any plugin must implement the PluginInterface interface.
103
-        if(!in_array(PluginInterface::class, $aInterfaces))
103
+        if (!in_array(PluginInterface::class, $aInterfaces))
104 104
         {
105 105
             $sMessage = $this->xTranslator->trans('errors.register.invalid', [
106 106
                 'name' => $sClassName,
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
         }
110 110
 
111 111
         // Response plugin.
112
-        if(in_array(ResponsePluginInterface::class, $aInterfaces))
112
+        if (in_array(ResponsePluginInterface::class, $aInterfaces))
113 113
         {
114 114
             $this->aResponsePlugins[$sPluginName] = $sClassName;
115 115
             return 1;
@@ -117,12 +117,12 @@  discard block
 block discarded – undo
117 117
 
118 118
         // Request plugin.
119 119
         $nCount = 0;
120
-        if(in_array(CallableRegistryInterface::class, $aInterfaces))
120
+        if (in_array(CallableRegistryInterface::class, $aInterfaces))
121 121
         {
122 122
             $this->aRegistryPlugins[$sPluginName] = $sClassName;
123 123
             $nCount++;
124 124
         }
125
-        if(in_array(RequestHandlerInterface::class, $aInterfaces))
125
+        if (in_array(RequestHandlerInterface::class, $aInterfaces))
126 126
         {
127 127
             $this->aRequestHandlers[$sPluginName] = $sClassName;
128 128
             $nCount++;
@@ -151,13 +151,13 @@  discard block
 block discarded – undo
151 151
         $nCount = $this->_registerPlugin($sClassName, $sPluginName, $aInterfaces);
152 152
 
153 153
         // Any plugin can implement the CodeGeneratorInterface interface.
154
-        if(in_array(CodeGeneratorInterface::class, $aInterfaces))
154
+        if (in_array(CodeGeneratorInterface::class, $aInterfaces))
155 155
         {
156 156
             $this->xCodeGenerator->addCodeGenerator($sClassName, $nPriority);
157 157
             $nCount++;
158 158
         }
159 159
         // The class is not a valid plugin.
160
-        if($nCount === 0)
160
+        if ($nCount === 0)
161 161
         {
162 162
             $sMessage = $this->xTranslator->trans('errors.register.invalid', [
163 163
                 'name' => $sClassName,
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
         }
167 167
 
168 168
         // Register the plugin in the DI container, if necessary
169
-        if(!$this->di->has($sClassName))
169
+        if (!$this->di->has($sClassName))
170 170
         {
171 171
             $this->di->auto($sClassName);
172 172
         }
@@ -182,8 +182,7 @@  discard block
 block discarded – undo
182 182
      */
183 183
     public function getResponsePlugin(string $sName): ?ResponsePluginInterface
184 184
     {
185
-        return $this->di->h($sName) ? $this->di->g($sName) :
186
-            (!isset($this->aResponsePlugins[$sName]) ? null :
185
+        return $this->di->h($sName) ? $this->di->g($sName) : (!isset($this->aResponsePlugins[$sName]) ? null :
187 186
             $this->di->g($this->aResponsePlugins[$sName]));
188 187
     }
189 188
 
@@ -201,7 +200,7 @@  discard block
 block discarded – undo
201 200
      */
202 201
     public function registerCallable(string $sType, string $sCallable, $xOptions = []): void
203 202
     {
204
-        if(isset($this->aRegistryPlugins[$sType]) &&
203
+        if (isset($this->aRegistryPlugins[$sType]) &&
205 204
             ($xPlugin = $this->di->g($this->aRegistryPlugins[$sType])))
206 205
         {
207 206
             $xPlugin->register($sType, $sCallable, $xPlugin->checkOptions($sCallable, $xOptions));
Please login to merge, or discard this patch.
Switch Indentation   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -45,49 +45,49 @@  discard block
 block discarded – undo
45 45
 
46 46
 class PluginManager
47 47
 {
48
-    /**
48
+/**
49 49
      * Request plugins, indexed by name
50 50
      *
51 51
      * @var array<string>
52 52
      */
53
-    private $aRegistryPlugins = [];
53
+private $aRegistryPlugins = [];
54 54
 
55
-    /**
55
+/**
56 56
      * Request handlers, indexed by name
57 57
      *
58 58
      * @var array<string>
59 59
      */
60
-    private $aRequestHandlers = [];
60
+private $aRequestHandlers = [];
61 61
 
62
-    /**
62
+/**
63 63
      * Response plugins, indexed by name
64 64
      *
65 65
      * @var array<string>
66 66
      */
67
-    private $aResponsePlugins = [];
67
+private $aResponsePlugins = [];
68 68
 
69
-    /**
69
+/**
70 70
      * The constructor
71 71
      *
72 72
      * @param Container $di
73 73
      * @param CodeGenerator $xCodeGenerator
74 74
      * @param Translator $xTranslator
75 75
      */
76
-    public function __construct(private Container $di,
77
-        private CodeGenerator $xCodeGenerator, private Translator $xTranslator)
78
-    {}
76
+public function __construct(private Container $di,
77
+private CodeGenerator $xCodeGenerator, private Translator $xTranslator)
78
+{}
79 79
 
80
-    /**
80
+/**
81 81
      * Get the request plugins
82 82
      *
83 83
      * @return array<class-string>
84 84
      */
85
-    public function getRequestHandlers(): array
86
-    {
87
-        return $this->aRequestHandlers;
88
-    }
85
+public function getRequestHandlers(): array
86
+{
87
+return $this->aRequestHandlers;
88
+}
89 89
 
90
-    /**
90
+/**
91 91
      * Register a plugin
92 92
      *
93 93
      * @param class-string $sClassName    The plugin class
@@ -97,40 +97,40 @@  discard block
 block discarded – undo
97 97
      * @return int
98 98
      * @throws SetupException
99 99
      */
100
-    private function _registerPlugin(string $sClassName, string $sPluginName, array $aInterfaces): int
101
-    {
102
-        // Any plugin must implement the PluginInterface interface.
103
-        if(!in_array(PluginInterface::class, $aInterfaces))
104
-        {
105
-            $sMessage = $this->xTranslator->trans('errors.register.invalid', [
106
-                'name' => $sClassName,
107
-            ]);
108
-            throw new SetupException($sMessage);
109
-        }
110
-
111
-        // Response plugin.
112
-        if(in_array(ResponsePluginInterface::class, $aInterfaces))
113
-        {
114
-            $this->aResponsePlugins[$sPluginName] = $sClassName;
115
-            return 1;
116
-        }
117
-
118
-        // Request plugin.
119
-        $nCount = 0;
120
-        if(in_array(CallableRegistryInterface::class, $aInterfaces))
121
-        {
122
-            $this->aRegistryPlugins[$sPluginName] = $sClassName;
123
-            $nCount++;
124
-        }
125
-        if(in_array(RequestHandlerInterface::class, $aInterfaces))
126
-        {
127
-            $this->aRequestHandlers[$sPluginName] = $sClassName;
128
-            $nCount++;
129
-        }
130
-        return $nCount;
131
-    }
132
-
133
-    /**
100
+private function _registerPlugin(string $sClassName, string $sPluginName, array $aInterfaces): int
101
+{
102
+// Any plugin must implement the PluginInterface interface.
103
+if(!in_array(PluginInterface::class, $aInterfaces))
104
+{
105
+$sMessage = $this->xTranslator->trans('errors.register.invalid', [
106
+    'name' => $sClassName,
107
+]);
108
+throw new SetupException($sMessage);
109
+}
110
+
111
+// Response plugin.
112
+if(in_array(ResponsePluginInterface::class, $aInterfaces))
113
+{
114
+$this->aResponsePlugins[$sPluginName] = $sClassName;
115
+return 1;
116
+}
117
+
118
+// Request plugin.
119
+$nCount = 0;
120
+if(in_array(CallableRegistryInterface::class, $aInterfaces))
121
+{
122
+$this->aRegistryPlugins[$sPluginName] = $sClassName;
123
+$nCount++;
124
+}
125
+if(in_array(RequestHandlerInterface::class, $aInterfaces))
126
+{
127
+$this->aRequestHandlers[$sPluginName] = $sClassName;
128
+$nCount++;
129
+}
130
+return $nCount;
131
+}
132
+
133
+/**
134 134
      * Register a plugin
135 135
      *
136 136
      * Below is a table for priorities and their description:
@@ -145,34 +145,34 @@  discard block
 block discarded – undo
145 145
      * @return void
146 146
      * @throws SetupException
147 147
      */
148
-    public function registerPlugin(string $sClassName, string $sPluginName, int $nPriority = 1000): void
149
-    {
150
-        $aInterfaces = class_implements($sClassName);
151
-        $nCount = $this->_registerPlugin($sClassName, $sPluginName, $aInterfaces);
152
-
153
-        // Any plugin can implement the CodeGeneratorInterface interface.
154
-        if(in_array(CodeGeneratorInterface::class, $aInterfaces))
155
-        {
156
-            $this->xCodeGenerator->addCodeGenerator($sClassName, $nPriority);
157
-            $nCount++;
158
-        }
159
-        // The class is not a valid plugin.
160
-        if($nCount === 0)
161
-        {
162
-            $sMessage = $this->xTranslator->trans('errors.register.invalid', [
163
-                'name' => $sClassName,
164
-            ]);
165
-            throw new SetupException($sMessage);
166
-        }
167
-
168
-        // Register the plugin in the DI container, if necessary
169
-        if(!$this->di->has($sClassName))
170
-        {
171
-            $this->di->auto($sClassName);
172
-        }
173
-    }
174
-
175
-    /**
148
+public function registerPlugin(string $sClassName, string $sPluginName, int $nPriority = 1000): void
149
+{
150
+$aInterfaces = class_implements($sClassName);
151
+$nCount = $this->_registerPlugin($sClassName, $sPluginName, $aInterfaces);
152
+
153
+// Any plugin can implement the CodeGeneratorInterface interface.
154
+if(in_array(CodeGeneratorInterface::class, $aInterfaces))
155
+{
156
+$this->xCodeGenerator->addCodeGenerator($sClassName, $nPriority);
157
+$nCount++;
158
+}
159
+// The class is not a valid plugin.
160
+if($nCount === 0)
161
+{
162
+$sMessage = $this->xTranslator->trans('errors.register.invalid', [
163
+    'name' => $sClassName,
164
+]);
165
+throw new SetupException($sMessage);
166
+}
167
+
168
+// Register the plugin in the DI container, if necessary
169
+if(!$this->di->has($sClassName))
170
+{
171
+$this->di->auto($sClassName);
172
+}
173
+}
174
+
175
+/**
176 176
      * Find the specified response plugin by name or class name
177 177
      *
178 178
      * @template R of ResponsePluginInterface
@@ -180,14 +180,14 @@  discard block
 block discarded – undo
180 180
      *
181 181
      * @return ($sName is class-string ? R : ResponsePluginInterface)|null
182 182
      */
183
-    public function getResponsePlugin(string $sName): ?ResponsePluginInterface
184
-    {
185
-        return $this->di->h($sName) ? $this->di->g($sName) :
186
-            (!isset($this->aResponsePlugins[$sName]) ? null :
187
-            $this->di->g($this->aResponsePlugins[$sName]));
188
-    }
189
-
190
-    /**
183
+public function getResponsePlugin(string $sName): ?ResponsePluginInterface
184
+{
185
+return $this->di->h($sName) ? $this->di->g($sName) :
186
+(!isset($this->aResponsePlugins[$sName]) ? null :
187
+$this->di->g($this->aResponsePlugins[$sName]));
188
+}
189
+
190
+/**
191 191
      * Register a callable function or class
192 192
      *
193 193
      * Call the request plugin with the $sType defined as name.
@@ -199,46 +199,46 @@  discard block
 block discarded – undo
199 199
      * @return void
200 200
      * @throws SetupException
201 201
      */
202
-    public function registerCallable(string $sType, string $sCallable, $xOptions = []): void
203
-    {
204
-        if(isset($this->aRegistryPlugins[$sType]) &&
205
-            ($xPlugin = $this->di->g($this->aRegistryPlugins[$sType])))
206
-        {
207
-            $xPlugin->register($sType, $sCallable, $xPlugin->checkOptions($sCallable, $xOptions));
208
-            return;
209
-        }
210
-        throw new SetupException($this->xTranslator->trans('errors.register.plugin',
211
-            ['name' => $sType, 'callable' => $sCallable]));
212
-    }
213
-
214
-    /**
202
+public function registerCallable(string $sType, string $sCallable, $xOptions = []): void
203
+{
204
+if(isset($this->aRegistryPlugins[$sType]) &&
205
+($xPlugin = $this->di->g($this->aRegistryPlugins[$sType])))
206
+{
207
+$xPlugin->register($sType, $sCallable, $xPlugin->checkOptions($sCallable, $xOptions));
208
+return;
209
+}
210
+throw new SetupException($this->xTranslator->trans('errors.register.plugin',
211
+['name' => $sType, 'callable' => $sCallable]));
212
+}
213
+
214
+/**
215 215
      * Register the Jaxon request plugins
216 216
      *
217 217
      * @return void
218 218
      * @throws SetupException
219 219
      */
220
-    public function registerPlugins(): void
221
-    {
222
-        // Request plugins
223
-        $this->registerPlugin(CallableClassPlugin::class, Jaxon::CALLABLE_CLASS, 101);
224
-        $this->registerPlugin(CallableFunctionPlugin::class, Jaxon::CALLABLE_FUNCTION, 102);
225
-        $this->registerPlugin(CallableDirPlugin::class, Jaxon::CALLABLE_DIR, 103);
226
-
227
-        // Response plugins
228
-        $this->registerPlugin(ScriptPlugin::class, ScriptPlugin::NAME, 700);
229
-        $this->registerPlugin(DatabagPlugin::class, DatabagPlugin::NAME, 700);
230
-        $this->registerPlugin(DialogPlugin::class, DialogPlugin::NAME, 750);
231
-        $this->registerPlugin(PaginatorPlugin::class, PaginatorPlugin::NAME, 800);
232
-        $this->registerPlugin(PsrPlugin::class, PsrPlugin::NAME, 850);
233
-    }
234
-
235
-    /**
220
+public function registerPlugins(): void
221
+{
222
+// Request plugins
223
+$this->registerPlugin(CallableClassPlugin::class, Jaxon::CALLABLE_CLASS, 101);
224
+$this->registerPlugin(CallableFunctionPlugin::class, Jaxon::CALLABLE_FUNCTION, 102);
225
+$this->registerPlugin(CallableDirPlugin::class, Jaxon::CALLABLE_DIR, 103);
226
+
227
+// Response plugins
228
+$this->registerPlugin(ScriptPlugin::class, ScriptPlugin::NAME, 700);
229
+$this->registerPlugin(DatabagPlugin::class, DatabagPlugin::NAME, 700);
230
+$this->registerPlugin(DialogPlugin::class, DialogPlugin::NAME, 750);
231
+$this->registerPlugin(PaginatorPlugin::class, PaginatorPlugin::NAME, 800);
232
+$this->registerPlugin(PsrPlugin::class, PsrPlugin::NAME, 850);
233
+}
234
+
235
+/**
236 236
      * Get the parameter reader
237 237
      *
238 238
      * @return ParameterReader
239 239
      */
240
-    public function getParameterReader(): ParameterReader
241
-    {
242
-        return $this->di->g(ParameterReader::class);
243
-    }
240
+public function getParameterReader(): ParameterReader
241
+{
242
+return $this->di->g(ParameterReader::class);
243
+}
244 244
 }
Please login to merge, or discard this patch.
jaxon-core/src/Plugin/Response/Psr/PsrPlugin.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@
 block discarded – undo
63 63
     public function ajaxResponse(): ResponseInterface
64 64
     {
65 65
         $xPsrResponse = $this->xPsr17Factory->createResponse(200);
66
-        if($this->xRequest->getMethod() === 'GET')
66
+        if ($this->xRequest->getMethod() === 'GET')
67 67
         {
68 68
             $xPsrResponse = $xPsrResponse
69 69
                 ->withHeader('Expires', 'Mon, 26 Jul 1997 05:00:00 GMT')
Please login to merge, or discard this patch.
jaxon-core/src/Plugin/Code/ConfigScriptGenerator.php 1 patch
Spacing   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -52,8 +52,7 @@
 block discarded – undo
52 52
     public function getScript(): string
53 53
     {
54 54
         // It is important to call $this->xParameterReader->uri() only if necessary.
55
-        $sUri = $this->xConfigManager->getOption('core.request.uri') ?:
56
-            $this->xParameterReader->uri();
55
+        $sUri = $this->xConfigManager->getOption('core.request.uri') ?: $this->xParameterReader->uri();
57 56
         $aOptions = [
58 57
             'sResponseType'      => 'JSON',
59 58
             'sVersion'           => $this->option('core.version'),
Please login to merge, or discard this patch.
jaxon-core/src/Plugin/Code/CodeGenerator.php 1 patch
Spacing   +20 added lines, -22 removed lines patch added patch discarded remove patch
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
      */
110 110
     public function addCodeGenerator(string $sClassName, int $nPriority): void
111 111
     {
112
-        while(isset($this->aCodeGenerators[$nPriority]))
112
+        while (isset($this->aCodeGenerators[$nPriority]))
113 113
         {
114 114
             $nPriority++;
115 115
         }
@@ -163,33 +163,33 @@  discard block
 block discarded – undo
163 163
      */
164 164
     private function generatePluginCodes(CodeGeneratorInterface $xGenerator): void
165 165
     {
166
-        if(!is_subclass_of($xGenerator, AbstractPlugin::class) ||
166
+        if (!is_subclass_of($xGenerator, AbstractPlugin::class) ||
167 167
             $this->xAssetManager->shallIncludeAssets($xGenerator))
168 168
         {
169 169
             // HTML tags for CSS
170
-            if(($sCss = trim($xGenerator->getCss(), " \n")) !== '')
170
+            if (($sCss = trim($xGenerator->getCss(), " \n")) !== '')
171 171
             {
172 172
                 $this->aCss[] = $sCss;
173 173
             }
174 174
             // HTML tags for js
175
-            if(($sJs = trim($xGenerator->getJs(), " \n")) !== '')
175
+            if (($sJs = trim($xGenerator->getJs(), " \n")) !== '')
176 176
             {
177 177
                 $this->aJs[] = $sJs;
178 178
             }
179 179
         }
180 180
 
181 181
         // Additional js codes
182
-        if(($xJsCode = $xGenerator->getJsCode()) !== null)
182
+        if (($xJsCode = $xGenerator->getJsCode()) !== null)
183 183
         {
184
-            if(($sJs = trim($xJsCode->sJs, " \n")) !== '')
184
+            if (($sJs = trim($xJsCode->sJs, " \n")) !== '')
185 185
             {
186 186
                 $this->aCodeJs[] = $sJs;
187 187
             }
188
-            if(($sJsBefore = trim($xJsCode->sJsBefore, " \n")) !== '')
188
+            if (($sJsBefore = trim($xJsCode->sJsBefore, " \n")) !== '')
189 189
             {
190 190
                 $this->aCodeJsBefore[] = $sJsBefore;
191 191
             }
192
-            if(($sJsAfter = trim($xJsCode->sJsAfter, " \n")) !== '')
192
+            if (($sJsAfter = trim($xJsCode->sJsAfter, " \n")) !== '')
193 193
             {
194 194
                 $this->aCodeJsAfter[] = $sJsAfter;
195 195
             }
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
      */
206 206
     private function generateCodes(): void
207 207
     {
208
-        if($this->bGenerated)
208
+        if ($this->bGenerated)
209 209
         {
210 210
             return;
211 211
         }
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
         // Sort the code generators by ascending priority
217 217
         ksort($this->aCodeGenerators);
218 218
 
219
-        foreach($this->aCodeGenerators as $sClassName)
219
+        foreach ($this->aCodeGenerators as $sClassName)
220 220
         {
221 221
             $this->generatePluginCodes($this->getCodeGenerator($sClassName));
222 222
         }
@@ -261,11 +261,11 @@  discard block
 block discarded – undo
261 261
      */
262 262
     public function getJsScript(): string
263 263
     {
264
-        foreach($this->aCodeGenerators as $sClassName)
264
+        foreach ($this->aCodeGenerators as $sClassName)
265 265
         {
266 266
             $xGenerator = $this->getCodeGenerator($sClassName);
267 267
             // Javascript code
268
-            if(($sJsScript = trim($xGenerator->getScript(), " \n")) !== '')
268
+            if (($sJsScript = trim($xGenerator->getScript(), " \n")) !== '')
269 269
             {
270 270
                 $aJsScript[] = $sJsScript;
271 271
             }
@@ -282,38 +282,36 @@  discard block
 block discarded – undo
282 282
     private function renderCodes(bool $bIncludeJs, bool $bIncludeCss): array
283 283
     {
284 284
         $aCodes = [];
285
-        if($bIncludeCss)
285
+        if ($bIncludeCss)
286 286
         {
287 287
             $aCodes[] = $this->getCss();
288 288
         }
289
-        if($bIncludeJs)
289
+        if ($bIncludeJs)
290 290
         {
291 291
             $aCodes[] = $this->getJs();
292 292
         }
293 293
 
294
-        $sUrl = !$this->xAssetManager->shallCreateJsFiles() ? '' :
295
-            $this->xAssetManager->createJsFiles($this);
294
+        $sUrl = !$this->xAssetManager->shallCreateJsFiles() ? '' : $this->xAssetManager->createJsFiles($this);
296 295
         // Wrap the js code into the corresponding HTML tag.
297 296
         $aCodes[] = $sUrl !== '' ?
298
-            $this->render('include.js', ['sUrl' => $sUrl]) :
299
-            $this->render('wrapper.js', ['sScript' => $this->getJsScript()]);
297
+            $this->render('include.js', ['sUrl' => $sUrl]) : $this->render('wrapper.js', ['sScript' => $this->getJsScript()]);
300 298
 
301 299
         // Wrap the js codes into HTML tags.
302
-        if(count($this->aCodeJsBefore) > 0)
300
+        if (count($this->aCodeJsBefore) > 0)
303 301
         {
304 302
             $sScript = implode("\n\n", $this->aCodeJsBefore);
305 303
             $aCodes[] = $this->render('wrapper.js', ['sScript' => $sScript]);
306 304
         }
307
-        if(count($this->aCodeJs) > 0)
305
+        if (count($this->aCodeJs) > 0)
308 306
         {
309 307
             $sScript = implode("\n\n", $this->aCodeJs);
310 308
             $aCodes[] = $this->render('wrapper.js', ['sScript' => $sScript]);
311 309
         }
312
-        if(count($this->aCodeJsFiles) > 0)
310
+        if (count($this->aCodeJsFiles) > 0)
313 311
         {
314 312
             $aCodes[] = $this->render('includes.js', ['aUrls' => $this->aCodeJsFiles]);
315 313
         }
316
-        if(count($this->aCodeJsAfter) > 0)
314
+        if (count($this->aCodeJsAfter) > 0)
317 315
         {
318 316
             $sScript = implode("\n\n", $this->aCodeJsAfter);
319 317
             $aCodes[] = $this->render('wrapper.js', ['sScript' => $sScript]);
Please login to merge, or discard this patch.
jaxon-core/src/Plugin/Code/AssetManager.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
     public function shallIncludeAssets(AbstractPlugin $xPlugin): bool
74 74
     {
75 75
         $sPluginOptionName = 'assets.include.' . $xPlugin->getName();
76
-        if($this->hasLibOption($sPluginOptionName))
76
+        if ($this->hasLibOption($sPluginOptionName))
77 77
         {
78 78
             return $this->getLibOption($sPluginOptionName);
79 79
         }
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
             $this->getLibOption('js.lib.jq', "$sJsLibUri/libs/chibi/chibi$sJsExtension"),
98 98
             "$sJsLibUri/jaxon.core$sJsExtension",
99 99
         ];
100
-        if($this->getLibOption('core.debug.on'))
100
+        if ($this->getLibOption('core.debug.on'))
101 101
         {
102 102
             $sLanguage = $this->getLibOption('core.language');
103 103
             $aJsFiles[] = "$sJsLibUri/jaxon.debug$sJsExtension";
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
         // Check config options
118 118
         // - The js.app.export option must be set to true
119 119
         // - The js.app.uri and js.app.dir options must be set to non null values
120
-        if(!$this->getLibOption('js.app.export', false) ||
120
+        if (!$this->getLibOption('js.app.export', false) ||
121 121
             !$this->getLibOption('js.app.uri') || !$this->getLibOption('js.app.dir'))
122 122
         {
123 123
             return false;
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
         $sJsFileName = $this->getLibOption('js.app.file') ?: $xCodeGenerator->getHash();
139 139
         $sJsDirectory = rtrim($this->getLibOption('js.app.dir'), '\/') . DIRECTORY_SEPARATOR;
140 140
         // - The js.app.dir must be writable
141
-        if(!$sJsFileName || !is_dir($sJsDirectory) || !is_writable($sJsDirectory))
141
+        if (!$sJsFileName || !is_dir($sJsDirectory) || !is_writable($sJsDirectory))
142 142
         {
143 143
             return '';
144 144
         }
@@ -147,16 +147,16 @@  discard block
 block discarded – undo
147 147
         $sJsMinFilePath = $sJsDirectory . $sJsFileName . '.min.js';
148 148
         $sJsFileUri = rtrim($this->getLibOption('js.app.uri'), '/') . "/$sJsFileName";
149 149
 
150
-        if(!is_file($sJsFilePath) &&
150
+        if (!is_file($sJsFilePath) &&
151 151
             !@file_put_contents($sJsFilePath, $xCodeGenerator->getJsScript()))
152 152
         {
153 153
             return '';
154 154
         }
155
-        if(!$this->getLibOption('js.app.minify', false))
155
+        if (!$this->getLibOption('js.app.minify', false))
156 156
         {
157 157
             return $sJsFileUri . '.js';
158 158
         }
159
-        if(!is_file($sJsMinFilePath) &&
159
+        if (!is_file($sJsMinFilePath) &&
160 160
             !$this->xMinifier->minify($sJsFilePath, $sJsMinFilePath))
161 161
         {
162 162
             // If the file cannot be minified, return the plain js file.
Please login to merge, or discard this patch.
jaxon-core/src/Plugin/Request/CallableClass/ComponentOptions.php 3 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -226,8 +226,7 @@
 block discarded – undo
226 226
             if(is_array($xMethodToCall))
227 227
             {
228 228
                 $aHookMethods[$sCalledMethod] = array_merge($aHookMethods[$sCalledMethod], $xMethodToCall);
229
-            }
230
-            elseif(is_string($xMethodToCall))
229
+            } elseif(is_string($xMethodToCall))
231 230
             {
232 231
                 $aHookMethods[$sCalledMethod][] = $xMethodToCall;
233 232
             }
Please login to merge, or discard this patch.
Spacing   +21 added lines, -23 removed lines patch added patch discarded remove patch
@@ -88,29 +88,29 @@  discard block
 block discarded – undo
88 88
         array $aProtectedMethods = [], array $aProperties = [])
89 89
     {
90 90
         $this->bExcluded = $bExcluded || (bool)($aOptions['excluded'] ?? false);
91
-        if($this->bExcluded)
91
+        if ($this->bExcluded)
92 92
         {
93 93
             return;
94 94
         }
95 95
 
96 96
         $sSeparator = $aOptions['separator'];
97
-        if($sSeparator === '_' || $sSeparator === '.')
97
+        if ($sSeparator === '_' || $sSeparator === '.')
98 98
         {
99 99
             $this->sSeparator = $sSeparator;
100 100
         }
101 101
         $this->addProtectedMethods($aOptions['protected']);
102 102
         $this->addProtectedMethods($aProtectedMethods);
103 103
 
104
-        foreach($aOptions['functions'] as $sNames => $aFunctionOptions)
104
+        foreach ($aOptions['functions'] as $sNames => $aFunctionOptions)
105 105
         {
106 106
             // Names are in a comma-separated list.
107 107
             $aFunctionNames = explode(',', $sNames);
108
-            foreach($aFunctionNames as $sFunctionName)
108
+            foreach ($aFunctionNames as $sFunctionName)
109 109
             {
110 110
                 $this->addFunctionOptions($sFunctionName, $aFunctionOptions);
111 111
             }
112 112
         }
113
-        foreach($aProperties as $sFunctionName => $aFunctionOptions)
113
+        foreach ($aProperties as $sFunctionName => $aFunctionOptions)
114 114
         {
115 115
             $this->addFunctionOptions($sFunctionName, $aFunctionOptions);
116 116
         }
@@ -123,13 +123,13 @@  discard block
 block discarded – undo
123 123
      */
124 124
     private function addProtectedMethods(array|string $xMethods): void
125 125
     {
126
-        if(!is_array($xMethods))
126
+        if (!is_array($xMethods))
127 127
         {
128 128
             $this->aProtectedMethods[trim((string)$xMethods)] = true;
129 129
             return;
130 130
         }
131 131
 
132
-        foreach($xMethods as $sMethod)
132
+        foreach ($xMethods as $sMethod)
133 133
         {
134 134
             $this->aProtectedMethods[trim((string)$sMethod)] = true;
135 135
         }
@@ -206,17 +206,17 @@  discard block
 block discarded – undo
206 206
      */
207 207
     private function setHookMethods(array &$aHookMethods, $xValue): void
208 208
     {
209
-        foreach($xValue as $sCalledMethod => $xMethodToCall)
209
+        foreach ($xValue as $sCalledMethod => $xMethodToCall)
210 210
         {
211
-            if(!isset($aHookMethods[$sCalledMethod]))
211
+            if (!isset($aHookMethods[$sCalledMethod]))
212 212
             {
213 213
                 $aHookMethods[$sCalledMethod] = [];
214 214
             }
215
-            if(is_array($xMethodToCall))
215
+            if (is_array($xMethodToCall))
216 216
             {
217 217
                 $aHookMethods[$sCalledMethod] = array_merge($aHookMethods[$sCalledMethod], $xMethodToCall);
218 218
             }
219
-            elseif(is_string($xMethodToCall))
219
+            elseif (is_string($xMethodToCall))
220 220
             {
221 221
                 $aHookMethods[$sCalledMethod][] = $xMethodToCall;
222 222
             }
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
      */
242 242
     private function addOption(string $sName, $xValue): void
243 243
     {
244
-        switch($sName)
244
+        switch ($sName)
245 245
         {
246 246
         // Set the methods to call before processing the request
247 247
         case '__before':
@@ -269,11 +269,11 @@  discard block
 block discarded – undo
269 269
      */
270 270
     private function _addJsArrayOption(string $sFunctionName, string $sOptionName, $xOptionValue): void
271 271
     {
272
-        if(is_string($xOptionValue))
272
+        if (is_string($xOptionValue))
273 273
         {
274 274
             $xOptionValue = [$xOptionValue];
275 275
         }
276
-        if(!is_array($xOptionValue))
276
+        if (!is_array($xOptionValue))
277 277
         {
278 278
             return; // Do not save.
279 279
         }
@@ -303,10 +303,10 @@  discard block
 block discarded – undo
303 303
      */
304 304
     private function addJsOption(string $sFunctionName, string $sOptionName, $xOptionValue): void
305 305
     {
306
-        switch($sOptionName)
306
+        switch ($sOptionName)
307 307
         {
308 308
         case 'excluded':
309
-            if((bool)$xOptionValue)
309
+            if ((bool)$xOptionValue)
310 310
             {
311 311
                 $this->addProtectedMethods($sFunctionName);
312 312
             }
@@ -330,12 +330,11 @@  discard block
 block discarded – undo
330 330
      */
331 331
     private function addFunctionOptions(string $sFunctionName, array $aFunctionOptions): void
332 332
     {
333
-        foreach($aFunctionOptions as $sOptionName => $xOptionValue)
333
+        foreach ($aFunctionOptions as $sOptionName => $xOptionValue)
334 334
         {
335 335
             substr($sOptionName, 0, 2) === '__' ?
336 336
                 // Options for PHP classes. They start with "__".
337
-                $this->addOption($sOptionName, [$sFunctionName => $xOptionValue]) :
338
-                // Options for javascript code.
337
+                $this->addOption($sOptionName, [$sFunctionName => $xOptionValue]) : // Options for javascript code.
339 338
                 $this->addJsOption($sFunctionName, $sOptionName, $xOptionValue);
340 339
         }
341 340
     }
@@ -351,16 +350,15 @@  discard block
 block discarded – undo
351 350
         $aOptions = array_merge($this->aJsOptions['*'] ?? []); // Clone the array
352 351
         // Then add the method options.
353 352
         $aMethodOptions = $this->aJsOptions[$sMethodName] ?? [];
354
-        foreach($aMethodOptions as $sOptionName => $xOptionValue)
353
+        foreach ($aMethodOptions as $sOptionName => $xOptionValue)
355 354
         {
356 355
             // For databags and callbacks, merge the values in a single array.
357 356
             // For all the other options, keep the last value.
358 357
             $aOptions[$sOptionName] = !in_array($sOptionName, ['bags', 'callback']) ?
359
-                $xOptionValue :
360
-                array_unique(array_merge($aOptions[$sOptionName] ?? [], $xOptionValue));
358
+                $xOptionValue : array_unique(array_merge($aOptions[$sOptionName] ?? [], $xOptionValue));
361 359
         }
362 360
         // Since callbacks are js object names, they need a special formatting.
363
-        if(isset($aOptions['callback']))
361
+        if (isset($aOptions['callback']))
364 362
         {
365 363
             $aOptions['callback'] = str_replace('"', '', json_encode($aOptions['callback']));
366 364
         }
Please login to merge, or discard this patch.
Switch Indentation   +137 added lines, -137 removed lines patch added patch discarded remove patch
@@ -27,56 +27,56 @@  discard block
 block discarded – undo
27 27
 
28 28
 class ComponentOptions
29 29
 {
30
-    /**
30
+/**
31 31
      * Check if the js code for this object must be generated
32 32
      *
33 33
      * @var bool
34 34
      */
35
-    private $bExcluded = false;
35
+private $bExcluded = false;
36 36
 
37
-    /**
37
+/**
38 38
      * The character to use as separator in javascript class names
39 39
      *
40 40
      * @var string
41 41
      */
42
-    private $sSeparator = '.';
42
+private $sSeparator = '.';
43 43
 
44
-    /**
44
+/**
45 45
      * A list of methods of the user registered callable object the library must not export to javascript
46 46
      *
47 47
      * @var array
48 48
      */
49
-    private $aProtectedMethods = [];
49
+private $aProtectedMethods = [];
50 50
 
51
-    /**
51
+/**
52 52
      * A list of methods to call before processing the request
53 53
      *
54 54
      * @var array
55 55
      */
56
-    private $aBeforeMethods = [];
56
+private $aBeforeMethods = [];
57 57
 
58
-    /**
58
+/**
59 59
      * A list of methods to call after processing the request
60 60
      *
61 61
      * @var array
62 62
      */
63
-    private $aAfterMethods = [];
63
+private $aAfterMethods = [];
64 64
 
65
-    /**
65
+/**
66 66
      * The javascript class options
67 67
      *
68 68
      * @var array
69 69
      */
70
-    private $aJsOptions = [];
70
+private $aJsOptions = [];
71 71
 
72
-    /**
72
+/**
73 73
      * The DI options
74 74
      *
75 75
      * @var array
76 76
      */
77
-    private $aDiOptions = [];
77
+private $aDiOptions = [];
78 78
 
79
-    /**
79
+/**
80 80
      * The constructor
81 81
      *
82 82
      * @param array $aOptions
@@ -84,119 +84,119 @@  discard block
 block discarded – undo
84 84
      * @param array $aProtectedMethods
85 85
      * @param array $aProperties
86 86
      */
87
-    public function __construct(array $aOptions, bool $bExcluded = false,
88
-        array $aProtectedMethods = [], array $aProperties = [])
89
-    {
90
-        $this->bExcluded = $bExcluded || (bool)($aOptions['excluded'] ?? false);
91
-        if($this->bExcluded)
92
-        {
93
-            return;
94
-        }
87
+public function __construct(array $aOptions, bool $bExcluded = false,
88
+array $aProtectedMethods = [], array $aProperties = [])
89
+{
90
+$this->bExcluded = $bExcluded || (bool)($aOptions['excluded'] ?? false);
91
+if($this->bExcluded)
92
+{
93
+return;
94
+}
95 95
 
96
-        $sSeparator = $aOptions['separator'];
97
-        if($sSeparator === '_' || $sSeparator === '.')
98
-        {
99
-            $this->sSeparator = $sSeparator;
100
-        }
101
-        $this->addProtectedMethods($aOptions['protected']);
102
-        $this->addProtectedMethods($aProtectedMethods);
96
+$sSeparator = $aOptions['separator'];
97
+if($sSeparator === '_' || $sSeparator === '.')
98
+{
99
+$this->sSeparator = $sSeparator;
100
+}
101
+$this->addProtectedMethods($aOptions['protected']);
102
+$this->addProtectedMethods($aProtectedMethods);
103 103
 
104
-        foreach($aOptions['functions'] as $sNames => $aFunctionOptions)
105
-        {
106
-            // Names are in a comma-separated list.
107
-            $aFunctionNames = explode(',', $sNames);
108
-            foreach($aFunctionNames as $sFunctionName)
109
-            {
110
-                $this->addFunctionOptions($sFunctionName, $aFunctionOptions);
111
-            }
112
-        }
113
-        foreach($aProperties as $sFunctionName => $aFunctionOptions)
114
-        {
115
-            $this->addFunctionOptions($sFunctionName, $aFunctionOptions);
116
-        }
117
-    }
104
+foreach($aOptions['functions'] as $sNames => $aFunctionOptions)
105
+{
106
+// Names are in a comma-separated list.
107
+$aFunctionNames = explode(',', $sNames);
108
+foreach($aFunctionNames as $sFunctionName)
109
+{
110
+    $this->addFunctionOptions($sFunctionName, $aFunctionOptions);
111
+}
112
+}
113
+foreach($aProperties as $sFunctionName => $aFunctionOptions)
114
+{
115
+$this->addFunctionOptions($sFunctionName, $aFunctionOptions);
116
+}
117
+}
118 118
 
119
-    /**
119
+/**
120 120
      * @param array|string $xMethods
121 121
      *
122 122
      * @return void
123 123
      */
124
-    private function addProtectedMethods(array|string $xMethods): void
125
-    {
126
-        if(!is_array($xMethods))
127
-        {
128
-            $this->aProtectedMethods[trim((string)$xMethods)] = true;
129
-            return;
130
-        }
124
+private function addProtectedMethods(array|string $xMethods): void
125
+{
126
+if(!is_array($xMethods))
127
+{
128
+$this->aProtectedMethods[trim((string)$xMethods)] = true;
129
+return;
130
+}
131 131
 
132
-        foreach($xMethods as $sMethod)
133
-        {
134
-            $this->aProtectedMethods[trim((string)$sMethod)] = true;
135
-        }
136
-    }
132
+foreach($xMethods as $sMethod)
133
+{
134
+$this->aProtectedMethods[trim((string)$sMethod)] = true;
135
+}
136
+}
137 137
 
138
-    /**
138
+/**
139 139
      * @param string $sMethodName
140 140
      *
141 141
      * @return bool
142 142
      */
143
-    public function isProtectedMethod(string $sMethodName): bool
144
-    {
145
-        return isset($this->aProtectedMethods['*']) ||
146
-            isset($this->aProtectedMethods[$sMethodName]);
147
-    }
143
+public function isProtectedMethod(string $sMethodName): bool
144
+{
145
+return isset($this->aProtectedMethods['*']) ||
146
+isset($this->aProtectedMethods[$sMethodName]);
147
+}
148 148
 
149
-    /**
149
+/**
150 150
      * Check if the js code for this object must be generated
151 151
      *
152 152
      * @return bool
153 153
      */
154
-    public function excluded(): bool
155
-    {
156
-        return $this->bExcluded;
157
-    }
154
+public function excluded(): bool
155
+{
156
+return $this->bExcluded;
157
+}
158 158
 
159
-    /**
159
+/**
160 160
      * @return string
161 161
      */
162
-    public function separator(): string
163
-    {
164
-        return $this->sSeparator;
165
-    }
162
+public function separator(): string
163
+{
164
+return $this->sSeparator;
165
+}
166 166
 
167
-    /**
167
+/**
168 168
      * @return array
169 169
      */
170
-    public function beforeMethods(): array
171
-    {
172
-        return $this->aBeforeMethods;
173
-    }
170
+public function beforeMethods(): array
171
+{
172
+return $this->aBeforeMethods;
173
+}
174 174
 
175
-    /**
175
+/**
176 176
      * @return array
177 177
      */
178
-    public function afterMethods(): array
179
-    {
180
-        return $this->aAfterMethods;
181
-    }
178
+public function afterMethods(): array
179
+{
180
+return $this->aAfterMethods;
181
+}
182 182
 
183
-    /**
183
+/**
184 184
      * @return array
185 185
      */
186
-    public function diOptions(): array
187
-    {
188
-        return $this->aDiOptions;
189
-    }
186
+public function diOptions(): array
187
+{
188
+return $this->aDiOptions;
189
+}
190 190
 
191
-    /**
191
+/**
192 192
      * @return array
193 193
      */
194
-    public function jsOptions(): array
195
-    {
196
-        return $this->aJsOptions;
197
-    }
194
+public function jsOptions(): array
195
+{
196
+return $this->aJsOptions;
197
+}
198 198
 
199
-    /**
199
+/**
200 200
      * Set hook methods
201 201
      *
202 202
      * @param array $aHookMethods    The array of hook methods
@@ -204,34 +204,34 @@  discard block
 block discarded – undo
204 204
      *
205 205
      * @return void
206 206
      */
207
-    private function setHookMethods(array &$aHookMethods, $xValue): void
208
-    {
209
-        foreach($xValue as $sCalledMethod => $xMethodToCall)
210
-        {
211
-            if(!isset($aHookMethods[$sCalledMethod]))
212
-            {
213
-                $aHookMethods[$sCalledMethod] = [];
214
-            }
215
-            if(is_array($xMethodToCall))
216
-            {
217
-                $aHookMethods[$sCalledMethod] = array_merge($aHookMethods[$sCalledMethod], $xMethodToCall);
218
-            }
219
-            elseif(is_string($xMethodToCall))
220
-            {
221
-                $aHookMethods[$sCalledMethod][] = $xMethodToCall;
222
-            }
223
-        }
224
-    }
207
+private function setHookMethods(array &$aHookMethods, $xValue): void
208
+{
209
+foreach($xValue as $sCalledMethod => $xMethodToCall)
210
+{
211
+if(!isset($aHookMethods[$sCalledMethod]))
212
+{
213
+    $aHookMethods[$sCalledMethod] = [];
214
+}
215
+if(is_array($xMethodToCall))
216
+{
217
+    $aHookMethods[$sCalledMethod] = array_merge($aHookMethods[$sCalledMethod], $xMethodToCall);
218
+}
219
+elseif(is_string($xMethodToCall))
220
+{
221
+    $aHookMethods[$sCalledMethod][] = $xMethodToCall;
222
+}
223
+}
224
+}
225 225
 
226
-    /**
226
+/**
227 227
      * @param array $aDiOptions
228 228
      */
229
-    private function addDiOption(array $aDiOptions): void
230
-    {
231
-        $this->aDiOptions = array_merge($this->aDiOptions, $aDiOptions);
232
-    }
229
+private function addDiOption(array $aDiOptions): void
230
+{
231
+$this->aDiOptions = array_merge($this->aDiOptions, $aDiOptions);
232
+}
233 233
 
234
-    /**
234
+/**
235 235
      * Set configuration options / call options for each method
236 236
      *
237 237
      * @param string $sName    The name of the configuration option
@@ -239,25 +239,25 @@  discard block
 block discarded – undo
239 239
      *
240 240
      * @return void
241 241
      */
242
-    private function addOption(string $sName, $xValue): void
243
-    {
244
-        switch($sName)
245
-        {
246
-        // Set the methods to call before processing the request
247
-        case '__before':
248
-            $this->setHookMethods($this->aBeforeMethods, $xValue);
249
-            break;
250
-        // Set the methods to call after processing the request
251
-        case '__after':
252
-            $this->setHookMethods($this->aAfterMethods, $xValue);
253
-            break;
254
-        // Set the attributes to inject in the callable object
255
-        case '__di':
256
-            $this->addDiOption($xValue);
257
-            break;
258
-        default:
259
-            break;
260
-        }
242
+private function addOption(string $sName, $xValue): void
243
+{
244
+switch($sName)
245
+{
246
+// Set the methods to call before processing the request
247
+case '__before':
248
+$this->setHookMethods($this->aBeforeMethods, $xValue);
249
+break;
250
+// Set the methods to call after processing the request
251
+case '__after':
252
+$this->setHookMethods($this->aAfterMethods, $xValue);
253
+break;
254
+// Set the attributes to inject in the callable object
255
+case '__di':
256
+$this->addDiOption($xValue);
257
+break;
258
+default:
259
+break;
260
+}
261 261
     }
262 262
 
263 263
     /**
Please login to merge, or discard this patch.
jaxon-core/src/Plugin/Request/CallableClass/SortedFileIterator.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@
 block discarded – undo
28 28
     public function __construct(string $sDirectory)
29 29
     {
30 30
         $itFile = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($sDirectory));
31
-        foreach($itFile as $xFile)
31
+        foreach ($itFile as $xFile)
32 32
         {
33 33
             $this->insert($xFile);
34 34
         }
Please login to merge, or discard this patch.