Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Collections: deprecate $textStingStartTokens in favour of textStingSt…
…artTokens() Over the last three PHP versions, PHP has steadily kept on introducing new tokens. In the context of this class, the introduction of a new token means that a collection can no longer be a property and must be changed to a method with some logic instead. With this in mind, all properties in the `Collections` class are being deprecated in favour of methods, to prevent the BC-breaks this kind of change would cause if left till later. The deprecated properties will be removed (or made `private`) before the `1.0.0` version is tagged. The deprecation in the upcoming alpha gives standards which have started to implement the use of PHPCSUtils a little time to switch over though. Includes only a perfunctory unit test for the new method, as the `textStingStartTokens()` method doesn't contain any actual logic. For now, it is just safeguarded that a) the method is available and can be called and b) that the method is in line with the now deprecated property. Includes replacing any references to this property in the PHPCSUtils codebase to now call the function instead.
- Loading branch information
Showing
4 changed files
with
56 additions
and
3 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,37 @@ | ||
<?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::textStingStartTokens | ||
* | ||
* @group collections | ||
* | ||
* @since 1.0.0 | ||
*/ | ||
class TextStingStartTokensTest extends TestCase | ||
{ | ||
|
||
/** | ||
* Test the method. | ||
* | ||
* @return void | ||
*/ | ||
public function testTextStingStartTokens() | ||
{ | ||
$this->assertSame(Collections::$textStingStartTokens, Collections::textStingStartTokens()); | ||
} | ||
} |