@@ -52,7 +52,7 @@ private static function getFeature(array $json, $filePath)
5252
5353 return new FeatureNode (
5454 $ featureJson ['name ' ] ?? null ,
55- trim ( $ featureJson ['description ' ] ?? '' ) ? : null ,
55+ $ featureJson ['description ' ] ? trim ( $ featureJson [ ' description ' ]) : null ,
5656 self ::getTags ($ featureJson ),
5757 self ::getBackground ($ featureJson ),
5858 self ::getScenarios ($ featureJson ),
@@ -158,17 +158,23 @@ private static function getTables(array $items): array
158158 static function ($ tableJson ) {
159159 $ table = [];
160160
161- if (!isset ($ tableJson ['tableHeader ' ])) {
162- throw new NodeException (
163- sprintf (
164- 'Table header is required, but none was specified for the example on line %s. ' ,
165- $ tableJson ['location ' ]['line ' ],
166- )
167- );
161+ if (isset ($ tableJson ['tableHeader ' ])) {
162+ // Table header seems to have been deprecated, but is still in use (in cucumber test fixtures)
163+ $ table [$ tableJson ['tableHeader ' ]['location ' ]['line ' ]] = array_column ($ tableJson ['tableHeader ' ]['cells ' ], 'value ' );
164+ } else {
165+ // Otherwise, assume the header is the first row (which would be now required)
166+ $ firstRow = array_shift ($ tableJson ['tableBody ' ]);
167+ if ($ firstRow === null ) {
168+ throw new NodeException (
169+ sprintf (
170+ 'Expected either a table header or at least one row for the example on line %s but found none. ' ,
171+ $ tableJson ['location ' ]['line ' ],
172+ )
173+ );
174+ }
175+ $ table [$ firstRow ['line ' ]] = array_column ($ firstRow ['cells ' ], 'value ' );
168176 }
169177
170- $ table [$ tableJson ['tableHeader ' ]['location ' ]['line ' ]] = array_column ($ tableJson ['tableHeader ' ]['cells ' ], 'value ' );
171-
172178 foreach ($ tableJson ['tableBody ' ] as $ bodyRow ) {
173179 $ table [$ bodyRow ['location ' ]['line ' ]] = array_column ($ bodyRow ['cells ' ], 'value ' );
174180 }
0 commit comments