3

I have create 2 files as below :

Namespace/Module/Model/Test.php

<?php
namespace Namespace\Module\Model;
use Namespace\Module\Model\Payment\Method\Abstract;

class Test extends Abstract
{
}
?>

Namespace/Module/Model/Payment/Method/Abstract.php

namespace Namespace\Module\Model\Payment\Method;
use Magento\Framework\DataObject;


abstract class Abstract extends DataObject implements \Namespace\Module\Model\Payment\Method\Interface
{
}

Now when file "Test.php" is called that time I am getting below error :

s:221:"Fatal Error: 'syntax error, unexpected 'Abstract' (T_ABSTRACT), expecting identifier (T_STRING)' in '/var/www/html/m2/app/code/Namespace/Module/Model/Payment/Method/Test.php' on line 3";

Does any one have an idea ? Thank you.

  • Could you try changing extends Abstract with extends \Namespace\Module\Model\Payment\Method\Abstract ? – Raphael at Digital Pianism May 17 '16 at 9:04
  • @RaphaelatDigitalPianism Yes I first try with that but getting same error. – Krupali May 17 '16 at 9:06
0

Change Abstract class name

Because it is reserved keyword in php

You cannot use any of the words as constants, class names, function or method names

| improve this answer | |
  • But I am using that same thing in Magento 1 and in that I am not getting any issue. – Krupali May 17 '16 at 9:12
  • Change class name it will work. – Prashant Valanda May 17 '16 at 9:19
  • It is working.But can you explain that why it is working in M1 and creating an issue in M2 ? – Krupali May 17 '16 at 10:15
  • It is not working with abstract keyword may be check there spell is different than abstract. – Prashant Valanda May 17 '16 at 10:20
  • I checked that and spell is "abstract" . :( – Krupali May 17 '16 at 10:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.