Skip to content

Commit

Permalink
Revert #3882
Browse files Browse the repository at this point in the history
  • Loading branch information
keradus committed Oct 14, 2018
1 parent c6b5113 commit eda42eb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
8 changes: 4 additions & 4 deletions src/Fixer/Phpdoc/PhpdocAnnotationWithoutDotFixer.php
Expand Up @@ -78,8 +78,8 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens)
$content = $annotation->getContent();

if (
1 !== Preg::match('/[.。]\h*(\R|$)/u', $content)
|| 0 !== Preg::match('/[.。](?!\h*(\R|$))/u', $content, $matches)
1 !== Preg::match('/[.。]\h*$/u', $content)
|| 0 !== Preg::match('/[.。](?!\h*$)/u', $content, $matches)
) {
continue;
}
Expand All @@ -92,9 +92,9 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens)
? sprintf('(?:%s\s+(?:\$\w+\s+)?)?', preg_quote(implode('|', $annotation->getTypes()), '/'))
: '';
$content = Preg::replaceCallback(
'/^(\s*\*\s*@\w+\s+'.$optionalTypeRegEx.')(\p{Lu}?(?=\p{Ll}|\p{Zs}))(.*)(\R|$)/',
'/^(\s*\*\s*@\w+\s+'.$optionalTypeRegEx.')(\p{Lu}?(?=\p{Ll}|\p{Zs}))(.*)$/',
static function (array $matches) {
return $matches[1].strtolower($matches[2]).$matches[3].$matches[4];
return $matches[1].strtolower($matches[2]).$matches[3];
},
$startLine->getContent(),
1
Expand Down
25 changes: 9 additions & 16 deletions tests/Fixer/Phpdoc/PhpdocAnnotationWithoutDotFixerTest.php
Expand Up @@ -163,22 +163,6 @@ public function provideFixCases()
],
[
'<?php
/**
* This is a broken phpdoc
* @param string $str surprisingly, it is a string
*/
function fixMe($str) {}',
'<?php
/**
* This is a broken phpdoc
* @param string $str Surprisingly, it is a string.
*/
function fixMe($str) {}',
],
[
'<?php
/**
* Dispatches an event to all registered listeners.
*
Expand Down Expand Up @@ -207,6 +191,15 @@ function extractObjectToPopulate($class, array $context, $key = null) {}
],
[
'<?php
/**
* This is a broken phpdoc - missing asterisk
* @param string $str As it is broken, let us not apply the rule to description of parameter.
*/
function foo($str) {}',
],
[
'<?php
/**
* @return bool|null Returns `true` if the class has a single-column ID.
Returns `false` otherwise.
Expand Down

0 comments on commit eda42eb

Please sign in to comment.