Skip to content

Commit

Permalink
Fix incompatibility with PHP 8 (#5)
Browse files Browse the repository at this point in the history
* Fix incompatibility with PHP 8

preg_split(): Passing null to parameter #3 ($limit) of type int is deprecated

* Fix incompatibility with PHP 8

Automatic conversion of false to array is deprecated

* Fix incorrect type in phpdoc params
  • Loading branch information
stdex committed Aug 28, 2024
1 parent e5d1a77 commit 22dfb4f
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/PHPSQLParser/PHPSQLParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class PHPSQLParser
* Constructor. It simply calls the parse() function.
* Use the public variable $parsed to get the output.
*
* @param String|bool $sql The SQL statement.
* @param string|bool $sql The SQL statement.
* @param bool $calcPositions True, if the output should contain [position], false otherwise.
* @param array $options
*/
Expand All @@ -87,7 +87,7 @@ public function __construct($sql = false, $calcPositions = false, array $options
* of the positions needs some time, if you don't need positions in
* your application, set the parameter to false.
*
* @param String $sql The SQL statement.
* @param string $sql The SQL statement.
* @param boolean $calcPositions True, if the output should contain [position], false otherwise.
*
* @return array An associative array with all meta information about the SQL statement.
Expand Down Expand Up @@ -127,7 +127,7 @@ protected function getPositionCalculator()
/**
* Add a custom function to the parser. no return value
*
* @param String $token The name of the function to add
* @param string $token The name of the function to add
*/
public function addCustomFunction($token)
{
Expand All @@ -137,7 +137,7 @@ public function addCustomFunction($token)
/**
* Remove a custom function from the parser. no return value
*
* @param String $token The name of the function to remove
* @param string $token The name of the function to remove
*/
public function removeCustomFunction($token)
{
Expand Down
2 changes: 1 addition & 1 deletion src/PHPSQLParser/lexer/PHPSQLLexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function split($sql)
$tokens = preg_split(
$this->splitters->getSplittersRegexPattern(),
$sql,
null,
-1,
PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY
);
$tokens = $this->concatComments($tokens);
Expand Down
2 changes: 1 addition & 1 deletion src/PHPSQLParser/processors/SQLProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function process($tokens)
$prev_category = "";
$token_category = "";
$skip_next = 0;
$out = false;
$out = [];

// $tokens may come as a numeric indexed array starting with an index greater than 0 (or as a boolean)
if (is_array($tokens)) {
Expand Down
2 changes: 1 addition & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* from a file as serialized string.
* Returns an unserialized value from the given file.
*
* @param String $filename
* @param string $filename
*/
function getExpectedValue($path, $filename, $unserialize = true) {
$path = explode(DIRECTORY_SEPARATOR, $path);
Expand Down
2 changes: 1 addition & 1 deletion tests/cases/AbstractTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected function setup() {
* from a file as serialized string.
* Returns an unserialized value from the given file.
*
* @param String $filename
* @param string $filename
*/
protected function getExpectedValue($path, $filename, $unserialize = true) {
$path = explode(DIRECTORY_SEPARATOR, $path);
Expand Down

0 comments on commit 22dfb4f

Please sign in to comment.