Skip to content

Commit

Permalink
Added support for detecting anonymous classes
Browse files Browse the repository at this point in the history
  • Loading branch information
RonRademaker authored and sstalle committed Dec 4, 2015
1 parent ff53cf5 commit 77436b6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/NodeVisitor/PHP4ConstructorVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ public function enterNode(Node $node)
$hasPhp5Constructor = false;
$php4ConstructorNode = null;

// Anonymous class can't use php4 constructor by definition
if (empty($currentClassName)) {
return;
}

// Checks if class is namespaced (property namespacedName was set by the NameResolver visitor)
if (count($node->namespacedName->parts) > 1) {
return;
Expand Down
5 changes: 3 additions & 2 deletions test/code/NodeVisitor/PHP4ConstructorVisitorTest.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
<?php

namespace code\NodeVisitor;

use PHPUnit_Framework_TestCase;
use Sstalle\php7cc\NodeVisitor\PHP4ConstructorVisitor;

/**
* Unit test for the PHP4 constructor visitor
* Unit test for the PHP4 constructor visitor.
*
* @author Ron Rademaker
*/
class PHP4ConstructorVisitorTest extends PHPUnit_Framework_TestCase
{
/**
* Test if an anonymous class is dealt with correctly
* Test if an anonymous class is dealt with correctly.
*/
public function testAnonymousClassIsValid()
{
Expand Down

0 comments on commit 77436b6

Please sign in to comment.