Skip to content

Commit 6f7cef5

Browse files
committed
[skip ci] Update PHP type hints and minimum version requirement
Added explicit type hints and nullable types to methods in JsUtils.php for improved type safety and compatibility with PHP 8+. Updated composer.json to require PHP >=8.5.
1 parent bfcee26 commit 6f7cef5

File tree

2 files changed

+22
-21
lines changed

2 files changed

+22
-21
lines changed

Ajax/JsUtils.php

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,10 @@ abstract public function fromDispatcher($dispatcher);
117117
/**
118118
* getter or setter of the jQuery-UI variable
119119
*
120-
* @param JqueryUI $ui
120+
* @param JqueryUI|null $ui
121121
* @return JqueryUI
122122
*/
123-
public function ui(JqueryUI $ui = NULL) {
123+
public function ui(?JqueryUI $ui = NULL) {
124124
if ($ui !== NULL) {
125125
$this->_ui = $ui;
126126
$ui->setJs($this);
@@ -135,10 +135,10 @@ public function ui(JqueryUI $ui = NULL) {
135135
/**
136136
* getter or setter of the Twitter Bootstrap variable
137137
*
138-
* @param Bootstrap $bootstrap
138+
* @param Bootstrap|null $bootstrap
139139
* @return Bootstrap
140140
*/
141-
public function bootstrap(Bootstrap $bootstrap = NULL) {
141+
public function bootstrap(?Bootstrap $bootstrap = NULL) {
142142
if ($bootstrap !== NULL) {
143143
$this->_bootstrap = $bootstrap;
144144
$bootstrap->setJs($this);
@@ -153,10 +153,10 @@ public function bootstrap(Bootstrap $bootstrap = NULL) {
153153
/**
154154
* getter or setter of the Semantic-UI variable
155155
*
156-
* @param Semantic $semantic
156+
* @param Semantic|null $semantic
157157
* @return Semantic
158158
*/
159-
public function semantic(Semantic $semantic = NULL) {
159+
public function semantic(?Semantic $semantic = NULL) {
160160
if ($semantic !== NULL) {
161161
$this->_semantic = $semantic;
162162
$semantic->setJs($this);
@@ -170,10 +170,10 @@ public function semantic(Semantic $semantic = NULL) {
170170

171171
/**
172172
*
173-
* @param Config $config
173+
* @param Config|null $config
174174
* @return Config
175175
*/
176-
public function config($config = NULL) {
176+
public function config(Config $config = NULL) {
177177
if ($config === NULL) {
178178
if ($this->config === NULL) {
179179
$this->config = new DefaultConfig();
@@ -190,10 +190,10 @@ public function config($config = NULL) {
190190
*
191191
* @param array $params
192192
* ['debug'=>true,'defer'=>false,'ajax'=>['ajaxTransition'=>null,'attr'=>'','historize'=>false,'attr'=>''],'beforeCompileHtml'=>null,'semantic'=>false,'bootstrap'=>false,'historize'=>true,'autoActiveLinks'=>true]
193-
* @param mixed $injected
193+
* @param mixed|null $injected
194194
* optional param for Symfony/Ubiquity
195195
*/
196-
public function __construct($params = array(), $injected = NULL) {
196+
public function __construct(array $params = array(), mixed $injected = NULL) {
197197
$ajaxDefault = [
198198
'ajaxTransition' => null,
199199
'attr' => '',
@@ -269,7 +269,7 @@ public function __set($property, $value) {
269269
$this->bootstrap($value);
270270
break;
271271
case "semantic":
272-
$this->semantic(value);
272+
$this->semantic($value);
273273
break;
274274
case "ui":
275275
$this->ui($value);
@@ -283,7 +283,7 @@ public function __set($property, $value) {
283283
*
284284
* @param string $key
285285
*/
286-
public function getParam($key) {
286+
public function getParam(string $key) {
287287
if (isset($this->params[$key]))
288288
return $this->params[$key];
289289
}
@@ -310,13 +310,14 @@ public function output($array_js) {
310310
/**
311311
* gather together all script needing to be output
312312
*
313-
* @param object $view
313+
* @param object|null $view
314314
* @param string $view_var
315315
* view script variable name, default : script_foot
316316
* @param boolean $script_tags
317317
* @return string
318318
*/
319-
public function compile(&$view = NULL, $view_var = 'script_foot', $script_tags = TRUE) {
319+
public function compile(?object &$view = NULL, string $view_var = 'script_foot', bool $script_tags = TRUE): string
320+
{
320321
if (isset($this->_ui)) {
321322
$this->_compileLibrary($this->_ui, $view);
322323
}
@@ -330,7 +331,7 @@ public function compile(&$view = NULL, $view_var = 'script_foot', $script_tags =
330331
$this->jquery_code_for_compile = \array_merge($this->jquery_code_for_compile, $this->jquery_code_for_compile_at_last);
331332

332333
if (\count($this->jquery_code_for_compile) == 0) {
333-
return;
334+
return '';
334335
}
335336

336337
// Inline references
@@ -358,7 +359,7 @@ public function compile(&$view = NULL, $view_var = 'script_foot', $script_tags =
358359
*
359360
* @return void
360361
*/
361-
public function clear_compile() {
362+
public function clear_compile(): void {
362363
$this->jquery_code_for_compile = $this->jquery_code_for_compile_at_last = [];
363364
if($this->_bootstrap!==null){
364365
$this->_bootstrap->clearComponents();
@@ -371,15 +372,15 @@ public function clear_compile() {
371372
}
372373
}
373374

374-
public function getScript($offset = 0) {
375+
public function getScript(int $offset = 0): string {
375376
$code = \array_merge($this->jquery_code_for_compile, $this->jquery_code_for_compile_at_last);
376377
if ($offset > 0) {
377378
$code = \array_slice($code, $offset);
378379
}
379380
return \implode('', $code);
380381
}
381382

382-
public function scriptCount() {
383+
public function scriptCount(): int {
383384
return \count($this->jquery_code_for_compile);
384385
}
385386

@@ -407,7 +408,7 @@ public function inline($script, $cdata = TRUE) {
407408
* match array types (defaults to objects)
408409
* @return string json formatted string
409410
*/
410-
public function generate_json($result = NULL, $match_array_type = FALSE) {
411+
public function generate_json(mixed $result = NULL, bool $match_array_type = FALSE): string {
411412
// JSON data can optionally be passed to this function
412413
// either as a database result object or an array, or a user supplied array
413414
if (! is_null($result)) {
@@ -424,7 +425,7 @@ public function generate_json($result = NULL, $match_array_type = FALSE) {
424425
return $this->_create_json($json_result, $match_array_type);
425426
}
426427

427-
private function _create_json($json_result, $match_array_type) {
428+
private function _create_json($json_result, $match_array_type): string {
428429
$json = array();
429430
$_is_assoc = TRUE;
430431
if (! is_array($json_result) && empty($json_result)) {

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"framework"
1818
],
1919
"require": {
20-
"php": ">7.0",
20+
"php": ">=8.5",
2121
"frameworks/jquery": "~2.1"
2222
},
2323
"suggest": {

0 commit comments

Comments
 (0)