Skip to content

Commit

Permalink
QA: add missing early return statement
Browse files Browse the repository at this point in the history
In contrast to the intention expressed in the comment in the code, the state was not being ignored as the function did not `return` within the `if` statement.

As the docblock indicates that the function should return an array, I've chosen to return an empty array for this event, but I can imagine that throwing a `RuntimeException` or returning with a more specific error state in the array may be more appropriate.

Consider this PR as flagging up the code error, but the final implementation needs to be decided by people more familiar with the code than me.
  • Loading branch information
jrfnl committed Sep 28, 2022
1 parent 74b0377 commit a6e9ac3
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions packages/block-serialization-default-parser/parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ function next_token() {
*/
if ( $is_closer && ( $is_void || $has_attrs ) ) {
// we can ignore them since they don't hurt anything.
return array();
}

if ( $is_void ) {
Expand Down

0 comments on commit a6e9ac3

Please sign in to comment.