Skip to content

Commit

Permalink
SlevomatCodingStandard.Strings.DisallowVariableParsing: Fixed false p…
Browse files Browse the repository at this point in the history
…ositive
  • Loading branch information
kukulich committed Apr 14, 2023
1 parent 5945d69 commit 3cddc97
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class DisallowVariableParsingSniff implements Sniff

private const DOLLAR_CURLY_SYNTAX_PATTERN = '~\${[\w\[\]]+}~';
private const CURLY_DOLLAR_SYNTAX_PATTERN = '~{\$[\w\[\]\->]+}~';
private const SIMPLE_SYNTAX_PATTERN = '~(?<!{)\$[\w\[\]\->]+(?!})~';
private const SIMPLE_SYNTAX_PATTERN = '~(?<!{|\[)\$[\w\[\]\->]+(?!})~';

/** @var bool */
public $disallowDollarCurlySyntax = true;
Expand Down
2 changes: 2 additions & 0 deletions tests/Sniffs/Strings/data/disallowVariableParsingErrors.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,5 @@
Some heredoc line with array item variable $array[1]
Some heredoc line with object variable $object->name
EOT;

"{$array[$simpleString]}";

0 comments on commit 3cddc97

Please sign in to comment.