Skip to content

Commit 32caf26

Browse files
KrinkleWMDE bot
authored andcommitted
phpunit: Use "@" instead of temporary error_reporting override
The native silence operator, or previously wikimedia/at-ease, are the preferred ways to silence an intentional warning rather than stateful and global overrides to error_reporting. See also T253461. == Why now == Out of dozens of possible almost-off/neutral states, this code used E_USER_ERROR, presumably because it is the only error code we never use. Either way, referencing the E_USER_ERROR constant causes a deprecation warning in PHP 8.4+. Bug: T379445 Change-Id: I1f2450f53b6b673f1d5c09f42c2a10f45567962b
1 parent 34770a9 commit 32caf26

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

tests/unit/Diff/ItemDiffTest.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,13 @@ public function testIsEmpty( array $diffOps, $isEmpty ) {
229229
* diffs for substructures even in recursive mode (bug 51363).
230230
*/
231231
public function testAtomicSubstructureWorkaround() {
232-
$oldErrorLevel = error_reporting( E_USER_ERROR );
233-
234232
$atomicListDiff = new DiffOpChange(
235233
[ 'a' => 'A', 'b' => 'B' ],
236234
[ 'b' => 'B', 'a' => 'A' ]
237235
);
238236

239-
$diff = new ItemDiff( [
237+
// Ignore intentional warning for "Invalid substructure diff"
238+
$diff = @new ItemDiff( [
240239
'aliases' => $atomicListDiff,
241240
'label' => $atomicListDiff,
242241
'description' => $atomicListDiff,
@@ -249,8 +248,6 @@ public function testAtomicSubstructureWorkaround() {
249248
$this->assertInstanceOf( Diff::class, $diff->getDescriptionsDiff() );
250249
$this->assertInstanceOf( Diff::class, $diff->getClaimsDiff() );
251250
$this->assertInstanceOf( Diff::class, $diff->getSiteLinkDiff() );
252-
253-
error_reporting( $oldErrorLevel );
254251
}
255252

256253
}

0 commit comments

Comments
 (0)