(static::model):: count ($conditions);) excuse me, is there any drawback in this way of writing?

problem description

(static::model)::count($conditions); // 

related codes

trait SRV {

    public static function count(array $conditions) {
        if (empty(static::model)) {
            return 0;
        }
        return (static::model)::count($conditions);
    }

}

class CommentSrv {

    // DB
    const model = CommentDB::class;

    use SRV;
}

the above code can be used normally in practical application, but I didn"t find it in this way. I don"t know if it will have any sequelae. This leads to an increase in maintenance costs in the later period

Php
Apr.23,2021

it's good to try something new, and it's normal to write things that can't be found.
doesn't that mean return CommentDB::count ($conditions); ?
you can change to an abstract class


is mainly due to poor readability. The difficulty of program development is to facilitate long-term maintenance, not to make sure that the code is short


sure it can run. Doubt it.
wanted to do this before, but Model::class is a string, STR::count (); this has to report an error. (at least I made a mistake when I did this.


trait SRV {
    /**
     * 
     *
     * @param array $conditions   buildCondition
     * @return int
     */
    public static function count(array $conditions) {
        $model = self::getModel();
        if (is_null($model)) {
            return 0;
        }
        return $model::count($conditions);
    }

    /**
     * 
     *
     * @return string || null
     */
    private static function getModel() {

        if (empty(static::$model)) {
            $parentClassName = get_class();

            if (!empty($parentClassName)) {
                $modelName = str_replace(['Srv', 'SRV'], 'DB', $parentClassName);
            }
        } else {
            $modelName = static::$model;
        }

        if (!class_exists($modelName)) {
            return null;
        }

        return $modelName;
    }
}

the previous way of writing may not be compatible under php7. Although it is no longer considered to be compatible with less than 7, it is always a bit uneasy to write that way, so let's change it.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3ac01-2ba8f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3ac01-2ba8f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?