File tree Expand file tree Collapse file tree
src/Codeception/Lib/Console Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2828 "phpunit/phpunit" : " ^9.5.20 | ^10.0 | ^11.0 | ^12.0 | ^13.0" ,
2929 "psy/psysh" : " ^0.11.2 | ^0.12" ,
3030 "sebastian/comparator" : " ^4.0.5 | ^5.0 | ^6.0 | ^7.0 | ^8.0" ,
31- "sebastian/diff" : " ^4.0.3 | ^5.0 | ^6.0 | ^7.0 | ^8.0" ,
31+ "sebastian/diff" : " ^4.0.3 | ^5.0 | ^6.0 | ^7.0 | ^8.0 | ^9.0 " ,
3232 "symfony/console" : " >=5.4.24 <9.0" ,
3333 "symfony/css-selector" : " >=5.4.24 <9.0" ,
3434 "symfony/event-dispatcher" : " >=5.4.24 <9.0" ,
Original file line number Diff line number Diff line change 66
77use SebastianBergmann \Comparator \ComparisonFailure ;
88use SebastianBergmann \Diff \Differ ;
9+ use SebastianBergmann \Diff \Output \StrictUnifiedDiffOutputBuilder ;
910use SebastianBergmann \Diff \Output \UnifiedDiffOutputBuilder ;
1011
1112class DiffFactory
@@ -17,7 +18,23 @@ public function createDiff(ComparisonFailure $failure): string
1718
1819 private function getDiff (string $ expected = '' , string $ actual = '' ): string
1920 {
20- $ differ = new Differ (new UnifiedDiffOutputBuilder ('' ));
21+ // Ensure compatibility with sebastian/diff v8.3.0
22+ // v8.3.0 added the parameter $emitNoLineEndEofWarning
23+ // v9.0.0 removed the class UnifiedDiffOutputBuilder, therefore
24+ // use StrictUnifiedDiffOutputBuilder right away.
25+ if (
26+ !class_exists (UnifiedDiffOutputBuilder::class)
27+ || property_exists (UnifiedDiffOutputBuilder::class, 'emitNoLineEndEofWarning ' )
28+ ) {
29+ $ outputBuilder = new StrictUnifiedDiffOutputBuilder ([
30+ 'addLineNumbers ' => false ,
31+ 'emitNoLineEndEofWarning ' => false ,
32+ 'header ' => '' ,
33+ ]);
34+ } else {
35+ $ outputBuilder = new UnifiedDiffOutputBuilder ('' );
36+ }
37+ $ differ = new Differ ($ outputBuilder );
2138 return ($ expected || $ actual ) ? $ differ ->diff ($ expected , $ actual ) : '' ;
2239 }
2340}
You can’t perform that action at this time.
0 commit comments