-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #176 from PHPCSStandards/feature/php8-nullsafe-ope…
…rator PHP 8.0 | Add utilities to handle the nullsafe object operator
- Loading branch information
Showing
10 changed files
with
513 additions
and
2 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
50 changes: 50 additions & 0 deletions
50
Tests/Tokens/Collections/NullsafeObjectOperatorTokensBCTest.php
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,50 @@ | ||
<?php | ||
/** | ||
* PHPCSUtils, utility functions and classes for PHP_CodeSniffer sniff developers. | ||
* | ||
* @package PHPCSUtils | ||
* @copyright 2019-2020 PHPCSUtils Contributors | ||
* @license https://opensource.org/licenses/LGPL-3.0 LGPL3 | ||
* @link https://github.com/PHPCSStandards/PHPCSUtils | ||
*/ | ||
|
||
namespace PHPCSUtils\Tests\Tokens\Collections; | ||
|
||
use PHPCSUtils\Tokens\Collections; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Test class. | ||
* | ||
* @covers \PHPCSUtils\Tokens\Collections::nullsafeObjectOperatorBC | ||
* | ||
* @group collections | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
class NullsafeObjectOperatorBCTest extends TestCase | ||
{ | ||
|
||
/** | ||
* Test the method. | ||
* | ||
* @return void | ||
*/ | ||
public function testNullsafeObjectOperatorBC() | ||
{ | ||
$expected = []; | ||
if (\version_compare(\PHP_VERSION_ID, '80000', '>=') === true | ||
) { | ||
$expected = [ | ||
\T_NULLSAFE_OBJECT_OPERATOR => \T_NULLSAFE_OBJECT_OPERATOR, | ||
]; | ||
} else { | ||
$expected = [ | ||
\T_INLINE_THEN => \T_INLINE_THEN, | ||
\T_OBJECT_OPERATOR => \T_OBJECT_OPERATOR, | ||
]; | ||
} | ||
|
||
$this->assertSame($expected, Collections::nullsafeObjectOperatorBC()); | ||
} | ||
} |
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,49 @@ | ||
<?php | ||
/** | ||
* PHPCSUtils, utility functions and classes for PHP_CodeSniffer sniff developers. | ||
* | ||
* @package PHPCSUtils | ||
* @copyright 2019-2020 PHPCSUtils Contributors | ||
* @license https://opensource.org/licenses/LGPL-3.0 LGPL3 | ||
* @link https://github.com/PHPCSStandards/PHPCSUtils | ||
*/ | ||
|
||
namespace PHPCSUtils\Tests\Tokens\Collections; | ||
|
||
use PHPCSUtils\Tokens\Collections; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Test class. | ||
* | ||
* @covers \PHPCSUtils\Tokens\Collections::objectOperatorsBC | ||
* | ||
* @group collections | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
class ObjectOperatorsBCTest extends TestCase | ||
{ | ||
|
||
/** | ||
* Test the method. | ||
* | ||
* @return void | ||
*/ | ||
public function testObjectOperatorsBC() | ||
{ | ||
$expected = [ | ||
\T_OBJECT_OPERATOR => \T_OBJECT_OPERATOR, | ||
\T_DOUBLE_COLON => \T_DOUBLE_COLON, | ||
]; | ||
|
||
if (\version_compare(\PHP_VERSION_ID, '80000', '>=') === true | ||
) { | ||
$expected[\T_NULLSAFE_OBJECT_OPERATOR] = \T_NULLSAFE_OBJECT_OPERATOR; | ||
} else { | ||
$expected[\T_INLINE_THEN] = \T_INLINE_THEN; | ||
} | ||
|
||
$this->assertSame($expected, Collections::objectOperatorsBC()); | ||
} | ||
} |
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,47 @@ | ||
<?php | ||
/** | ||
* PHPCSUtils, utility functions and classes for PHP_CodeSniffer sniff developers. | ||
* | ||
* @package PHPCSUtils | ||
* @copyright 2019-2020 PHPCSUtils Contributors | ||
* @license https://opensource.org/licenses/LGPL-3.0 LGPL3 | ||
* @link https://github.com/PHPCSStandards/PHPCSUtils | ||
*/ | ||
|
||
namespace PHPCSUtils\Tests\Tokens\Collections; | ||
|
||
use PHPCSUtils\Tokens\Collections; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Test class. | ||
* | ||
* @covers \PHPCSUtils\Tokens\Collections::objectOperators | ||
* | ||
* @group collections | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
class ObjectOperatorsTest extends TestCase | ||
{ | ||
|
||
/** | ||
* Test the method. | ||
* | ||
* @return void | ||
*/ | ||
public function testObjectOperators() | ||
{ | ||
$expected = [ | ||
\T_OBJECT_OPERATOR => \T_OBJECT_OPERATOR, | ||
\T_DOUBLE_COLON => \T_DOUBLE_COLON, | ||
]; | ||
|
||
if (\version_compare(\PHP_VERSION_ID, '80000', '>=') === true | ||
) { | ||
$expected[\T_NULLSAFE_OBJECT_OPERATOR] = \T_NULLSAFE_OBJECT_OPERATOR; | ||
} | ||
|
||
$this->assertSame($expected, Collections::objectOperators()); | ||
} | ||
} |
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
Oops, something went wrong.