-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
91 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
/** | ||
* Unit tests for PHP_CompatInfo package, return type declaration sniff | ||
* | ||
* PHP version 7 | ||
* | ||
* @category PHP | ||
* @package PHP_CompatInfo | ||
* @subpackage Tests | ||
* @author Laurent Laville <[email protected]> | ||
* @license https://opensource.org/licenses/BSD-3-Clause The 3-Clause BSD License | ||
* @since Class available since Release 5.4.0 | ||
*/ | ||
|
||
namespace Bartlett\Tests\CompatInfo; | ||
|
||
use Bartlett\CompatInfo\Analyser\CompatibilityAnalyser; | ||
use Bartlett\Reflect\Client; | ||
|
||
/** | ||
* @link https://wiki.php.net/rfc/return_types | ||
* @link https://www.php.net/manual/en/migration70.new-features.php#migration70.new-features.return-type-declarations | ||
*/ | ||
class ReturnTypeDeclarationSniffTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
protected static $fixtures; | ||
protected static $analyserId; | ||
protected static $api; | ||
|
||
/** | ||
* Sets up the shared fixture. | ||
* | ||
* @return void | ||
*/ | ||
public static function setUpBeforeClass(): void | ||
{ | ||
self::$fixtures = __DIR__ . DIRECTORY_SEPARATOR | ||
. 'fixtures' . DIRECTORY_SEPARATOR | ||
. 'sniffs' . DIRECTORY_SEPARATOR | ||
; | ||
|
||
self::$analyserId = CompatibilityAnalyser::class; | ||
|
||
$client = new Client(); | ||
|
||
// request for a Bartlett\Reflect\Api\Analyser | ||
self::$api = $client->api('analyser'); | ||
} | ||
|
||
/** | ||
* Regression test for return type hint declaration detection GH#233 | ||
* | ||
* @link https://github.com/llaville/php-compat-info/issues/233 | ||
* PHP 7 requirement not detected for return type hint | ||
* @group features | ||
* @group regression | ||
* @return void | ||
*/ | ||
public function testReturnTypeHint() | ||
{ | ||
$dataSource = self::$fixtures . 'return_types.php'; | ||
$analysers = ['compatibility']; | ||
$metrics = self::$api->run($dataSource, $analysers); | ||
$versions = $metrics[self::$analyserId]['versions']; | ||
|
||
$this->assertEquals( | ||
[ | ||
'php.min' => '7.0.0alpha1', | ||
'php.max' => '', | ||
'php.all' => '7.0.0alpha1', | ||
], | ||
$versions | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters