Skip to content
Permalink
Browse files

NullableParamStyleFixer - fix for reference (#186)

  • Loading branch information
kubawerlos committed Nov 13, 2019
1 parent bffe185 commit 26bf4ce8270dd612b80fd3a642aee93cad4e30d0
Showing with 13 additions and 2 deletions.
  1. +1 −1 README.md
  2. +1 −1 src/Fixer/NullableParamStyleFixer.php
  3. +11 −0 tests/Fixer/NullableParamStyleFixerTest.php
@@ -8,7 +8,7 @@

[![Build status](https://img.shields.io/travis/kubawerlos/php-cs-fixer-custom-fixers/master.svg)](https://travis-ci.org/kubawerlos/php-cs-fixer-custom-fixers)
[![Code coverage](https://img.shields.io/coveralls/github/kubawerlos/php-cs-fixer-custom-fixers/master.svg)](https://coveralls.io/github/kubawerlos/php-cs-fixer-custom-fixers?branch=master)
![Tests](https://img.shields.io/badge/tests-1458-brightgreen.svg)
![Tests](https://img.shields.io/badge/tests-1460-brightgreen.svg)
[![Mutation testing badge](https://badge.stryker-mutator.io/github.com/kubawerlos/php-cs-fixer-custom-fixers/master)](https://stryker-mutator.github.io)
[![Psalm type coverage](https://shepherd.dev/github/kubawerlos/php-cs-fixer-custom-fixers/coverage.svg)](https://shepherd.dev/github/kubawerlos/php-cs-fixer-custom-fixers)

@@ -94,7 +94,7 @@ private function fixFunction(Tokens $tokens, int $paramBlockStartIndex, int $par
/** @var int $typeIndex */
$typeIndex = $tokens->getPrevMeaningfulToken($variableIndex);

if (!$tokens[$typeIndex]->isGivenKind([CT::T_ARRAY_TYPEHINT, T_CALLABLE, T_STRING])) {
if (!$tokens[$typeIndex]->equalsAny(['&', [CT::T_ARRAY_TYPEHINT], [T_CALLABLE], [T_STRING]])) {
continue;
}

@@ -95,5 +95,16 @@ public function provideFixCases(): iterable
'<?php $foo = function (?int $x = null, $y = null) {};',
'<?php $foo = function (int $x = null, $y = null) {};',
];

yield [
'<?php $foo = function (?int &$x = null) {};',
'<?php $foo = function (int &$x = null) {};',
];

yield [
'<?php $foo = function (int &$x = null) {};',
'<?php $foo = function (?int &$x = null) {};',
['style' => 'without_question_mark'],
];
}
}

0 comments on commit 26bf4ce

Please sign in to comment.
You can’t perform that action at this time.