Passed
Push — main ( 7f530d...7aae9b )
by Thierry
05:54
created
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.
jaxon-core/src/Plugin/Response/Pagination/PaginatorPlugin.php 1 patch
Switch Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -43,60 +43,60 @@  discard block
 block discarded – undo
43 43
  */
44 44
 class PaginatorPlugin extends AbstractResponsePlugin
45 45
 {
46
-    /**
46
+/**
47 47
      * @const The plugin name
48 48
      */
49
-    public const NAME = 'pg';
49
+public const NAME = 'pg';
50 50
 
51
-    /**
51
+/**
52 52
      * The constructor.
53 53
      *
54 54
      * @param RendererInterface $xRenderer
55 55
      */
56
-    public function __construct(protected RendererInterface $xRenderer)
57
-    {}
56
+public function __construct(protected RendererInterface $xRenderer)
57
+{}
58 58
 
59
-    /**
59
+/**
60 60
      * @inheritDoc
61 61
      */
62
-    public function getName(): string
63
-    {
64
-        return self::NAME;
65
-    }
62
+public function getName(): string
63
+{
64
+return self::NAME;
65
+}
66 66
 
67
-    /**
67
+/**
68 68
      * @inheritDoc
69 69
      */
70
-    public function getHash(): string
71
-    {
72
-        return '5.0.0'; // Use the version number as hash
73
-    }
70
+public function getHash(): string
71
+{
72
+return '5.0.0'; // Use the version number as hash
73
+}
74 74
 
75
-    /**
75
+/**
76 76
      * @inheritDoc
77 77
      */
78
-    public function getCss(): string
79
-    {
80
-        return '
78
+public function getCss(): string
79
+{
80
+return '
81 81
 <style>
82 82
   .pagination li a {
83 83
     cursor: pointer;
84 84
   }
85 85
 </style>
86 86
 ';
87
-    }
87
+}
88 88
 
89
-    /**
89
+/**
90 90
      * Get the view renderer
91 91
      *
92 92
      * @return RendererInterface
93 93
      */
94
-    public function renderer(): RendererInterface
95
-    {
96
-        return $this->xRenderer;
97
-    }
94
+public function renderer(): RendererInterface
95
+{
96
+return $this->xRenderer;
97
+}
98 98
 
99
-    /**
99
+/**
100 100
      * Create a paginator
101 101
      *
102 102
      * @param int $nPageNumber     The current page number
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
      *
106 106
      * @return Paginator
107 107
      */
108
-    public function paginator(int $nPageNumber, int $nItemsPerPage, int $nTotalItems): Paginator
109
-    {
110
-        return new Paginator($this, $nPageNumber, $nItemsPerPage, $nTotalItems);
111
-    }
108
+public function paginator(int $nPageNumber, int $nItemsPerPage, int $nTotalItems): Paginator
109
+{
110
+return new Paginator($this, $nPageNumber, $nItemsPerPage, $nTotalItems);
111
+}
112 112
 }
Please login to merge, or discard this patch.
jaxon-core/src/Plugin/Response/Script/ScriptPlugin.php 1 patch
Switch Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -26,56 +26,56 @@  discard block
 block discarded – undo
26 26
 
27 27
 class ScriptPlugin extends AbstractResponsePlugin
28 28
 {
29
-    /**
29
+/**
30 30
      * @const The plugin name
31 31
      */
32
-    public const NAME = 'script';
32
+public const NAME = 'script';
33 33
 
34
-    /**
34
+/**
35 35
      * The class constructor
36 36
      *
37 37
      * @param CallFactory $xFactory
38 38
      */
39
-    public function __construct(private CallFactory $xFactory)
40
-    {}
39
+public function __construct(private CallFactory $xFactory)
40
+{}
41 41
 
42
-    /**
42
+/**
43 43
      * @return Closure
44 44
      */
45
-    private function getCallback(): Closure
46
-    {
47
-        // The closure needs to capture the response object the script plugin is called with.
48
-        $xResponse = $this->response();
49
-        return function(JsExpr $xJsExpr) use($xResponse) {
50
-            // Add the newly created expression to the response
51
-            $aOptions = [
52
-                'expr' => $xJsExpr,
53
-                'context' => is_a($xResponse, NodeResponse::class) ?
54
-                    ['component' => true] : [],
55
-            ];
56
-            $xResponse->addCommand('script.exec.expr', $aOptions)
57
-                ->setOption('plugin', $this->getName());
58
-        };
59
-    }
45
+private function getCallback(): Closure
46
+{
47
+// The closure needs to capture the response object the script plugin is called with.
48
+$xResponse = $this->response();
49
+return function(JsExpr $xJsExpr) use($xResponse) {
50
+// Add the newly created expression to the response
51
+$aOptions = [
52
+    'expr' => $xJsExpr,
53
+    'context' => is_a($xResponse, NodeResponse::class) ?
54
+        ['component' => true] : [],
55
+];
56
+$xResponse->addCommand('script.exec.expr', $aOptions)
57
+    ->setOption('plugin', $this->getName());
58
+};
59
+}
60 60
 
61
-    /**
61
+/**
62 62
      * @inheritDoc
63 63
      */
64
-    public function getName(): string
65
-    {
66
-        return self::NAME;
67
-    }
64
+public function getName(): string
65
+{
66
+return self::NAME;
67
+}
68 68
 
69
-    /**
69
+/**
70 70
      * @inheritDoc
71 71
      */
72
-    public function getHash(): string
73
-    {
74
-        // Use the version number as hash
75
-        return '5.0.0';
76
-    }
72
+public function getHash(): string
73
+{
74
+// Use the version number as hash
75
+return '5.0.0';
76
+}
77 77
 
78
-    /**
78
+/**
79 79
      * Create a JQuery selector expression, and link it to the current response.
80 80
      *
81 81
      * @param string $sPath    The jQuery selector path
@@ -83,32 +83,32 @@  discard block
 block discarded – undo
83 83
      *
84 84
      * @return JqSelectorCall
85 85
      */
86
-    public function jq(string $sPath = '', $xContext = null): JqSelectorCall
87
-    {
88
-        return $this->xFactory->jq($sPath, $xContext, $this->getCallback());
89
-    }
86
+public function jq(string $sPath = '', $xContext = null): JqSelectorCall
87
+{
88
+return $this->xFactory->jq($sPath, $xContext, $this->getCallback());
89
+}
90 90
 
91
-    /**
91
+/**
92 92
      * Create a Javascript object expression, and link it to the current response.
93 93
      *
94 94
      * @param string $sObject
95 95
      *
96 96
      * @return JsObjectCall
97 97
      */
98
-    public function jo(string $sObject = ''): JsObjectCall
99
-    {
100
-        return $this->xFactory->jo($sObject, $this->getCallback());
101
-    }
98
+public function jo(string $sObject = ''): JsObjectCall
99
+{
100
+return $this->xFactory->jo($sObject, $this->getCallback());
101
+}
102 102
 
103
-    /**
103
+/**
104 104
      * Create a Javascript element selector expression, and link it to the current response.
105 105
      *
106 106
      * @param string $sElementId
107 107
      *
108 108
      * @return JsSelectorCall
109 109
      */
110
-    public function je(string $sElementId = ''): JsSelectorCall
111
-    {
112
-        return $this->xFactory->je($sElementId, $this->getCallback());
113
-    }
110
+public function je(string $sElementId = ''): JsSelectorCall
111
+{
112
+return $this->xFactory->je($sElementId, $this->getCallback());
113
+}
114 114
 }
Please login to merge, or discard this patch.