Skip to content

Commit

Permalink
php-cs-fixer PHP 5.4 migration
Browse files Browse the repository at this point in the history
  • Loading branch information
mambax7 committed Nov 24, 2023
1 parent 7f383f7 commit 6116750
Show file tree
Hide file tree
Showing 42 changed files with 725 additions and 713 deletions.
2 changes: 1 addition & 1 deletion _archive/src/Xmf/Template/Breadcrumb.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Breadcrumb extends AbstractTemplate
/**
* @var array
*/
private $items = array();
private $items = [];

/**
* initialization run by parent::__construct
Expand Down
2 changes: 1 addition & 1 deletion _archive/src/Xmf/Template/Buttonbox.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Buttonbox extends AbstractTemplate
/**
* @var array
*/
private $items = array();
private $items = [];

/**
* @var string
Expand Down
2 changes: 1 addition & 1 deletion _archive/src/Xmf/Template/Feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class Feed extends AbstractTemplate
/**
* @var array
*/
private $items = array();
private $items = [];

/**
* init - called by parent::_construct
Expand Down
9 changes: 4 additions & 5 deletions _archive/src/Xmf/Utilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
*/
class Utilities
{

/**
* purifyText
*
Expand Down Expand Up @@ -78,7 +77,7 @@ public static function purifyText($text, $keyword = false)
*/
public static function html2text($document)
{
$search = array(
$search = [
"'<script[^>]*?>.*?</script>'si", // Strip out javascript
"'<img.*?/>'si", // Strip out img tags
"'<[\/\!]*?[^<>]*?>'si", // Strip out HTML tags
Expand All @@ -92,9 +91,9 @@ public static function html2text($document)
"'&(cent|#162);'i",
"'&(pound|#163);'i",
"'&(copy|#169);'i"
);
];

$replace = array(
$replace = [
"",
"",
"",
Expand All @@ -108,7 +107,7 @@ public static function html2text($document)
chr(162),
chr(163),
chr(169)
);
];

$text = preg_replace($search, $replace, $document);

Expand Down
3 changes: 2 additions & 1 deletion index.php
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
<?php
header('HTTP/1.0 404 Not Found');

header('HTTP/1.0 404 Not Found');
4 changes: 2 additions & 2 deletions src/Database/Migrate.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
*/
class Migrate
{

/** @var false|\Xmf\Module\Helper|\Xoops\Module\Helper\HelperAbstract */
protected $helper;

Expand Down Expand Up @@ -78,7 +77,8 @@ function ($match) {
}
return $semver;
},
$module->getInfo('version'));
$module->getInfo('version')
);

$this->tableDefinitionFile = $this->helper->path("sql/{$dirname}_{$version}_migrate.yml");
$this->tableHandler = new Tables();
Expand Down
7 changes: 3 additions & 4 deletions src/Database/TableLoad.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
*/
class TableLoad
{

/**
* loadTableFromArray
*
Expand Down Expand Up @@ -149,7 +148,7 @@ public static function countRows($table, $criteria = null)
*
* @return array of table rows
*/
public static function extractRows($table, $criteria = null, $skipColumns = array())
public static function extractRows($table, $criteria = null, $skipColumns = [])
{
/** @var \XoopsDatabase */
$db = \XoopsDatabaseFactory::getDatabaseConnection();
Expand All @@ -160,7 +159,7 @@ public static function extractRows($table, $criteria = null, $skipColumns = arra
/** @var \CriteriaCompo $criteria */
$sql .= $criteria->renderWhere();
}
$rows = array();
$rows = [];
$result = $db->query($sql);
if ($result) {
while (false !== ($row = $db->fetchArray($result))) {
Expand Down Expand Up @@ -191,7 +190,7 @@ public static function extractRows($table, $criteria = null, $skipColumns = arra
*
* @return bool true on success, false on error
*/
public static function saveTableToYamlFile($table, $yamlFile, $criteria = null, $skipColumns = array())
public static function saveTableToYamlFile($table, $yamlFile, $criteria = null, $skipColumns = [])
{
$rows = static::extractRows($table, $criteria, $skipColumns);

Expand Down
28 changes: 14 additions & 14 deletions src/Database/Tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ protected function name($table)
*/
public function addColumn($table, $column, $attributes)
{
$columnDef = array(
$columnDef = [
'name' => $column,
'attributes' => $attributes
);
];

// Find table def.
if (isset($this->tables[$table])) {
Expand Down Expand Up @@ -237,16 +237,16 @@ public function addTable($table)
return true;
} else {
if ($tableDef === true) {
$tableDef = array(
$tableDef = [
'name' => $this->name($table),
'options' => 'ENGINE=InnoDB',
'columns' => array(),
'keys' => array(),
'columns' => [],
'keys' => [],
'create' => true,
);
];
$this->tables[$table] = $tableDef;

$this->queue[] = array('createtable' => $table);
$this->queue[] = ['createtable' => $table];

return true;
} else {
Expand Down Expand Up @@ -391,7 +391,7 @@ public function copyTable($table, $newTable, $withData = false)
$this->queue[] = "INSERT INTO `{$copy}` SELECT * FROM `{$original}` ;";
} else {
$tableDef['create'] = true;
$this->queue[] = array('createtable' => $newTable);
$this->queue[] = ['createtable' => $newTable];
}
$this->tables[$newTable] = $tableDef;

Expand Down Expand Up @@ -575,8 +575,8 @@ public function setTableOptions($table, $options)
*/
public function resetQueue()
{
$this->tables = array();
$this->queue = array();
$this->tables = [];
$this->queue = [];
}

/**
Expand Down Expand Up @@ -815,7 +815,7 @@ protected function quoteDefaultClause($default)
{
// . (($column['COLUMN_DEFAULT'] === null) ? '' : " DEFAULT '" . $column['COLUMN_DEFAULT'] . "' ")
// no default specified
if (null===$default) {
if (null === $default) {
return '';
}

Expand All @@ -840,7 +840,7 @@ protected function quoteDefaultClause($default)
*/
protected function getTable($table)
{
$tableDef = array();
$tableDef = [];

$sql = 'SELECT TABLE_NAME, ENGINE, CHARACTER_SET_NAME ';
$sql .= ' FROM `INFORMATION_SCHEMA`.`TABLES` t, ';
Expand Down Expand Up @@ -876,10 +876,10 @@ protected function getTable($table)
//. $column['EXTRA'];
. str_replace('DEFAULT_GENERATED ', '', $column['EXTRA']);

$columnDef = array(
$columnDef = [
'name' => $column['COLUMN_NAME'],
'attributes' => $attributes
);
];

$tableDef['columns'][] = $columnDef;
};
Expand Down
3 changes: 2 additions & 1 deletion src/Database/index.php
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
<?php
header('HTTP/1.0 404 Not Found');

header('HTTP/1.0 404 Not Found');
6 changes: 3 additions & 3 deletions src/Debug.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ private static function doOnce()
if (true !== $done) {
$done = true;
$class = get_called_class();
parent::$aliases[] = array($class, 'dump');
parent::$aliases[] = array($class, 'backtrace');
parent::$aliases[] = [$class, 'dump'];
parent::$aliases[] = [$class, 'backtrace'];
parent::$enabled_mode = true;
parent::$mode_default = \Kint::MODE_RICH;
// display output inline ::folder = false, true puts all output at bottom of window
Expand All @@ -59,7 +59,7 @@ public static function dump($data = null)
$args = func_get_args();

static::doOnce();
forward_static_call_array(array('parent', 'dump'), $args);
forward_static_call_array(['parent', 'dump'], $args);
}

/**
Expand Down
24 changes: 12 additions & 12 deletions src/FilterInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class FilterInput
protected $attrMethod; // default is 0

protected $xssAuto; // default is 1
protected $tagBlacklist = array(
protected $tagBlacklist = [
'applet',
'body',
'bgsound',
Expand All @@ -64,9 +64,9 @@ class FilterInput
'style',
'title',
'xml'
);
];
// also, it will strip ALL event handlers
protected $attrBlacklist = array('action', 'background', 'codebase', 'dynsrc', 'lowsrc');
protected $attrBlacklist = ['action', 'background', 'codebase', 'dynsrc', 'lowsrc'];

/**
* Constructor
Expand All @@ -78,8 +78,8 @@ class FilterInput
* @param int $xssAuto - 0 = only auto clean essentials, 1 = allow clean blacklisted tags/attr
*/
protected function __construct(
$tagsArray = array(),
$attrArray = array(),
$tagsArray = [],
$attrArray = [],
$tagsMethod = 0,
$attrMethod = 0,
$xssAuto = 1
Expand Down Expand Up @@ -117,8 +117,8 @@ protected function __construct(
* @return FilterInput object.
*/
public static function getInstance(
$tagsArray = array(),
$attrArray = array(),
$tagsArray = [],
$attrArray = [],
$tagsMethod = 0,
$attrMethod = 0,
$xssAuto = 1
Expand All @@ -127,10 +127,10 @@ public static function getInstance(

$className = get_called_class(); // so an extender gets an instance of itself

$sig = md5(serialize(array($className, $tagsArray, $attrArray, $tagsMethod, $attrMethod, $xssAuto)));
$sig = md5(serialize([$className, $tagsArray, $attrArray, $tagsMethod, $attrMethod, $xssAuto]));

if (!isset($instances)) {
$instances = array();
$instances = [];
}

if (empty($instances[$sig])) {
Expand Down Expand Up @@ -365,7 +365,7 @@ protected function filterTags($source)
}
// iterate through tag finding attribute pairs - setup
$tagLeft = $currentTag;
$attrSet = array();
$attrSet = [];
$currentSpace = strpos($tagLeft, ' ');
if (substr($currentTag, 0, 1) === "/") {
// is end tag
Expand Down Expand Up @@ -404,7 +404,7 @@ protected function filterTags($source)
} else {
$attr = substr($fromSpace, 0, $nextSpace);
}
// one or neither exist
// one or neither exist
} else {
// no more equals exist
$attr = substr($fromSpace, 0, $nextSpace);
Expand Down Expand Up @@ -461,7 +461,7 @@ protected function filterTags($source)
*/
protected function filterAttr($attrSet)
{
$newSet = array();
$newSet = [];
// process attributes
$attrSetCount = count($attrSet);
for ($i = 0; $i < $attrSetCount; ++$i) {
Expand Down
2 changes: 1 addition & 1 deletion src/Highlighter.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Highlighter
/**
* mbstring encoding
*/
const ENCODING = 'UTF-8';
public const ENCODING = 'UTF-8';

/**
* Apply highlight to words in body text
Expand Down
4 changes: 2 additions & 2 deletions src/Jwt/JsonWebToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class JsonWebToken
/**
* @var array
*/
protected $claims = array();
protected $claims = [];

/**
* JsonWebToken constructor.
Expand Down Expand Up @@ -79,7 +79,7 @@ public function setAlgorithm($algorithm)
*
* @return object|false
*/
public function decode($jwtString, $assertClaims = array())
public function decode($jwtString, $assertClaims = [])
{
try {
$values = JWT::decode($jwtString, new Key($this->key->getVerifying(), $this->algorithm));
Expand Down
8 changes: 4 additions & 4 deletions src/Jwt/TokenReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class TokenReader
*
* @throws \InvalidArgumentException on unusable key name
*/
public static function fromString($key, $token, $assertClaims = array())
public static function fromString($key, $token, $assertClaims = [])
{
$key = ($key instanceof KeyAbstract) ? $key : KeyFactory::build($key);
$jwt = new JsonWebToken($key);
Expand All @@ -56,7 +56,7 @@ public static function fromString($key, $token, $assertClaims = array())
*
* @throws \InvalidArgumentException on unusable key name
*/
public static function fromCookie($key, $cookieName, $assertClaims = array())
public static function fromCookie($key, $cookieName, $assertClaims = [])
{
$token = Request::getString($cookieName, '', 'COOKIE');
if (empty($token)) {
Expand All @@ -76,7 +76,7 @@ public static function fromCookie($key, $cookieName, $assertClaims = array())
*
* @throws \InvalidArgumentException on unusable key name
*/
public static function fromRequest($key, $attributeName, $assertClaims = array())
public static function fromRequest($key, $attributeName, $assertClaims = [])
{
$token = Request::getString($attributeName, '');
if (empty($token)) {
Expand All @@ -96,7 +96,7 @@ public static function fromRequest($key, $attributeName, $assertClaims = array()
*
* @throws \InvalidArgumentException on unusable key name
*/
public static function fromHeader($key, $assertClaims = array(), $headerName = 'Authorization')
public static function fromHeader($key, $assertClaims = [], $headerName = 'Authorization')
{
$header = Request::getHeader($headerName, '');
if (empty($header)) {
Expand Down
3 changes: 2 additions & 1 deletion src/Jwt/index.php
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
<?php
header('HTTP/1.0 404 Not Found');

header('HTTP/1.0 404 Not Found');
3 changes: 2 additions & 1 deletion src/Key/index.php
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
<?php
header('HTTP/1.0 404 Not Found');

header('HTTP/1.0 404 Not Found');
Loading

0 comments on commit 6116750

Please sign in to comment.