@@ -17,14 +17,14 @@ |
||
17 | 17 | |
18 | 18 | trait HtmlDomTrait |
19 | 19 | { |
20 | - /** |
|
21 | - * Add a response command to the array of commands that will be sent to the browser |
|
22 | - * |
|
23 | - * @param string $sName The command name |
|
24 | - * @param array|JsonSerializable $aOptions The command options |
|
25 | - * |
|
26 | - * @return ResponseInterface |
|
27 | - */ |
|
20 | + /** |
|
21 | + * Add a response command to the array of commands that will be sent to the browser |
|
22 | + * |
|
23 | + * @param string $sName The command name |
|
24 | + * @param array|JsonSerializable $aOptions The command options |
|
25 | + * |
|
26 | + * @return ResponseInterface |
|
27 | + */ |
|
28 | 28 | abstract public function addCommand(string $sName, array|JsonSerializable $aOptions): ResponseInterface; |
29 | 29 | |
30 | 30 | /** |
@@ -25,7 +25,7 @@ |
||
25 | 25 | * |
26 | 26 | * @return ResponseInterface |
27 | 27 | */ |
28 | - abstract public function addCommand(string $sName, array|JsonSerializable $aOptions): ResponseInterface; |
|
28 | + abstract public function addCommand(string $sName, array | JsonSerializable $aOptions): ResponseInterface; |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * Add a command to assign the specified value to the given element's attribute |
@@ -61,8 +61,7 @@ discard block |
||
61 | 61 | public function appendCommands(array $aCommands, bool $bBefore = false) |
62 | 62 | { |
63 | 63 | $this->aCommands = ($bBefore) ? |
64 | - array_merge($aCommands, $this->aCommands) : |
|
65 | - array_merge($this->aCommands, $aCommands); |
|
64 | + array_merge($aCommands, $this->aCommands) : array_merge($this->aCommands, $aCommands); |
|
66 | 65 | } |
67 | 66 | |
68 | 67 | /** |
@@ -86,7 +85,7 @@ discard block |
||
86 | 85 | * |
87 | 86 | * @return ResponseInterface |
88 | 87 | */ |
89 | - public function addCommand(string $sName, array|JsonSerializable $aOptions): ResponseInterface |
|
88 | + public function addCommand(string $sName, array | JsonSerializable $aOptions): ResponseInterface |
|
90 | 89 | { |
91 | 90 | $this->aCommands[] = [ |
92 | 91 | 'cmd' => $this->str($sName), |
@@ -105,7 +104,7 @@ discard block |
||
105 | 104 | * @return ResponseInterface |
106 | 105 | */ |
107 | 106 | public function addPluginCommand(ResponsePlugin $xPlugin, string $sName, |
108 | - array|JsonSerializable $aOptions): ResponseInterface |
|
107 | + array | JsonSerializable $aOptions): ResponseInterface |
|
109 | 108 | { |
110 | 109 | $this->aCommands[] = [ |
111 | 110 | 'cmd' => $this->str($sName), |
@@ -124,7 +123,7 @@ discard block |
||
124 | 123 | */ |
125 | 124 | protected function str($xData): string |
126 | 125 | { |
127 | - return trim((string)$xData, " \t\n"); |
|
126 | + return trim((string) $xData, " \t\n"); |
|
128 | 127 | } |
129 | 128 | |
130 | 129 | /** |
@@ -136,10 +135,10 @@ discard block |
||
136 | 135 | * |
137 | 136 | * @return ResponseInterface |
138 | 137 | */ |
139 | - protected function _addCommand(string $sName, array|JsonSerializable $aOptions, |
|
138 | + protected function _addCommand(string $sName, array | JsonSerializable $aOptions, |
|
140 | 139 | bool $bRemoveEmpty = false): ResponseInterface |
141 | 140 | { |
142 | - if($bRemoveEmpty) |
|
141 | + if ($bRemoveEmpty) |
|
143 | 142 | { |
144 | 143 | $aOptions = array_filter($aOptions, function($xOption) { |
145 | 144 | return $xOption === ''; |
@@ -20,14 +20,14 @@ |
||
20 | 20 | |
21 | 21 | trait ScriptTrait |
22 | 22 | { |
23 | - /** |
|
24 | - * Add a response command to the array of commands that will be sent to the browser |
|
25 | - * |
|
26 | - * @param string $sName The command name |
|
27 | - * @param array|JsonSerializable $aOptions The command options |
|
28 | - * |
|
29 | - * @return ResponseInterface |
|
30 | - */ |
|
23 | + /** |
|
24 | + * Add a response command to the array of commands that will be sent to the browser |
|
25 | + * |
|
26 | + * @param string $sName The command name |
|
27 | + * @param array|JsonSerializable $aOptions The command options |
|
28 | + * |
|
29 | + * @return ResponseInterface |
|
30 | + */ |
|
31 | 31 | abstract public function addCommand(string $sName, array|JsonSerializable $aOptions): ResponseInterface; |
32 | 32 | |
33 | 33 | /** |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return ResponseInterface |
30 | 30 | */ |
31 | - abstract public function addCommand(string $sName, array|JsonSerializable $aOptions): ResponseInterface; |
|
31 | + abstract public function addCommand(string $sName, array | JsonSerializable $aOptions): ResponseInterface; |
|
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Response command that prompts user with [ok] [cancel] style message box |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | { |
61 | 61 | $aArgs = func_get_args(); |
62 | 62 | array_shift($aArgs); |
63 | - return $this->addCommand('script.call', ['func' => $this->str($sFunc),'args' => $aArgs]); |
|
63 | + return $this->addCommand('script.call', ['func' => $this->str($sFunc), 'args' => $aArgs]); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -73,7 +73,7 @@ |
||
73 | 73 | * @return ResponseInterface |
74 | 74 | */ |
75 | 75 | public function addPluginCommand(ResponsePlugin $xPlugin, string $sName, |
76 | - array|JsonSerializable $aOptions): ResponseInterface; |
|
76 | + array | JsonSerializable $aOptions): ResponseInterface; |
|
77 | 77 | |
78 | 78 | /** |
79 | 79 | * Convert this response to a PSR7 response object |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | */ |
124 | 124 | public function addParameters(array $aParameters): JsCall |
125 | 125 | { |
126 | - foreach($aParameters as $xParameter) |
|
126 | + foreach ($aParameters as $xParameter) |
|
127 | 127 | { |
128 | 128 | $this->pushParameter(Parameter::make($xParameter)); |
129 | 129 | } |
@@ -144,12 +144,12 @@ discard block |
||
144 | 144 | return $xParam->jsonSerialize(); |
145 | 145 | }, $this->aParameters), |
146 | 146 | ]]; |
147 | - if($this->bToInt) |
|
147 | + if ($this->bToInt) |
|
148 | 148 | { |
149 | 149 | $aCalls[] = [ |
150 | 150 | '_type' => 'func', |
151 | 151 | '_name' => 'jaxon.utils.string.toInt', |
152 | - 'params' => [[ '_type' => '_', '_name' => 'this' ]], |
|
152 | + 'params' => [['_type' => '_', '_name' => 'this']], |
|
153 | 153 | ]; |
154 | 154 | } |
155 | 155 | return [ |
@@ -75,7 +75,7 @@ |
||
75 | 75 | public function selector(string $sPath = '', $xContext = null): DomSelector |
76 | 76 | { |
77 | 77 | $xSelector = new DomSelector($sPath, $xContext); |
78 | - if($this->bCommand && $this->response() !== null) |
|
78 | + if ($this->bCommand && $this->response() !== null) |
|
79 | 79 | { |
80 | 80 | $this->addCommand('jquery.call', ['selector' => $xSelector]); |
81 | 81 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | */ |
40 | 40 | private function initDataBag() |
41 | 41 | { |
42 | - if($this->xDataBag !== null) |
|
42 | + if ($this->xDataBag !== null) |
|
43 | 43 | { |
44 | 44 | return; |
45 | 45 | } |
@@ -48,8 +48,7 @@ discard block |
||
48 | 48 | $aBody = $xRequest->getParsedBody(); |
49 | 49 | $aParams = $xRequest->getQueryParams(); |
50 | 50 | $aData = is_array($aBody) ? |
51 | - $this->readData($aBody['jxnbags'] ?? []) : |
|
52 | - $this->readData($aParams['jxnbags'] ?? []); |
|
51 | + $this->readData($aBody['jxnbags'] ?? []) : $this->readData($aParams['jxnbags'] ?? []); |
|
53 | 52 | $this->xDataBag = new DataBag($aData); |
54 | 53 | } |
55 | 54 | |
@@ -70,8 +69,7 @@ discard block |
||
70 | 69 | { |
71 | 70 | // Todo: clean input data. |
72 | 71 | return is_string($xData) ? |
73 | - (json_decode($xData, true) ?: []) : |
|
74 | - (is_array($xData) ? $xData : []); |
|
72 | + (json_decode($xData, true) ?: []) : (is_array($xData) ? $xData : []); |
|
75 | 73 | } |
76 | 74 | |
77 | 75 | /** |
@@ -89,7 +87,7 @@ discard block |
||
89 | 87 | public function writeCommand() |
90 | 88 | { |
91 | 89 | $this->initDataBag(); |
92 | - if($this->xDataBag->touched()) |
|
90 | + if ($this->xDataBag->touched()) |
|
93 | 91 | { |
94 | 92 | $this->addCommand('databag.set', ['values' => $this->xDataBag]); |
95 | 93 | } |