The file path of the BaseActiveRecord class is: Project vendoryiisoftyii2dbBaseActiveRecord. php does not need to implement all methods in the interface because the BaseActiveRecord class is abstract, or does the find () method in the interface not need to be implemented if it is? Or the file path of the yii2. .. BaseActiveRecord class is: Project \ vendor \ yiisoft \ yii2 \ db \ BaseActiveRecord. php
Is it because the BaseActiveRecord class is abstract that it does not need to implement all the methods in the interface, or does it not need to be implemented if the find () method in the interface is static? Or is yii2 processed elsewhere?
Reply content:
The file path of the BaseActiveRecord class is: Project \ vendor \ yiisoft \ yii2 \ db \ BaseActiveRecord. php
Is it because the BaseActiveRecord class is abstract that it does not need to implement all the methods in the interface, or does it not need to be implemented if the find () method in the interface is static? Or is yii2 processed elsewhere?
I tested php5.5.11 and found that abstract classes do not need to implement methods in interfaces, but they must implement all methods in interfaces in inheritance classes.
BaseActiveRecord inherits some methods of the model, and the remaining methods are implemented in the inheritance class ActiveRecord.
ActiveRecordInterface. php
php
interface ActiveRecordInterface{ public static function a(); public function b(); public function c();}
BaseActiveRecord. php
php
include "ActiveRecordInterface.php";abstract class BaseActiveRecord implements ActiveRecordInterface{ // public static function a(){echo 'a';} // public function b(){echo 'b';} // public function c(){echo 'c';}}
Test. php
php
include "BaseActiveRecord.php";class test extends BaseActiveRecord{ public static function a(){} public function b(){} public function c(){} function d(){ echo 'dd'; }}$a = new test();$a->d();
Normal output dd