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

Commit f406777

Browse files
localheinzweierophinney
authored andcommitted
Enhancement: Assert that method names using reserved keywords are ignored
1 parent e50e9f7 commit f406777

File tree

3 files changed

+78
-0
lines changed

3 files changed

+78
-0
lines changed

test/ClassFileLocatorTest.php

+26
Original file line numberDiff line numberDiff line change
@@ -177,4 +177,30 @@ public function testIgnoresAnonymousClasses()
177177

178178
$this->assertEquals($expected, $classNames);
179179
}
180+
181+
/**
182+
* @requires PHP 7.1
183+
*/
184+
public function testIgnoresMethodsNamedAfterKeywords()
185+
{
186+
$classFileLocator = new ClassFileLocator(__DIR__ . '/TestAsset/WithMethodsNamedAfterKeywords');
187+
188+
$classFiles = \iterator_to_array($classFileLocator);
189+
190+
$this->assertCount(2, $classFiles);
191+
192+
$classNames = \array_reduce($classFiles, function (array $classNames, PhpClassFile $classFile) {
193+
return \array_merge(
194+
$classNames,
195+
$classFile->getClasses()
196+
);
197+
}, []);
198+
199+
$expected = [
200+
TestAsset\WithMethodsNamedAfterKeywords\WithoutReturnTypeDeclaration::class,
201+
TestAsset\WithMethodsNamedAfterKeywords\WithReturnTypeDeclaration::class,
202+
];
203+
204+
$this->assertEquals($expected, $classNames, '', 0.0, 10, true);
205+
}
180206
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
/**
4+
* Zend Framework (http://framework.zend.com/)
5+
*
6+
* @link https://github.com/zendframework/zend-file for the canonical source repository
7+
* @copyright Copyright (c) 2017 Zend Technologies USA Inc. (http://www.zend.com)
8+
* @license https://github.com/zendframework/zend-file/blob/master/LICENSE.md New BSD License
9+
*/
10+
11+
namespace ZendTest\File\TestAsset\WithMethodsNamedAfterKeywords;
12+
13+
final class WithReturnTypeDeclaration
14+
{
15+
public function class(): string
16+
{
17+
}
18+
19+
public function interface(): string
20+
{
21+
}
22+
23+
public function trait(): string
24+
{
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
/**
4+
* Zend Framework (http://framework.zend.com/)
5+
*
6+
* @link https://github.com/zendframework/zend-file for the canonical source repository
7+
* @copyright Copyright (c) 2017 Zend Technologies USA Inc. (http://www.zend.com)
8+
* @license https://github.com/zendframework/zend-file/blob/master/LICENSE.md New BSD License
9+
*/
10+
11+
namespace ZendTest\File\TestAsset\WithMethodsNamedAfterKeywords;
12+
13+
final class WithoutReturnTypeDeclaration
14+
{
15+
public function class()
16+
{
17+
}
18+
19+
public function interface()
20+
{
21+
}
22+
23+
public function trait()
24+
{
25+
}
26+
}

0 commit comments

Comments
 (0)