Skip to content

Tests/GetClassPropertiesTest: sync with upstream - minor improvements #542

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 34 additions & 34 deletions Tests/BackCompat/BCFile/GetClassPropertiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class GetClassPropertiesTest extends UtilityMethodTestCase
*
* @dataProvider dataNotAClassException
*
* @param string $testMarker The comment which prefaces the target token in the test file.
* @param array $tokenType The type of token to look for after the marker.
* @param string $testMarker The comment which prefaces the target token in the test file.
* @param int|string $tokenType The type of token to look for after the marker.
*
* @return void
*/
Expand All @@ -59,22 +59,22 @@ public function testNotAClassException($testMarker, $tokenType)
*
* @see testNotAClassException() For the array format.
*
* @return array
* @return array<string, array<string, string|int>>
*/
public static function dataNotAClassException()
{
return [
'interface' => [
'/* testNotAClass */',
\T_INTERFACE,
'testMarker' => '/* testNotAClass */',
'tokenType' => \T_INTERFACE,
],
'anon-class' => [
'/* testAnonClass */',
\T_ANON_CLASS,
'testMarker' => '/* testAnonClass */',
'tokenType' => \T_ANON_CLASS,
],
'enum' => [
'/* testEnum */',
\T_ENUM,
'testMarker' => '/* testEnum */',
'tokenType' => \T_ENUM,
],
];
}
Expand All @@ -84,8 +84,8 @@ public static function dataNotAClassException()
*
* @dataProvider dataGetClassProperties
*
* @param string $testMarker The comment which prefaces the target token in the test file.
* @param array $expected Expected function output.
* @param string $testMarker The comment which prefaces the target token in the test file.
* @param array<string, bool|int> $expected Expected function output.
*
* @return void
*/
Expand All @@ -104,14 +104,14 @@ public function testGetClassProperties($testMarker, $expected)
*
* @see testGetClassProperties() For the array format.
*
* @return array
* @return array<string, array<string, string|array<string, bool|int>>>
*/
public static function dataGetClassProperties()
{
return [
'no-properties' => [
'/* testClassWithoutProperties */',
[
'testMarker' => '/* testClassWithoutProperties */',
'expected' => [
'is_abstract' => false,
'abstract_token' => false,
'is_final' => false,
Expand All @@ -121,8 +121,8 @@ public static function dataGetClassProperties()
],
],
'abstract' => [
'/* testAbstractClass */',
[
'testMarker' => '/* testAbstractClass */',
'expected' => [
'is_abstract' => true,
'abstract_token' => -2,
'is_final' => false,
Expand All @@ -132,8 +132,8 @@ public static function dataGetClassProperties()
],
],
'final' => [
'/* testFinalClass */',
[
'testMarker' => '/* testFinalClass */',
'expected' => [
'is_abstract' => false,
'abstract_token' => false,
'is_final' => true,
Expand All @@ -143,8 +143,8 @@ public static function dataGetClassProperties()
],
],
'readonly' => [
'/* testReadonlyClass */',
[
'testMarker' => '/* testReadonlyClass */',
'expected' => [
'is_abstract' => false,
'abstract_token' => false,
'is_final' => false,
Expand All @@ -154,8 +154,8 @@ public static function dataGetClassProperties()
],
],
'final-readonly' => [
'/* testFinalReadonlyClass */',
[
'testMarker' => '/* testFinalReadonlyClass */',
'expected' => [
'is_abstract' => false,
'abstract_token' => false,
'is_final' => true,
Expand All @@ -165,8 +165,8 @@ public static function dataGetClassProperties()
],
],
'readonly-final' => [
'/* testReadonlyFinalClass */',
[
'testMarker' => '/* testReadonlyFinalClass */',
'expected' => [
'is_abstract' => false,
'abstract_token' => false,
'is_final' => true,
Expand All @@ -176,8 +176,8 @@ public static function dataGetClassProperties()
],
],
'abstract-readonly' => [
'/* testAbstractReadonlyClass */',
[
'testMarker' => '/* testAbstractReadonlyClass */',
'expected' => [
'is_abstract' => true,
'abstract_token' => -4,
'is_final' => false,
Expand All @@ -187,8 +187,8 @@ public static function dataGetClassProperties()
],
],
'readonly-abstract' => [
'/* testReadonlyAbstractClass */',
[
'testMarker' => '/* testReadonlyAbstractClass */',
'expected' => [
'is_abstract' => true,
'abstract_token' => -2,
'is_final' => false,
Expand All @@ -198,8 +198,8 @@ public static function dataGetClassProperties()
],
],
'comments-and-new-lines' => [
'/* testWithCommentsAndNewLines */',
[
'testMarker' => '/* testWithCommentsAndNewLines */',
'expected' => [
'is_abstract' => true,
'abstract_token' => -6,
'is_final' => false,
Expand All @@ -209,8 +209,8 @@ public static function dataGetClassProperties()
],
],
'no-properties-with-docblock' => [
'/* testWithDocblockWithoutProperties */',
[
'testMarker' => '/* testWithDocblockWithoutProperties */',
'expected' => [
'is_abstract' => false,
'abstract_token' => false,
'is_final' => false,
Expand All @@ -220,8 +220,8 @@ public static function dataGetClassProperties()
],
],
'abstract-final-parse-error' => [
'/* testParseErrorAbstractFinal */',
[
'testMarker' => '/* testParseErrorAbstractFinal */',
'expected' => [
'is_abstract' => true,
'abstract_token' => -5,
'is_final' => true,
Expand Down
6 changes: 3 additions & 3 deletions Tests/Utils/ObjectDeclarations/GetClassPropertiesDiffTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ public function testGetClassProperties($testMarker, $expected)
$class = $this->getTargetToken($testMarker, \T_CLASS);

// Translate offsets to absolute token positions.
if ($expected['abstract_token'] !== false) {
if (\is_int($expected['abstract_token']) === true) {
$expected['abstract_token'] += $class;
}
if ($expected['final_token'] !== false) {
if (\is_int($expected['final_token']) === true) {
$expected['final_token'] += $class;
}
if ($expected['readonly_token'] !== false) {
if (\is_int($expected['readonly_token']) === true) {
$expected['readonly_token'] += $class;
}

Expand Down
6 changes: 3 additions & 3 deletions Tests/Utils/ObjectDeclarations/GetClassPropertiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ public function testGetClassProperties($testMarker, $expected)
$class = $this->getTargetToken($testMarker, \T_CLASS);

// Translate offsets to absolute token positions.
if ($expected['abstract_token'] !== false) {
if (\is_int($expected['abstract_token']) === true) {
$expected['abstract_token'] += $class;
}
if ($expected['final_token'] !== false) {
if (\is_int($expected['final_token']) === true) {
$expected['final_token'] += $class;
}
if ($expected['readonly_token'] !== false) {
if (\is_int($expected['readonly_token']) === true) {
$expected['readonly_token'] += $class;
}

Expand Down