File tree Expand file tree Collapse file tree 2 files changed +22
-14
lines changed Expand file tree Collapse file tree 2 files changed +22
-14
lines changed Original file line number Diff line number Diff line change 1111
1212 strategy :
1313 matrix :
14- # operating-system: [ubuntu-latest, windows-latest, macos-latest]
15- operating-system : [ubuntu-latest, macos-latest]
14+ operating-system : [ubuntu-latest, windows-latest, macos-latest]
1615 php-versions : ['7.2', '7.3', '7.4']
1716 runs-on : ${{ matrix.operating-system }}
1817
Original file line number Diff line number Diff line change @@ -112,22 +112,31 @@ public static function makePattern(
112112 */
113113 public static function makeArrayOutput (array $ entries ): string
114114 {
115- $ output = '' ;
116- foreach ( $ entries as $ key => $ value ) {
117- $ output .= <<<EOT
118- [ { $ key} ] => { $ value}
119-
120- EOT ;
121- }
122- $ output = rtrim ( $ output );
123-
124- return <<<EOT
115+ $ output = preg_replace ( ' /\R/ ' , "\n" , str_replace (
116+ ' {{entries}} ' ,
117+ implode ( PHP_EOL , array_map (
118+ function ( $ key, $ value): string {
119+ return " [ { $ key } ] => { $ value }" ;
120+ },
121+ array_keys ( $ entries ),
122+ array_values ( $ entries )
123+ )),
124+ <<<' EOT'
125125Array
126126(
127- {$ output }
127+ {{entries} }
128128)
129129
130- EOT ;
130+ EOT
131+ ));
132+
133+ if ($ output === null ) {
134+ throw new \UnexpectedValueException (
135+ 'Error while replacing newlines in array output '
136+ );
137+ }
138+
139+ return $ output ;
131140 }
132141
133142 /**
You can’t perform that action at this time.
0 commit comments