Skip to content

Commit

Permalink
[ci-review] Rector Rectify
Browse files Browse the repository at this point in the history
  • Loading branch information
kaizen-ci committed Apr 1, 2021
1 parent ab0462a commit 9cdd885
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ final class DoctrineAnnotationTagValueNode extends AbstractTagValueNode implemen
*/
private $hasChanged = false;

/**
* @var string|null
*/
private $silentKey;

/**
* @param array<mixed, mixed> $values
*/
Expand All @@ -59,7 +54,6 @@ public function __construct(
$this->annotationClass = $annotationClass;
$this->docContent = $docContent;
$this->values = $values;
$this->silentKey = $silentKey;
$this->hasChanged = true;

parent::__construct(
Expand All @@ -72,7 +66,7 @@ public function __construct(

public function __toString(): string
{
if ($this->hasChanged === false) {
if (! $this->hasChanged) {
if ($this->docContent === null) {
return '';
}
Expand Down Expand Up @@ -126,11 +120,10 @@ public function getValuesWithExplicitSilentAndWithoutQuotes(): array
{
$explicitKeysValues = [];

foreach ($this->values as $key => $value) {
foreach (array_keys($this->values) as $key) {
$valueWithoutQuotes = $this->getValueWithoutQuotes($key);

if (is_int($key)) {
$explicitKeysValues[$this->silentKey] = $valueWithoutQuotes;
} else {
$explicitKeysValues[$key] = $valueWithoutQuotes;
}
Expand Down Expand Up @@ -244,8 +237,10 @@ private function stringifyValue($value): string
if ($value === true) {
return 'true';
}

if (is_int($value) || is_float($value)) {
if (is_int($value)) {
return (string) $value;
}
if (is_float($value)) {
return (string) $value;
}

Expand Down
9 changes: 6 additions & 3 deletions packages/BetterPhpDocParser/PhpDocInfo/PhpDocInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,14 @@ public function getByAnnotationClass(string $class): ?DoctrineAnnotationTagValue
if ($annotationClass === $class) {
return $phpDocChildNode->value;
}

// fnmatch
if (Strings::contains($class, '*') && fnmatch($class, $annotationClass, FNM_NOESCAPE)) {
return $phpDocChildNode->value;
if (! Strings::contains($class, '*')) {
continue;
}
if (! fnmatch($class, $annotationClass, FNM_NOESCAPE)) {
continue;
}
return $phpDocChildNode->value;
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
final class SilentKeyMap
{
/**
* @var array<class-string, string>
* @var array<string, string>
*/
public const CLASS_NAMES_TO_SILENT_KEYS = [
'Symfony\Component\Routing\Annotation\Route' => 'path',
Expand Down
2 changes: 1 addition & 1 deletion packages/BetterPhpDocParser/ValueObject/NodeTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ final class NodeTypes
];

/**
* @var array<class-string>
* @var string[]
*/
public const TYPE_AWARE_DOCTRINE_ANNOTATION_CLASSES = [
'JMS\Serializer\Annotation\Type',
Expand Down

0 comments on commit 9cdd885

Please sign in to comment.