-
-
Notifications
You must be signed in to change notification settings - Fork 341
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve string support in Doctrine Annotations (#3645)
- Loading branch information
Showing
22 changed files
with
247 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Rector\BetterPhpDocParser\PhpDoc; | ||
|
||
use PhpParser\Node\Scalar\String_; | ||
use PHPStan\PhpDocParser\Ast\NodeAttributes; | ||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode; | ||
use Rector\NodeTypeResolver\Node\AttributeKey; | ||
use Stringable; | ||
|
||
final class StringNode implements PhpDocTagValueNode, Stringable | ||
{ | ||
use NodeAttributes; | ||
|
||
public function __construct( | ||
public string $value, | ||
) { | ||
$this->value = str_replace('""', '"', $this->value); | ||
|
||
if (str_contains($this->value, "'") && ! str_contains($this->value, "\n")) { | ||
$kind = String_::KIND_DOUBLE_QUOTED; | ||
} else { | ||
$kind = String_::KIND_SINGLE_QUOTED; | ||
} | ||
|
||
$this->setAttribute(AttributeKey::KIND, $kind); | ||
} | ||
|
||
public function __toString(): string | ||
{ | ||
return '"' . str_replace('"', '""', $this->value) . '"'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.