Skip to content

Commit

Permalink
Drop PHP 5.3 support
Browse files Browse the repository at this point in the history
Merge pull request #18 from mvorisek/drop_php5_support
  • Loading branch information
AllanJard authored Dec 21, 2023
2 parents 9ae253a + b493865 commit 6673f4e
Show file tree
Hide file tree
Showing 34 changed files with 421 additions and 436 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/test-unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ jobs:
name: Unit
runs-on: ubuntu-latest
container:
image: ${{ (matrix.php == '5.3' || matrix.php == '5.4' || matrix.php == '5.5' || matrix.php == '5.6' || matrix.php == '7.0' || matrix.php == '7.1' || matrix.php == '7.2' || matrix.php == '7.3') && 'php' || 'ghcr.io/mvorisek/image-php' }}:${{ matrix.php }}
image: ${{ (matrix.php == '5.4' || matrix.php == '5.5' || matrix.php == '5.6' || matrix.php == '7.0' || matrix.php == '7.1' || matrix.php == '7.2' || matrix.php == '7.3') && 'php' || 'ghcr.io/mvorisek/image-php' }}:${{ matrix.php }}
strategy:
fail-fast: false
matrix:
php: ['5.3', '5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', 'latest']
php: ['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', 'latest']
type: ['Lint']
# php: ['7.4', '8.0', '8.1', 'latest']
# type: ['Phpunit']
Expand All @@ -27,7 +27,7 @@ jobs:
uses: actions/checkout@v3

- name: Configure PHP (for PHP < 7.4)
if: matrix.php == '5.3' || matrix.php == '5.4' || matrix.php == '5.5' || matrix.php == '5.6' || matrix.php == '7.0' || matrix.php == '7.1' || matrix.php == '7.2' || matrix.php == '7.3'
if: matrix.php == '5.4' || matrix.php == '5.5' || matrix.php == '5.6' || matrix.php == '7.0' || matrix.php == '7.1' || matrix.php == '7.2' || matrix.php == '7.3'
run: |
php --version
echo 'deb [trusted=yes] http://archive.debian.org/debian jessie main' > /etc/apt/sources.list
Expand All @@ -39,7 +39,7 @@ jobs:
sed -i 's/require-dev/require-xxx/g' composer.json
- name: Configure PHP (for PHP >= 7.4)
if: matrix.php != '5.3' && matrix.php != '5.4' && matrix.php != '5.5' && matrix.php != '5.6' && matrix.php != '7.0' && matrix.php != '7.1' && matrix.php != '7.2' && matrix.php != '7.3'
if: matrix.php != '5.4' && matrix.php != '5.5' && matrix.php != '5.6' && matrix.php != '7.0' && matrix.php != '7.1' && matrix.php != '7.2' && matrix.php != '7.3'
run: |
rm /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
php --version
Expand Down
41 changes: 19 additions & 22 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in(array(__DIR__))
->in([__DIR__])
->ignoreDotFiles(false)
->ignoreVCS(true)
->exclude(array('vendor', 'HtmLawed'));
->exclude(['vendor', 'HtmLawed']);

$config = new PhpCsFixer\Config();

return $config
->setRiskyAllowed(true)
->setIndent("\t")
->setRules(array(
->setRules([
'@PhpCsFixer' => true,
'@PhpCsFixer:risky' => true,
'@PHP74Migration' => true,
'@PHP74Migration:risky' => true,

// required by PSR-12
'concat_space' => array(
'concat_space' => [
'spacing' => 'one',
),
],

// disable some too strict rules
'phpdoc_types_order' => array(
'phpdoc_types_order' => [
'null_adjustment' => 'always_last',
'sort_algorithm' => 'none',
),
],
'single_line_throw' => false,
'yoda_style' => array(
'yoda_style' => [
'equal' => false,
'identical' => false,
),
],
'native_constant_invocation' => true,
'native_function_invocation' => false,
'void_return' => false,
'blank_line_before_statement' => array(
'statements' => array('break', 'continue', 'declare', 'return', 'throw', 'exit'),
),
'blank_line_before_statement' => [
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'exit'],
],
'combine_consecutive_issets' => false,
'combine_consecutive_unsets' => false,
'multiline_whitespace_before_semicolons' => false,
Expand All @@ -48,31 +48,28 @@
'phpdoc_add_missing_param_annotation' => false,
'return_assignment' => false,
'comment_to_phpdoc' => false,
'general_phpdoc_annotation_remove' => array(
'annotations' => array(/* 'author', 'copyright', */ 'throws'),
),
'nullable_type_declaration_for_default_null_value' => array(
'general_phpdoc_annotation_remove' => [
'annotations' => [/* 'author', 'copyright', */ 'throws'],
],
'nullable_type_declaration_for_default_null_value' => [
'use_nullable_type_declaration' => false,
),
],

// fn => without curly brackets is less readable,
// also prevent bounding of unwanted variables for GC
'use_arrow_functions' => false,

// disable too destructive formating for now
'list_syntax' => array('syntax' => 'long'), // needs PHP 5.4+
'array_syntax' => array('syntax' => 'long'), // needs PHP 5.4+
'ternary_to_null_coalescing' => false, // needs PHP 7.0+
'single_line_comment_style' => false,
'phpdoc_annotation_without_dot' => false,
'declare_strict_types' => false,
'static_lambda' => false, // needs PHP 5.4+
'strict_comparison' => false,
'strict_param' => false, // TODO
'final_internal_class' => false,
'function_to_constant' => false, // needs PHP 5.5+
'self_accessor' => false, // TODO some should be converted to static:: probably
'visibility_required' => array('elements' => array('property', 'method')), // needs PHP 7.1+
))
'visibility_required' => ['elements' => ['property', 'method']], // needs PHP 7.1+
])
->setFinder($finder)
->setCacheFile(sys_get_temp_dir() . '/php-cs-fixer.' . md5(__DIR__) . '.cache');
2 changes: 1 addition & 1 deletion Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* DataTables PHP libraries.
*
* PHP libraries for DataTables and DataTables Editor, utilising PHP 5.3+.
* PHP libraries for DataTables and DataTables Editor.
*
* @author SpryMedia
* @copyright SpryMedia ( http://sprymedia.co.uk )
Expand Down
14 changes: 7 additions & 7 deletions DataTables.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* DataTables PHP libraries.
*
* PHP libraries for DataTables and DataTables Editor, utilising PHP 5.3+.
* PHP libraries for DataTables and DataTables Editor.
*
* @author SpryMedia
* @copyright SpryMedia ( http://sprymedia.co.uk )
Expand All @@ -13,15 +13,15 @@
define('DATATABLES', true);

//
// Error checking - check that we are PHP 5.3 or newer
// Error checking - check that we are PHP 5.4 or newer
//
if (version_compare(\PHP_VERSION, '5.3.0', '<')) {
echo json_encode(array(
'sError' => 'Editor PHP libraries required PHP 5.3 or newer. You are ' .
'currently using ' . \PHP_VERSION . '. PHP 5.3 and newer have a lot of ' .
if (version_compare(\PHP_VERSION, '5.4.0', '<')) {
echo json_encode([
'sError' => 'Editor PHP libraries required PHP 5.4 or newer. You are ' .
'currently using ' . \PHP_VERSION . '. PHP 5.4 and newer have a lot of ' .
'great new features that the Editor libraries take advantage of to ' .
'present an easy to use and flexible API.',
));
]);

exit(1);
}
Expand Down
12 changes: 6 additions & 6 deletions Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* DataTables PHP libraries.
*
* PHP libraries for DataTables and DataTables Editor, utilising PHP 5.3+.
* PHP libraries for DataTables and DataTables Editor.
*
* @author SpryMedia
* @copyright 2012 SpryMedia ( http://sprymedia.co.uk )
Expand Down Expand Up @@ -38,19 +38,19 @@ class Database
*
* @param array<string, string|\PDO> $opts Array of connection parameters for the database:
* ```php
* array(
* [
* "user" => "", // User name
* "pass" => "", // Password
* "host" => "", // Host name
* "port" => "", // Port
* "db" => "", // Database name
* "type" => "" // Datable type: "Mysql", "Postgres" or "Sqlite"
* )
* ]
* ```
*/
public function __construct($opts)
{
$types = array('Mysql', 'Oracle', 'Postgres', 'Sqlite', 'Sqlserver', 'Db2', 'Firebird');
$types = ['Mysql', 'Oracle', 'Postgres', 'Sqlite', 'Sqlserver', 'Db2', 'Firebird'];

if (!in_array($opts['type'], $types)) {
throw new \Exception(
Expand Down Expand Up @@ -466,10 +466,10 @@ public function debugInfo($query = null, $bindings = null)
$callback = $this->_debugCallback;

if ($callback) {
$callback(array(
$callback([
'query' => $query,
'bindings' => $bindings,
));
]);
}

return $this;
Expand Down
6 changes: 3 additions & 3 deletions Database/Driver/Db2Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ public static function connect($user, $pass = '', $host = '', $port = '', $db =
// error.
$e = 'Connection failed: ' . db2_conn_error() . ' : ' . db2_conn_errormsg();

echo json_encode(array(
echo json_encode([
'error' => 'An error occurred while connecting to the database ' .
"'{$db}'. The error reported by the server was: " . $e,
));
]);

exit(1);
}
Expand Down Expand Up @@ -142,7 +142,7 @@ protected function _exec()

protected function _build_table()
{
$out = array();
$out = [];

for ($i = 0, $ien = count($this->_table); $i < $ien; ++$i) {
$t = $this->_table[$i];
Expand Down
2 changes: 1 addition & 1 deletion Database/Driver/Db2Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function insertId()

private function _fetchAll()
{
$a = array();
$a = [];
while ($row = db2_fetch_assoc($this->_stmt)) {
$a[] = $row;
}
Expand Down
10 changes: 5 additions & 5 deletions Database/Driver/FirebirdQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* DataTables PHP libraries.
*
* PHP libraries for DataTables and DataTables Editor, utilising PHP 5.3+.
* PHP libraries for DataTables and DataTables Editor.
*
* @author SpryMedia
* @copyright 2012 SpryMedia ( http://sprymedia.co.uk )
Expand All @@ -27,7 +27,7 @@ class FirebirdQuery extends Query
*/
private $_stmt;

protected $_identifier_limiter = array('"', '"');
protected $_identifier_limiter = ['"', '"'];

protected $_field_quote = '"';

Expand All @@ -49,7 +49,7 @@ public static function connect($user, $pass = '', $host = '', $port = '', $db =
$host = $opts['host'];
$db = $opts['db'];
$dsn = isset($opts['dsn']) ? $opts['dsn'] : '';
$pdoAttr = isset($opts['pdoAttr']) ? $opts['pdoAttr'] : array();
$pdoAttr = isset($opts['pdoAttr']) ? $opts['pdoAttr'] : [];
}

if ($host !== '') {
Expand All @@ -74,10 +74,10 @@ public static function connect($user, $pass = '', $host = '', $port = '', $db =
} catch (\PDOException $e) {
// If we can't establish a DB connection then we return a DataTables
// error.
echo json_encode(array(
echo json_encode([
'error' => 'An error occurred while connecting to the database ' .
"'{$db}'. The error reported by the server was: " . $e->getMessage(),
));
]);

exit(1);
}
Expand Down
2 changes: 1 addition & 1 deletion Database/Driver/FirebirdResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* DataTables PHP libraries.
*
* PHP libraries for DataTables and DataTables Editor, utilising PHP 5.3+.
* PHP libraries for DataTables and DataTables Editor.
*
* @author SpryMedia
* @copyright 2012 SpryMedia ( http://sprymedia.co.uk )
Expand Down
8 changes: 4 additions & 4 deletions Database/Driver/MysqlQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* DataTables PHP libraries.
*
* PHP libraries for DataTables and DataTables Editor, utilising PHP 5.3+.
* PHP libraries for DataTables and DataTables Editor.
*
* @author SpryMedia
* @copyright 2012 SpryMedia ( http://sprymedia.co.uk )
Expand Down Expand Up @@ -41,7 +41,7 @@ public static function connect($user, $pass = '', $host = '', $port = '', $db =
$db = $opts['db'];
$port = isset($opts['port']) ? $opts['port'] : '';
$dsn = isset($opts['dsn']) ? $opts['dsn'] : '';
$pdoAttr = isset($opts['pdoAttr']) ? $opts['pdoAttr'] : array();
$pdoAttr = isset($opts['pdoAttr']) ? $opts['pdoAttr'] : [];
}

if ($port !== '') {
Expand All @@ -60,10 +60,10 @@ public static function connect($user, $pass = '', $host = '', $port = '', $db =
} catch (\PDOException $e) {
// If we can't establish a DB connection then we return a DataTables
// error.
echo json_encode(array(
echo json_encode([
'error' => 'An error occurred while connecting to the database ' .
"'{$db}'. The error reported by the server was: " . $e->getMessage(),
));
]);

exit(1);
}
Expand Down
2 changes: 1 addition & 1 deletion Database/Driver/MysqlResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* DataTables PHP libraries.
*
* PHP libraries for DataTables and DataTables Editor, utilising PHP 5.3+.
* PHP libraries for DataTables and DataTables Editor.
*
* @author SpryMedia
* @copyright 2012 SpryMedia ( http://sprymedia.co.uk )
Expand Down
12 changes: 6 additions & 6 deletions Database/Driver/OracleQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class OracleQuery extends Query

private $_editor_pkey_value;

protected $_identifier_limiter = array('"', '"');
protected $_identifier_limiter = ['"', '"'];

protected $_field_quote = '"';

Expand All @@ -57,9 +57,9 @@ public static function connect($user, $pass = '', $host = '', $port = '', $db =
}

if (!function_exists('oci_connect')) {
echo json_encode(array(
echo json_encode([
'error' => 'oci methods are not available in this PHP install to connect to Oracle',
));
]);

exit(1);
}
Expand All @@ -71,10 +71,10 @@ public static function connect($user, $pass = '', $host = '', $port = '', $db =
// error.
$e = oci_error();

echo json_encode(array(
echo json_encode([
'error' => 'An error occurred while connecting to the database ' .
"'{$db}'. The error reported by the server was: " . $e['message'],
));
]);

exit(1);
}
Expand Down Expand Up @@ -166,7 +166,7 @@ protected function _exec()

protected function _build_table()
{
$out = array();
$out = [];

for ($i = 0, $ien = count($this->_table); $i < $ien; ++$i) {
$t = $this->_table[$i];
Expand Down
2 changes: 1 addition & 1 deletion Database/Driver/OracleResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function fetch($fetchType = \PDO::FETCH_ASSOC /* irrelevant for oci8 */)
public function fetchAll($fetchType = \PDO::FETCH_ASSOC /* irrelevant for oci8 */)
{
if (!$this->_rows) {
$out = array();
$out = [];

oci_fetch_all($this->_stmt, $out, 0, -1, OCI_FETCHSTATEMENT_BY_ROW + OCI_ASSOC);

Expand Down
Loading

0 comments on commit 6673f4e

Please sign in to comment.