PHP chain operation elegant writing?

is there a more elegant way to use chained operations in PHP?
if a chain operation is complex and needs to write a long line, when will it break the line?

No line wrapping:

function test(){

    $res = $this->erp_base
                ->select([
                    "company_id AS city_id",
                    "city_name AS city_name",
                    "UNIX_TIMESTAMP() AS create_time",
                    "UNIX_TIMESTAMP() AS update_time"
                ])->where([
                    "if_deleted =" => 0
                ])->where_not_in("company_id", $this->_blacklist)
                ->get("company")
                ->result_array();
                
    return $res;
}

Virgo indicates that code style is important. how do you write it?

Php
Mar.06,2021

how do you align this arrowhead with the method?

function test()
{

    $res = $this
        ->erp_base
        ->select([
            'company_id AS city_id',
            'city_name AS city_name',
            'UNIX_TIMESTAMP() AS create_time',
            'UNIX_TIMESTAMP() AS update_time',
        ])
        ->where([
            'if_deleted =' => 0,
        ])
        ->where_not_in('company_id', $this->_blacklist)
        ->get('company')
        ->result_array();

    return $res;
    
}

is basically written in the chain style of jQ. But I usually use the editor's formatting plug-in to VSCode+phpfmt+php runtime automatically. It doesn't matter about elegance. It's a matter of opinion.

Menu