@@ -92,9 +92,9 @@ public function testUsageExample3(): void
9292
9393 $ matches = $ regExp ->exec ($ text );
9494
95- $ this ->assertTrue ( $ matches [ 0 ] === "SomeFile.pdf " );
96- $ this ->assertTrue ( $ matches [ 1 ] === "doc_04.pdf " );
97- $ this ->assertTrue ( $ matches [ 2 ] === "File.doc " );
95+ $ this ->assertSame ( "SomeFile.pdf " , $ matches [ 0 ] );
96+ $ this ->assertSame ( "doc_04.pdf " , $ matches [ 1 ] );
97+ $ this ->assertSame ( "File.doc " , $ matches [ 2 ] );
9898 }
9999
100100 public function testReplace (): void
@@ -111,12 +111,13 @@ public function testReplace(): void
111111
112112 $ text = $ regExp ->replace (
113113 $ text ,
114- function ($ match ) {
115- return (int )$ match + 1 ;
114+ function (string $ match ): string {
115+ // convert to int, increment and cast back to string
116+ return (string )(((int )$ match ) + 1 );
116117 }
117118 );
118119
119- $ this ->assertTrue ("99 bottles of beer on the wall " === $ text );
120+ $ this ->assertSame ("99 bottles of beer on the wall " , $ text );
120121 }
121122
122123 public function testPregMatchFlags (): void
@@ -144,16 +145,16 @@ public function testPregMatchFlags(): void
144145
145146 $ matches = $ regExp ->exec ($ text );
146147
147- $ this ->assertTrue ( is_array ( $ matches [0 ]) );
148- $ this ->assertTrue ( $ matches [0 ][0 ] === " SomeFile.pdf " );
149- $ this ->assertTrue ( $ matches [0 ][1 ] === 73 );
148+ $ this ->assertIsArray ( $ matches [0 ]);
149+ $ this ->assertSame ( " SomeFile.pdf " , $ matches [0 ][0 ]);
150+ $ this ->assertSame ( 73 , $ matches [0 ][1 ]);
150151
151- $ this ->assertTrue ( is_array ( $ matches [1 ]) );
152- $ this ->assertTrue ( $ matches [1 ][0 ] === " doc_04.pdf " );
153- $ this ->assertTrue ( $ matches [1 ][1 ] === 226 );
152+ $ this ->assertIsArray ( $ matches [1 ]);
153+ $ this ->assertSame ( " doc_04.pdf " , $ matches [1 ][0 ]);
154+ $ this ->assertSame ( 226 , $ matches [1 ][1 ]);
154155
155- $ this ->assertTrue ( is_array ( $ matches [2 ]) );
156- $ this ->assertTrue ( $ matches [2 ][0 ] === " File.doc " );
157- $ this ->assertTrue ( $ matches [2 ][1 ] === 419 );
156+ $ this ->assertIsArray ( $ matches [2 ]);
157+ $ this ->assertSame ( " File.doc " , $ matches [2 ][0 ]);
158+ $ this ->assertSame ( 419 , $ matches [2 ][1 ]);
158159 }
159160}
0 commit comments