A
A
Anton Chernogolov2020-04-21 09:54:12
PHP
Anton Chernogolov, 2020-04-21 09:54:12

How to properly override protected static function vendor class in Laravel?

I need to override the class from the vendor folder. The code below throws an error Declaration of Method should be compatible with Parent Method

namespace App\PhpExcelTemplator;
use alhimik1986\PhpExcelTemplator\PhpExcelTemplator as ParentPhpExcelTemplator;
class PhpExcelTemplator extends ParentPhpExcelTemplator
{
  protected static function getWriter(Spreadsheet $spreadsheet)
  {
              return IOFactory::createWriter($spreadsheet, 'Xlsx');
  }
}


The method itself is still identical. They write on the network that it is necessary to override without protected - I tried static function getWriter () - the result is the same.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question