Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: StatementIndentationFixer - handle monolithic php only #7864

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion phpstan.dist.neon
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ parameters:
-
message: '#^Method PhpCsFixer\\Tests\\.+::provide.+Cases\(\) return type has no value type specified in iterable type iterable\.$#'
path: tests
count: 1021
count: 1020
tipsOfTheDay: false
tmpDir: dev-tools/phpstan/cache
2 changes: 1 addition & 1 deletion src/Fixer/Whitespace/StatementIndentationFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public function getPriority(): int

public function isCandidate(Tokens $tokens): bool
{
return true;
return $tokens->isMonolithicPhp();
}

protected function createConfigurationDefinition(): FixerConfigurationResolverInterface
Expand Down
87 changes: 13 additions & 74 deletions tests/Fixer/Basic/BracesFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1404,7 +1404,7 @@ function mixedComplex()

yield [
'<?php if (true) {
echo "s";
echo "s";
} ?>x',
'<?php if (true) echo "s" ?>x',
];
Expand Down Expand Up @@ -2437,7 +2437,7 @@ function mixedComplex()

yield [
'<?php if (true) {
echo "s";
echo "s";
} ?>x',
'<?php if (true) echo "s" ?>x',
self::CONFIGURATION_OOP_POSITION_SAME_LINE,
Expand Down Expand Up @@ -3234,10 +3234,6 @@ public static function provideFixCommentBeforeBraceCases(): iterable

yield [
'<?php
if ($a) { //
?><?php ++$a;
} ?>',
'<?php
if ($a) { //
?><?php ++$a;
} ?>',
Expand Down Expand Up @@ -5418,63 +5414,6 @@ public static function provideMessyWhitespacesCases(): iterable
];
}

/**
* @dataProvider provideNowdocInTemplatesCases
*/
public function testNowdocInTemplates(string $expected, ?string $input = null): void
{
$this->doTest($expected, $input);
}

public static function provideNowdocInTemplatesCases(): iterable
{
yield [
<<<'EOT'
<?php
if (true) {
$var = <<<'NOWDOC'
NOWDOC;
?>
<?php
}

EOT,
<<<'EOT'
<?php
if (true) {
$var = <<<'NOWDOC'
NOWDOC;
?>
<?php
}

EOT,
];

yield [
<<<'EOT'
<?php
if (true) {
$var = <<<HEREDOC
HEREDOC;
?>
<?php
}

EOT,
<<<'EOT'
<?php
if (true) {
$var = <<<HEREDOC
HEREDOC;
?>
<?php
}

EOT,
];
}

/**
* @dataProvider provideFixCommentsCases
*/
Expand Down Expand Up @@ -5809,7 +5748,7 @@ public static function provideFixAlternativeSyntaxCases(): iterable

yield [
'<?php if ($a) {
foreach ($b as $c): ?> X <?php endforeach;
foreach ($b as $c): ?> X <?php endforeach;
} ?>',
'<?php if ($a) foreach ($b as $c): ?> X <?php endforeach; ?>',
];
Expand Down Expand Up @@ -5843,25 +5782,25 @@ public static function provideFixAlternativeSyntaxCases(): iterable
yield [
'<?php
if ($a) {
foreach ($b as $c): ?>
foreach ($b as $c): ?>
<?php if ($a) {
for (;;): ?>
for (;;): ?>
<?php if ($a) {
foreach ($b as $c): ?>
foreach ($b as $c): ?>
<?php if ($a) {
for (;;): ?>
for (;;): ?>
<?php if ($a) {
while ($b): ?>
while ($b): ?>
<?php if ($a) {
while ($b): ?>
while ($b): ?>
<?php if ($a) {
foreach ($b as $c): ?>
foreach ($b as $c): ?>
<?php if ($a) {
for (;;): ?>
for (;;): ?>
<?php if ($a) {
while ($b): ?>
while ($b): ?>
<?php if ($a) {
while ($b): ?>
while ($b): ?>
<?php endwhile;
} ?>
<?php endwhile;
Expand Down