Skip to content

Commit

Permalink
fix: PHP 8.1 updates
Browse files Browse the repository at this point in the history
  • Loading branch information
daylightstudio committed Apr 25, 2022
1 parent 7228adc commit 7bf6ffa
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 15 deletions.
3 changes: 2 additions & 1 deletion fuel/codeigniter/libraries/Pagination.php
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,8 @@ public function create_links()
}

// If something isn't quite right, back to the default base page.
if ( ! ctype_digit($this->cur_page) OR ($this->use_page_numbers && (int) $this->cur_page === 0))
// https://github.com/bcit-ci/CodeIgniter/issues/6119
if ( ! ctype_digit((string)$this->cur_page) OR ($this->use_page_numbers && (int) $this->cur_page === 0))
{
$this->cur_page = $base_page;
}
Expand Down
4 changes: 2 additions & 2 deletions fuel/modules/fuel/controllers/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -675,10 +675,10 @@ function _filter_list($params)
{
// create search filter
$search_key = !empty($this->search_field) ? $this->search_field : $this->display_field;
$filters[$search_key] = trim($params['search_term']);
$filters[$search_key] = trim((string) $params['search_term']);

// sort of hacky here... to make it easy for the model to just filter on the search term (like the users model)
$this->model->filter_value = trim($params['search_term']);
$this->model->filter_value = trim((string) $params['search_term']);

foreach($this->filters as $key => $val)
{
Expand Down
2 changes: 1 addition & 1 deletion fuel/modules/fuel/core/Loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public function library($library, $params = NULL, $object_name = NULL, $module =
if (isset($this->_ci_classes[$class]) && $_alias = $this->_ci_classes[$class])
return $this;

($_alias = strtolower($object_name)) OR $_alias = $class;
($_alias = is_string($object_name) && strtolower($object_name)) OR $_alias = $class;

list($path, $_library) = Modules::find($library, $module, 'libraries/');

Expand Down
2 changes: 1 addition & 1 deletion fuel/modules/fuel/helpers/MY_date_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ function english_date($date, $long = FALSE, $timezone = NULL, $delimiter = '/')
if (!empty($date))
{
$date_ts = (!is_numeric($date)) ? strtotime($date) : $date;
if (strtolower($timezone) == 'auto')
if ($timezone AND strtolower($timezone) == 'auto')
{
$timezone = date('e');
}
Expand Down
2 changes: 1 addition & 1 deletion fuel/modules/fuel/libraries/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -1558,7 +1558,7 @@ protected function _array_to_attr($arr)
*/
protected function _is_local_path($path)
{
if (strncmp($path, 'http', 4) === 0)
if ($path AND strncmp((string)$path, 'http', 4) === 0)
{
return FALSE;
}
Expand Down
5 changes: 3 additions & 2 deletions fuel/modules/fuel/libraries/Data_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,7 @@ public function add_row($columns = array(), $attrs = array(), $index = NULL, $ac
}
// add the actions
if (empty($action)) $action = $this->default_field_action;

if (!empty($action))
{
$callback = function($match) use ($columns) {
Expand All @@ -806,11 +807,11 @@ public function add_row($columns = array(), $attrs = array(), $index = NULL, $ac
};

$action = preg_replace_callback('#^(.*)\{(.+)\}(.*)$#', $callback, $action);
$fields[] = new Data_table_field($key, xss_clean($val), array(), $action);
$fields[] = new Data_table_field($key, xss_clean((string)$val), array(), $action);
}
else
{
$fields[] = new Data_table_field($key, xss_clean($val), $col_attrs);
$fields[] = new Data_table_field($key, xss_clean((string)$val), $col_attrs);
}

$i++;
Expand Down
8 changes: 5 additions & 3 deletions fuel/modules/fuel/libraries/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function set_validator(&$validator)
* @param object validator object
* @return string
*/
public function open($attrs = null, $validator = null)
public function open($attrs = '', $validator = NULL)
{
if (!empty($attrs)) $this->attrs = $attrs;
if (!empty($validator)) $this->validator =& $validator;
Expand All @@ -136,7 +136,7 @@ public function open($attrs = null, $validator = null)
* @param object validator object
* @return string
*/
public function open_multipart($attrs = null, $validator = null)
public function open_multipart($attrs = '', $validator = NULL)
{
$attrs['enctype'] = 'multipart/form-data';
return $this->open($attrs, $validator);
Expand Down Expand Up @@ -188,7 +188,7 @@ public function close($html_before_form = '', $add_csrf_field = TRUE)
* @param mixed attrs if array then create string
* @return string
*/
public function fieldset_open($legend, $attrs = NULL, $fieldset_id = NULL)
public function fieldset_open($legend, $attrs = '', $fieldset_id = NULL)
{
if (!empty($fieldset_id))
{
Expand Down Expand Up @@ -749,6 +749,8 @@ public function create_attrs($attrs)
{
return ' '.$attrs;
}

return '';
}

// --------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion fuel/modules/fuel/libraries/Fuel_admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ public function get_state_key()
*/
public function ui_cookie($key = NULL)
{
$cookie_val = json_decode(urldecode($this->CI->input->cookie('fuel_ui')), TRUE);
$cookie_val = json_decode(urldecode((string) $this->CI->input->cookie('fuel_ui')), TRUE);
if (!empty($key))
{
if (isset($cookie_val[$key]))
Expand Down
6 changes: 6 additions & 0 deletions fuel/modules/fuel/models/Base_model_helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ public function reorder($order)
* @access public
* @return ArrayIterator
*/
#[\ReturnTypeWillChange]
public function getIterator()
{
return new ArrayIterator($this->fields);
Expand All @@ -441,6 +442,7 @@ public function getIterator()
* @access public
* @return int
*/
#[\ReturnTypeWillChange]
public function count()
{
return count($this->fields);
Expand All @@ -455,6 +457,7 @@ public function count()
* @param mixed $key
* @return bool
*/
#[\ReturnTypeWillChange]
public function offsetExists($key)
{
return array_key_exists($key, $this->fields);
Expand All @@ -469,6 +472,7 @@ public function offsetExists($key)
* @param mixed $key
* @return mixed
*/
#[\ReturnTypeWillChange]
public function offsetGet($key)
{
$ref =& $this->fields[$key];
Expand All @@ -485,6 +489,7 @@ public function offsetGet($key)
* @param mixed $value
* @return void
*/
#[\ReturnTypeWillChange]
public function offsetSet($key, $value)
{
if (is_null($key))
Expand All @@ -506,6 +511,7 @@ public function offsetSet($key, $value)
* @param string $key
* @return void
*/
#[\ReturnTypeWillChange]
public function offsetUnset($key)
{
unset($this->fields[$key]);
Expand Down
4 changes: 2 additions & 2 deletions fuel/modules/fuel/models/Base_module_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,11 @@ public function list_items($limit = NULL, $offset = 0, $col = 'id', $order = 'as
$escape_order_by = (property_exists($this, 'escape_order_by')) ? $this->escape_order_by : TRUE;

// Additional cleaning
if ($escape_order_by && strpos($col, ')') !== FALSE)
if ($escape_order_by && strpos((string) $col, ')') !== FALSE)
{
$col = '';
}
if (!empty($col)) $this->db->order_by($col, $order, $escape_order_by);
if (!empty($col)) $this->db->order_by((string) $col, (string) $order, $escape_order_by);
if (!empty($limit)) $this->db->limit((int) $limit);
$this->db->offset((int)$offset);

Expand Down
2 changes: 1 addition & 1 deletion fuel/modules/fuel/views/_blocks/fuel_header_jqx.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
jqx_config.cookieDefaultPath = '<?=$this->fuel->config('fuel_cookie_path')?>';
<?php if (!empty($keyboard_shortcuts)){ ?>jqx_config.keyboardShortcuts = <?=json_encode($keyboard_shortcuts)?>;<?php } ?>
jqx_config.warnIfModified = <?=(int)$this->fuel->config('warn_if_modified')?>;
jqx_config.cacheString = new Date('<?=date('F d, Y H:i:s', strtotime($this->config->item('last_updated'))) ?>').getTime().toString();
jqx_config.cacheString = new Date('<?=date('F d, Y H:i:s', strtotime((string)$this->config->item('last_updated'))) ?>').getTime().toString();
jqx_config.assetsAccept = '<?php $editable_asset_types = $this->fuel->config('editable_asset_filetypes'); echo (!empty($editable_asset_types['assets']) ? $editable_asset_types['assets'] : 'jpg|jpeg|jpe|gif|png'); ?>';
jqx_config.lang = '<?=$this->fuel->auth->user_lang()?>';
<?php if (!empty($js_localized)) :?>
Expand Down

0 comments on commit 7bf6ffa

Please sign in to comment.