nilportugues / php-sql-query-builder

An elegant lightweight and efficient SQL Query Builder with fluid interface SQL syntax supporting bindings and complicated query generation.
http://nilportugues.com
MIT License
418 stars 115 forks source link

PHP 8 deprecated warning on Syntax>Column #129

Open vanbe opened 1 year ago

vanbe commented 1 year ago

I recently upgrated to PHP 8.2, and getting warnings on Column->setAlias($alias) function line 115.

Code:

public function setAlias($alias)
    {
        if (0 == \strlen($alias)) {
            $this->alias = null;

            return $this;
        }

        if ($this->isAll()) {
            throw new QueryException("Can't use alias because column name is ALL (*)");
        }

        $this->alias = (string) $alias;

        return $this;
    }

Throws Deprecated: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in ...app/Vendor/nilportugues/sql-query-builder/src/Syntax/Column.php on line 115

The strlen line should be:

if ($alias === null || 0 == \strlen($alias)) {

rafark commented 1 year ago

Came to post this issue too. Have you considered a pull request? @nilportugues

rafark commented 1 year ago

To provide more context, this happens (at least to me), when trying to select all columns (when not specifying conditions), by just calling Select::setTable() and no other methods.

For the query string:

SELECT ``options_table``.* FROM ``options_table``

PHP 81

nilportugues commented 1 year ago

I'm considering releasing this package as a PHP 8.2 and above, yeah.

akamaccio commented 6 months ago

I'm considering releasing this package as a PHP 8.2 and above, yeah.

The big question is WHEN!?