Skip to content

Commit 06fc029

Browse files
committed
Support heredoc and nowdoc
1 parent f4ad678 commit 06fc029

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![Latest stable version](https://img.shields.io/packagist/v/kubawerlos/php-cs-fixer-custom-fixers.svg?label=current%20version)](https://packagist.org/packages/kubawerlos/php-cs-fixer-custom-fixers)
66
[![PHP version](https://img.shields.io/packagist/php-v/kubawerlos/php-cs-fixer-custom-fixers.svg)](https://php.net)
77
[![License](https://img.shields.io/github/license/kubawerlos/php-cs-fixer-custom-fixers.svg)](LICENSE)
8-
![Tests](https://img.shields.io/badge/tests-3740-brightgreen.svg)
8+
![Tests](https://img.shields.io/badge/tests-3742-brightgreen.svg)
99
[![Downloads](https://img.shields.io/packagist/dt/kubawerlos/php-cs-fixer-custom-fixers.svg)](https://packagist.org/packages/kubawerlos/php-cs-fixer-custom-fixers)
1010

1111
[![CI status](https://github.com/kubawerlos/php-cs-fixer-custom-fixers/actions/workflows/ci.yaml/badge.svg)](https://github.com/kubawerlos/php-cs-fixer-custom-fixers/actions/workflows/ci.yaml)

src/Fixer/TypedClassConstantFixer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ final class TypedClassConstantFixer extends AbstractFixer
2323
{
2424
private const INTEGER_KINDS = [\T_LNUMBER, '+', '-', '*', '(', ')', \T_POW, \T_SL, \T_SR];
2525
private const FLOAT_KINDS = [\T_DNUMBER, ...self::INTEGER_KINDS, '/'];
26-
private const STRING_KINDS = [\T_CONSTANT_ENCAPSED_STRING, \T_LNUMBER, \T_DNUMBER];
26+
private const STRING_KINDS = [\T_CONSTANT_ENCAPSED_STRING, \T_START_HEREDOC, \T_ENCAPSED_AND_WHITESPACE, \T_END_HEREDOC, \T_LNUMBER, \T_DNUMBER];
2727

2828
public function getDefinition(): FixerDefinitionInterface
2929
{

tests/Fixer/TypedClassConstantFixerTest.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,39 @@ public static function provideFixCases(): iterable
135135
"<?php class Foo { public const BAR = 'John Doe'; }",
136136
];
137137

138+
yield 'string with heredoc syntax' => [
139+
<<<'PHP'
140+
<?php class Foo {
141+
public const string BAR = <<<STRING
142+
the content
143+
STRING;
144+
}
145+
PHP,
146+
<<<'PHP'
147+
<?php class Foo {
148+
public const BAR = <<<STRING
149+
the content
150+
STRING;
151+
}
152+
PHP,
153+
];
154+
yield 'string with nowdoc syntax' => [
155+
<<<'PHP'
156+
<?php class Foo {
157+
public const string BAR = <<<'STRING'
158+
the content
159+
STRING;
160+
}
161+
PHP,
162+
<<<'PHP'
163+
<?php class Foo {
164+
public const BAR = <<<'STRING'
165+
the content
166+
STRING;
167+
}
168+
PHP,
169+
];
170+
138171
yield 'string as result of concatenations' => [
139172
'<?php class Foo { public const string BAR = "A" . 1 . "B" . 0.25 . "C"; }',
140173
'<?php class Foo { public const BAR = "A" . 1 . "B" . 0.25 . "C"; }',

0 commit comments

Comments
 (0)