Skip to content

PHPCBF bug: foreach no brace with ${$var['key']} #1321

@GaryJones

Description

@GaryJones

Original code:

foreach ( $item['postmeta'] as $meta )
	${$meta['key']} = $meta['value'];

After phpcbf with PHP 7.1.7, this results in:

foreach ( $item['postmeta'] as $meta ) {
	$meta['key']} = $meta['value'];

Instead of:

foreach ( $item['postmeta'] as $meta ) {
	${$meta['key']} = $meta['value'];
}

Report:

  938 | ERROR   | [x] Opening brace should be on the same line as the declaration (WordPress.WhiteSpace.ControlStructureSpacing.OpenBraceNotSameLine)
  938 | ERROR   | [x] Expected 1 space(s) after closing parenthesis; found "\n            $" (Squiz.ControlStructures.ControlSignature.SpaceAfterCloseParenthesis)
  939 | ERROR   | [x] Newline required after opening brace (Squiz.ControlStructures.ControlSignature.NewlineAfterOpenBrace)
  939 | ERROR   | [x] Array keys must NOT be surrounded by spaces if they only contain a string or an integer. (WordPress.Arrays.ArrayKeySpacingRestrictions.SpacesAroundArrayKeys)
  939 | ERROR   | [x] Array keys must NOT be surrounded by spaces if they only contain a string or an integer. (WordPress.Arrays.ArrayKeySpacingRestrictions.SpacesAroundArrayKeys)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions