Skip to content

Commit ca82714

Browse files
authored
Add test case for automatic string conversion (#33)
* Add test case for automatic string conversion This may be confusing because if PHP encounters an undefined symbol, it will issue a warning and try converting it to a string. Because of this fallback, using unquoted strings may seem like valid PHP, but it's not doing what you might think it's doing; it's actually still using a string. In a future version of php, this fallback may be removed, so it's recommended to avoid it (see the warning here: https://www.php.net/manual/en/migration72.deprecated.php). * Add case to test * Fix another test that uses that fixture
1 parent 92f6325 commit ca82714

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

tests/Sniffs/Imports/RequireImportsSniffTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ public function testRequireImportsSniffFindsWordPressPatternsIfNotSet() {
169169
61,
170170
63,
171171
74,
172+
80,
172173
];
173174
$this->assertEquals($expectedLines, $lines);
174175
}
@@ -185,7 +186,7 @@ public function testRequireImportsSniffIgnoresWordPressPatternsIfSet() {
185186
);
186187
$phpcsFile->process();
187188
$lines = $helper->getWarningLineNumbersFromFile($phpcsFile);
188-
$expectedLines = [ 38, 61, 63 ];
189+
$expectedLines = [ 38, 61, 63, 80 ];
189190
$this->assertEquals($expectedLines, $lines);
190191
}
191192

tests/Sniffs/Imports/WordPressFixture.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,6 @@ public function test_additional_constants() {
7575
);
7676
}
7777
}
78+
79+
function foo() {}
80+
add_action('init', foo);

0 commit comments

Comments
 (0)