Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Enhancement: Assert that method names using reserved keywords are ign…
Browse files Browse the repository at this point in the history
…ored
  • Loading branch information
localheinz committed Oct 9, 2017
1 parent c42dcb2 commit 21595e0
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/ClassFileLocatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,30 @@ public function testIgnoresAnonymousClasses()

$this->assertEquals($expected, $classNames);
}

/**
* @requires PHP 7.1
*/
public function testIgnoresMethodsNamedAfterKeywords()
{
$classFileLocator = new ClassFileLocator(__DIR__ . '/TestAsset/WithMethodsNamedAfterKeywords');

$classFiles = \iterator_to_array($classFileLocator);

$this->assertCount(2, $classFiles);

$classNames = \array_reduce($classFiles, function (array $classNames, PhpClassFile $classFile) {
return \array_merge(
$classNames,
$classFile->getClasses()
);
}, []);

$expected = [
TestAsset\WithMethodsNamedAfterKeywords\WithoutReturnTypeDeclaration::class,
TestAsset\WithMethodsNamedAfterKeywords\WithReturnTypeDeclaration::class,
];

$this->assertEquals($expected, $classNames, '', 0.0, 10, true);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

/**
* Zend Framework (http://framework.zend.com/)
*
* @link https://github.com/zendframework/zend-file for the canonical source repository
* @copyright Copyright (c) 2017 Zend Technologies USA Inc. (http://www.zend.com)
* @license https://github.com/zendframework/zend-file/blob/master/LICENSE.md New BSD License
*/

namespace ZendTest\File\TestAsset\WithMethodsNamedAfterKeywords;

final class WithReturnTypeDeclaration
{
public function class(): string
{
}

public function interface(): string
{
}

public function trait(): string
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

/**
* Zend Framework (http://framework.zend.com/)
*
* @link https://github.com/zendframework/zend-file for the canonical source repository
* @copyright Copyright (c) 2017 Zend Technologies USA Inc. (http://www.zend.com)
* @license https://github.com/zendframework/zend-file/blob/master/LICENSE.md New BSD License
*/

namespace ZendTest\File\TestAsset\WithMethodsNamedAfterKeywords;

final class WithoutReturnTypeDeclaration
{
public function class()
{
}

public function interface()
{
}

public function trait()
{
}
}

0 comments on commit 21595e0

Please sign in to comment.