Skip to content

Commit 7b6d644

Browse files
committed
Apply suggestions from code review
1 parent 606fc2f commit 7b6d644

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

WordPress/Tests/Helpers/ContextHelper/IsInIssetOrEmptyUnitTest.inc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* The below should NOT be recognized as being inside an isset/empty check.
55
*/
66

7+
/* testBareVariable */ $value;
78
some_function( /* testOtherFunctionCall */ $value );
89
array_key_exists( /* testMissingArrayParam */ $key );
910
key_exists( /* testKeyParamNotArrayParam */ $value, $array );
@@ -14,7 +15,7 @@ namespace\Sub\key_exists( 'key', /* testNamespaceRelativeSubFunction */ $array )
1415
$obj->array_key_exists( 'key', /* testObjectMethod */ $array );
1516
$obj?->key_exists( 'key', /* testNullsafeObjectMethod */ $array );
1617
MyClass::array_key_exists( 'key', /* testStaticMethod */ $array );
17-
key_exists( 'key', my_function( /* testNestedFunctionCall */ $array ) );
18+
key_exists( 'key', my_function( /* testNestedNonTargetFunctionCall */ $array ) );
1819

1920
/*
2021
* The below should be recognized as being inside an isset/empty check.
@@ -27,3 +28,4 @@ Key_Exists( 'key', /* testMixedCaseFunction */ $array );
2728
\array_key_exists( 'key', /* testFullyQualifiedFunction */ $array );
2829
\KEY_EXISTS( 'key', /* testFullyQualifiedUpperCaseFunction */ $array );
2930
array_key_exists( array: /* testNamedParamReversedOrder */ $array, key: 'foo' );
31+
array_key_exists( 'key', \key_exists( 'key', /* testNestedValidFunctionCall */ $array ) );

WordPress/Tests/Helpers/ContextHelper/IsInIssetOrEmptyUnitTest.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ public function testIsInIssetOrEmpty( $testMarker, $expectedResult ) {
4848
public static function dataIsInIssetOrEmpty() {
4949
return array(
5050
// Cases that should return false.
51+
'bare_variable' => array(
52+
'testMarker' => '/* testBareVariable */',
53+
'expectedResult' => false,
54+
),
5155
'other_function_call' => array(
5256
'testMarker' => '/* testOtherFunctionCall */',
5357
'expectedResult' => false,
@@ -88,8 +92,8 @@ public static function dataIsInIssetOrEmpty() {
8892
'testMarker' => '/* testStaticMethod */',
8993
'expectedResult' => false,
9094
),
91-
'nested_function_call' => array(
92-
'testMarker' => '/* testNestedFunctionCall */',
95+
'nested_non_target_function_call' => array(
96+
'testMarker' => '/* testNestedNonTargetFunctionCall */',
9397
'expectedResult' => false,
9498
),
9599

@@ -122,6 +126,10 @@ public static function dataIsInIssetOrEmpty() {
122126
'testMarker' => '/* testNamedParamReversedOrder */',
123127
'expectedResult' => true,
124128
),
129+
'nested_valid_function_call' => array(
130+
'testMarker' => '/* testNestedValidFunctionCall */',
131+
'expectedResult' => true,
132+
),
125133
);
126134
}
127135
}

0 commit comments

Comments
 (0)