-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4a1ab8e
commit 5745775
Showing
7 changed files
with
320 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\PhpDocParser\Ast\ConstExpr; | ||
|
||
use PHPStan\PhpDocParser\Ast\NodeAttributes; | ||
use function sprintf; | ||
use function str_replace; | ||
use function strlen; | ||
use function substr; | ||
|
||
class DoctrineConstExprStringNode extends ConstExprStringNode | ||
{ | ||
|
||
use NodeAttributes; | ||
|
||
/** @var string */ | ||
public $value; | ||
|
||
public function __construct(string $value) | ||
{ | ||
parent::__construct($value); | ||
$this->value = $value; | ||
} | ||
|
||
public function __toString(): string | ||
{ | ||
return self::escape($this->value); | ||
} | ||
|
||
public static function unescape(string $value): string | ||
{ | ||
// from https://github.com/doctrine/annotations/blob/a9ec7af212302a75d1f92fa65d3abfbd16245a2a/lib/Doctrine/Common/Annotations/DocLexer.php#L103-L107 | ||
return str_replace('""', '"', substr($value, 1, strlen($value) - 2)); | ||
} | ||
|
||
private static function escape(string $value): string | ||
{ | ||
// from https://github.com/phpstan/phpdoc-parser/issues/205#issuecomment-1662323656 | ||
return sprintf('"%s"', str_replace('"', '""', $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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace PHPStan\PhpDocParser\Parser\Doctrine; | ||
|
||
/** | ||
* ApiResource annotation. | ||
* | ||
* @author Kévin Dunglas <[email protected]> | ||
* | ||
* @Annotation | ||
* @Target({"CLASS"}) | ||
*/ | ||
final class ApiResource | ||
{ | ||
|
||
/** @var string */ | ||
public $shortName; | ||
|
||
/** @var string */ | ||
public $description; | ||
|
||
/** @var string */ | ||
public $iri; | ||
|
||
/** @var array */ | ||
public $itemOperations; | ||
|
||
/** @var array */ | ||
public $collectionOperations; | ||
|
||
/** @var array */ | ||
public $attributes = []; | ||
|
||
} |
Oops, something went wrong.