Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Jan 9, 2024
2 parents 400433a + d2906cd commit 0fe181e
Show file tree
Hide file tree
Showing 13 changed files with 909 additions and 297 deletions.
7 changes: 5 additions & 2 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
* with this source code in the file LICENSE.
*/

use PhpCsFixer\Config;
use PhpCsFixer\Finder;

$header = <<<'EOF'
This file is part of PHP CS Fixer.
Expand All @@ -22,14 +25,14 @@
with this source code in the file LICENSE.
EOF;

$finder = (new PhpCsFixer\Finder())
$finder = (new Finder())
->ignoreDotFiles(false)
->ignoreVCSIgnored(true)
->exclude(['dev-tools/phpstan', 'tests/Fixtures'])
->in(__DIR__)
;

return (new PhpCsFixer\Config())
return (new Config())
->setRiskyAllowed(true)
->setRules([
'@PHP74Migration' => true,
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ A *config* knows about the code style rules and the files and directories that m
You can do some things to increase the chance that your pull request is accepted without communication ping-pong between you and the reviewers:

* Submit [single](https://en.wikipedia.org/wiki/Single-responsibility_principle) pull request per fix or feature.
* Don't amend commits because it makes review rounds harder - all commits from your branch will be squashed (without commit messages) during merge, so you can treat pull request as a playground, without keeping everything tidy at any point.
* If your changes are not up-to-date, [rebase](https://git-scm.com/docs/git-rebase) your branch onto the parent branch. Do it regularly whenever your branch is behind `master` branch, that will eliminate risk of problems after the merge.
* Keep meaningful commit logs, don't use meaningless messages (e.g. `foo`, `more work`, `more work`, `more work`) and don't push complex PR as a single commit.
* Don't [amend](https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---amend) commits because it makes review rounds harder - all commits from your branch will be squashed (without commit messages) during the merge.
* Follow the conventions used in the project.
* Remember about tests and documentation.
* Don't bump `PhpCsFixer\Console\Application::VERSION`, it's done during release.
Expand Down
8 changes: 5 additions & 3 deletions dev-tools/info-extractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
* with this source code in the file LICENSE.
*/

use PhpCsFixer\Console\Application;

require_once __DIR__.'/../vendor/autoload.php';

$version = [
'number' => PhpCsFixer\Console\Application::VERSION,
'vnumber' => 'v'.PhpCsFixer\Console\Application::VERSION,
'codename' => PhpCsFixer\Console\Application::VERSION_CODENAME,
'number' => Application::VERSION,
'vnumber' => 'v'.Application::VERSION,
'codename' => Application::VERSION_CODENAME,
];

echo json_encode([
Expand Down
3 changes: 1 addition & 2 deletions src/Doctrine/Annotation/Tokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

namespace PhpCsFixer\Doctrine\Annotation;

use PhpCsFixer\Doctrine\Annotation\Token as AnnotationToken;
use PhpCsFixer\Preg;
use PhpCsFixer\Tokenizer\Token as PhpToken;

Expand Down Expand Up @@ -103,7 +102,7 @@ public static function createFromDocComment(PhpToken $input, array $ignoredTags
$lastTokenEndIndex = 0;
foreach (\array_slice($scannedTokens, 0, $nbScannedTokensToUse) as $token) {
if ($token->isType(DocLexer::T_STRING)) {
$token = new AnnotationToken(
$token = new Token(
$token->getType(),
'"'.str_replace('"', '""', $token->getContent()).'"',
$token->getPosition()
Expand Down
15 changes: 7 additions & 8 deletions src/Fixer/FunctionNotation/PhpdocToReturnTypeFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
namespace PhpCsFixer\Fixer\FunctionNotation;

use PhpCsFixer\AbstractPhpdocToTypeDeclarationFixer;
use PhpCsFixer\DocBlock\Annotation;
use PhpCsFixer\FixerDefinition\CodeSample;
use PhpCsFixer\FixerDefinition\FixerDefinition;
use PhpCsFixer\FixerDefinition\FixerDefinitionInterface;
Expand Down Expand Up @@ -153,8 +152,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
continue;
}

/** @var Annotation $returnTypeAnnotation */
$returnTypeAnnotation = current($returnTypeAnnotations);
$returnTypeAnnotation = $returnTypeAnnotations[0];

$typesExpression = $returnTypeAnnotation->getTypeExpression();

Expand Down Expand Up @@ -185,20 +183,21 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens): void
continue;
}

$startIndex = $tokens->getNextTokenOfKind($index, ['{', ';']);
$paramsStartIndex = $tokens->getNextTokenOfKind($index, ['(']);
$paramsEndIndex = $tokens->findBlockEnd(Tokens::BLOCK_TYPE_PARENTHESIS_BRACE, $paramsStartIndex);

if ($this->hasReturnTypeHint($tokens, $startIndex)) {
$bodyStartIndex = $tokens->getNextTokenOfKind($paramsEndIndex, ['{', ';', [T_DOUBLE_ARROW]]);

if ($this->hasReturnTypeHint($tokens, $bodyStartIndex)) {
continue;
}

if (!$this->isValidSyntax(sprintf(self::TYPE_CHECK_TEMPLATE, $returnType))) {
continue;
}

$endFuncIndex = $tokens->getPrevTokenOfKind($startIndex, [')']);

$tokens->insertAt(
$endFuncIndex + 1,
$paramsEndIndex + 1,
array_merge(
[
new Token([CT::T_TYPE_COLON, ':']),
Expand Down

0 comments on commit 0fe181e

Please sign in to comment.