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

Commit

Permalink
Merge branch 'hotfix/zendframework/zendframework#6946-ignore-php-5-5-…
Browse files Browse the repository at this point in the history
…scalar-class-name-resolution'

Close zendframework/zendframework#6946
Close zendframework/zendframework#6814
  • Loading branch information
Ocramius committed Nov 29, 2014
152 parents 452ae1b + 4c2d087 + 15d7ad3 + 43d486b + de6c4f3 + c04ecdf + 7b52962 + 9e9b7fb + 9654dc2 + 77fcf26 + a8d7175 + 2df1fa2 + 2eea980 + 5e212bf + 099a852 + b4fea29 + ca1f464 + 23d6321 + 296e43e + d444a38 + 3db95a1 + 981d623 + 0a2e3ae + af23c99 + 80f5165 + 78d16a9 + 6bc4f23 + ece1d99 + 0b9ced2 + 9d50bff + 476d115 + c660c64 + 23e480a + 2d1a86f + bcd3a85 + d46ca8d + 236d691 + 0c0ae53 + 16da5d7 + 1c4489e + a57bb3d + c14d67b + b241e8d + 10c9e19 + 33f9f3b + 4585cfe + d06b3a5 + 371eaa8 + c9fbe3f + 77552c9 + 5883d28 + 518460f + 63a6a3b + f21d820 + 5b80282 + 8d4f7c0 + 3428c24 + 50a5cf9 + 0fcf91c + ffd0e6c + 90cc750 + 4c0cba4 + 9e64972 + 3a86f54 + f4931d8 + 9c496b9 + f36d38f + 1b580df + dab01ce + bc6e247 + 96739b6 + e1b5376 + 1c7183f + 0e68ed1 + 5b3198f + 929c939 + f7e2963 + 611c83e + 1d9e7ae + eae64aa + 1f3f9e7 + b2d7401 + 2f1d9d3 + de6b908 + c73007c + 9565c63 + bc2a6d0 + 264d24f + c9c493c + 3992e0d + 5225965 + 0de9a5c + 867db21 + 34fe2aa + 6ec2723 + e576e38 + cbc0283 + d007f6e + db4f03e + f8f7897 + 4cb349f + f5287db + e7abf4a + b1e5a28 + 6c77a16 + d3f730c + 9abb387 + c0b8c0d + f8bc057 + 4f32b4b + aa46231 + 52390dd + aed5127 + d6219ab + cc8aa50 + 3796880 + 3460327 + 6371934 + bdc1874 + 540ba2f + c5fa53c + c1cd9d0 + e861d7a + bfa4749 + 5ec28c8 + 5078786 + 9d152ef + 3376d96 + 2851abb + 8728f2a + e5443b4 + 6b3466e + 435b7e1 + 3abf077 + 3e7551c + 0af2391 + 60c43e9 + d3bdecf + 7b55dd6 + e705b54 + 6d56b35 + 8383390 + 5642b61 + 85af0e4 + 4bef446 + 1de66d7 + 2cfd916 + 297bb66 + 7bb614c + b49dbbb + 55d21d8 + 475e3c8 commit 480db95
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/ClassFileLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ public function accept()
break;
case $t_trait:
case T_CLASS:
// ignore T_CLASS after T_DOUBLE_COLON to allow PHP >=5.5 FQCN scalar resolution
if ($i > 0 && is_array($tokens[$i-1]) && $tokens[$i-1][0] === T_DOUBLE_COLON) {
break;
}
case T_INTERFACE:
// Abstract class, class, interface or trait found

Expand Down
18 changes: 18 additions & 0 deletions test/ClassFileLocatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,22 @@ public function testIterationShouldFindMultipleClassesInMultipleNamespacesInSing
$this->assertTrue($foundThird);
$this->assertTrue($foundFourth);
}

/**
* @group 6946
* @group 6814
*/
public function testIterationShouldNotCountFQCNScalarResolutionConstantAsClass()
{
if (PHP_VERSION_ID < 50500) {
$this->markTestSkipped('Only applies to PHP >=5.5');
}

foreach (new ClassFileLocator(__DIR__ .'/TestAsset') as $file) {
if (! preg_match('/ClassNameResolutionCompatibility\.php$/', $file->getFilename())) {
continue;
}
$this->assertCount(1, $file->getClasses());
}
}
}
20 changes: 20 additions & 0 deletions test/TestAsset/ClassNameResolutionCompatibility.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace ZendTest\File\TestAsset;

use stdClass;

class ClassNameResolutionCompatibility
{
protected $someClassNames = [
stdClass::class,
stdClass::class,
];
}

0 comments on commit 480db95

Please sign in to comment.