There are some errors while using anonymous classes in PHP7, for eg.:
<?php
namespace Brzuchal;
use ArrayObject;
class Base
{
protected $anonymous;
public function __construct()
{
$this->anonymous = new class extends ArrayObject
{
public function __construct()
{
parent::__construct(['a' => 1, 'b' => 2]);
}
};
}
}
When running phpspec --standard=PSR2 it outputs some _ERROR_, like:
----------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
----------------------------------------------------------------------
12 | ERROR | Class name "extends" is not in camel caps format
18 | ERROR | Closing class brace must be on a line by itself
----------------------------------------------------------------------
And when add parenthesis after class, like new class() extends ArrayObject there is different _ERROR_ on method indentation, like:
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
14 | ERROR | [x] Line indented incorrectly; expected 8 spaces, found
| | 12
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
Thanks for the very clear bug report. That class wasn't being converted into a T_ANON_CLASS token, and it now is.
Any chance this will be tagged as release any time soon?
Yes, soon. Hopefully next week, but I've had very little time over the last month.
Most helpful comment
Thanks for the very clear bug report. That class wasn't being converted into a T_ANON_CLASS token, and it now is.