I create my own class in which I want to inherit the СUser class and one of its methods.

abstract class MineClass extends CAllUser { public static function GetByID($ID){ parent::GetByID($ID); } } 

But I can't call him

  $htmm = MineClass::GetByID($_SESSION['SESS_AUTH']['USER_ID']); 
  • Because an abstract class. - ilyaplot
  • I'm not very good at php yet, can you tell me a way out of the situation, and what's the catch? I thought in abstr. classes, you can not create obekstov, and I'm just turning to him. Or do I indirectly try to create an object in this way? - Oleksandr
  • Just remove the word abstract, and then read the documentation. Soon you bitriks. - ilyaplot
  • unfortunately we need an abstract. I understand that to call this class, I will need to inherit it again and get this function from it, right? - Oleksandr
  • there is no abstract class here. static method, parent may have non-static method - teran

1 answer 1

The problem is that the GetByID() parent method returns a user object. However, in the inheritance class, the method is invoked, however, the result is not returned from the method. Thus, adding a return will solve the problem.

 public static function GetByID($ID){ return parent::GetByID($ID); }