Skip to content

Commit

Permalink
Merge branch 'feature/issue-1605-squiz-operator-spacing-unary' of htt…
Browse files Browse the repository at this point in the history
  • Loading branch information
gsherwood committed Aug 15, 2017
2 parents a0b7f03 + c0564f5 commit 016aa86
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public function process(File $phpcsFile, $stackPtr)
if ($tokens[$stackPtr]['code'] === T_MINUS || $tokens[$stackPtr]['code'] === T_PLUS) {
// Check minus spacing, but make sure we aren't just assigning
// a minus value or returning one.
$prev = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
$prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
if ($tokens[$prev]['code'] === T_RETURN) {
// Just returning a negative value; eg. (return -1).
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,3 +201,12 @@ $res = $a ? : $b;
$res = $a ? : $b;

function foo(string $a = '', ?string $b = ''): ?string {}

// Issue #1605.
$text = preg_replace_callback(
self::CHAR_REFS_REGEX,
[ 'Sanitizer', 'decodeCharReferencesCallback' ],
$text, /* limit */ -1, $count );

if (true || /* test */ -1 == $b) {}
$y = 10 + /* test */ -2;
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,12 @@ $res = $a ? : $b;
$res = $a ? : $b;

function foo(string $a = '', ?string $b = ''): ?string {}

// Issue #1605.
$text = preg_replace_callback(
self::CHAR_REFS_REGEX,
[ 'Sanitizer', 'decodeCharReferencesCallback' ],
$text, /* limit */ -1, $count );

if (true || /* test */ -1 == $b) {}
$y = 10 + /* test */ -2;

0 comments on commit 016aa86

Please sign in to comment.