Skip to content

CS update after upstream changes #124

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

Merged
merged 6 commits into from
Aug 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
@@ -1,21 +1,35 @@
<?xml version="1.0"?>
<ruleset name="phpDocumentor">
<description>The coding standard for phpDocumentor.</description>
<ruleset name="TypeResolver">
<description>The coding standard for this library.</description>

<file>src</file>
<file>tests/unit</file>
<exclude-pattern>*/tests/unit/Types/ContextFactoryTest.php</exclude-pattern>
<exclude-pattern>*/tests/unit/Types/ContextFactoryTest\.php</exclude-pattern>
<arg value="p"/>

<!-- Set the minimum PHP version for PHPCompatibility.
This should be kept in sync with the requirements in the composer.json file. -->
<config name="testVersion" value="7.2-"/>

<rule ref="phpDocumentor">
<!-- Property type declarations are a PHP 7.4 feature. -->
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingNativeTypeHint"/>
</rule>

<rule ref="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming.SuperfluousPrefix">
<exclude-pattern>*/src/*/Abstract*.php</exclude-pattern>
<exclude-pattern>*/src/*/Abstract*\.php</exclude-pattern>
</rule>

<rule ref="PSR1.Files.SideEffects.FoundWithSymbols">
<exclude-pattern>*/src/PseudoTypes/False_.php</exclude-pattern>
<exclude-pattern>*/src/PseudoTypes/True_.php</exclude-pattern>
<exclude-pattern>*/src/PseudoTypes/False_\.php</exclude-pattern>
<exclude-pattern>*/src/PseudoTypes/True_\.php</exclude-pattern>
</rule>

<!-- Ignore two PHP 8.0 constants which are being polyfilled in the file using them. -->
<rule ref="PHPCompatibility.Constants.NewConstants.t_name_qualifiedFound">
<exclude-pattern>*/src/Types/ContextFactory\.php</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.Constants.NewConstants.t_name_fully_qualifiedFound">
<exclude-pattern>*/src/Types/ContextFactory\.php</exclude-pattern>
</rule>
</ruleset>
7 changes: 4 additions & 3 deletions src/FqsenResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use InvalidArgumentException;
use phpDocumentor\Reflection\Types\Context;

use function explode;
use function implode;
use function strpos;
Expand All @@ -29,7 +30,7 @@ class FqsenResolver
/** @var string Definition of the NAMESPACE operator in PHP */
private const OPERATOR_NAMESPACE = '\\';

public function resolve(string $fqsen, ?Context $context = null) : Fqsen
public function resolve(string $fqsen, ?Context $context = null): Fqsen
{
if ($context === null) {
$context = new Context('');
Expand All @@ -45,7 +46,7 @@ public function resolve(string $fqsen, ?Context $context = null) : Fqsen
/**
* Tests whether the given type is a Fully Qualified Structural Element Name.
*/
private function isFqsen(string $type) : bool
private function isFqsen(string $type): bool
{
return strpos($type, self::OPERATOR_NAMESPACE) === 0;
}
Expand All @@ -56,7 +57,7 @@ private function isFqsen(string $type) : bool
*
* @throws InvalidArgumentException When type is not a valid FQSEN.
*/
private function resolvePartialStructuralElementName(string $type, Context $context) : Fqsen
private function resolvePartialStructuralElementName(string $type, Context $context): Fqsen
{
$typeParts = explode(self::OPERATOR_NAMESPACE, $type, 2);

Expand Down
2 changes: 1 addition & 1 deletion src/PseudoType.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@

interface PseudoType extends Type
{
public function underlyingType() : Type;
public function underlyingType(): Type;
}
4 changes: 2 additions & 2 deletions src/PseudoTypes/CallableString.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
*/
final class CallableString extends String_ implements PseudoType
{
public function underlyingType() : Type
public function underlyingType(): Type
{
return new String_();
}

/**
* Returns a rendered output of the Type as it would be used in a DocBlock.
*/
public function __toString() : string
public function __toString(): string
{
return 'callable-string';
}
Expand Down
5 changes: 3 additions & 2 deletions src/PseudoTypes/False_.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use phpDocumentor\Reflection\PseudoType;
use phpDocumentor\Reflection\Type;
use phpDocumentor\Reflection\Types\Boolean;

use function class_alias;

/**
Expand All @@ -25,12 +26,12 @@
*/
final class False_ extends Boolean implements PseudoType
{
public function underlyingType() : Type
public function underlyingType(): Type
{
return new Boolean();
}

public function __toString() : string
public function __toString(): string
{
return 'false';
}
Expand Down
4 changes: 2 additions & 2 deletions src/PseudoTypes/HtmlEscapedString.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
*/
final class HtmlEscapedString extends String_ implements PseudoType
{
public function underlyingType() : Type
public function underlyingType(): Type
{
return new String_();
}

/**
* Returns a rendered output of the Type as it would be used in a DocBlock.
*/
public function __toString() : string
public function __toString(): string
{
return 'html-escaped-string';
}
Expand Down
4 changes: 2 additions & 2 deletions src/PseudoTypes/LowercaseString.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
*/
final class LowercaseString extends String_ implements PseudoType
{
public function underlyingType() : Type
public function underlyingType(): Type
{
return new String_();
}

/**
* Returns a rendered output of the Type as it would be used in a DocBlock.
*/
public function __toString() : string
public function __toString(): string
{
return 'lowercase-string';
}
Expand Down
4 changes: 2 additions & 2 deletions src/PseudoTypes/NonEmptyLowercaseString.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
*/
final class NonEmptyLowercaseString extends String_ implements PseudoType
{
public function underlyingType() : Type
public function underlyingType(): Type
{
return new String_();
}

/**
* Returns a rendered output of the Type as it would be used in a DocBlock.
*/
public function __toString() : string
public function __toString(): string
{
return 'non-empty-lowercase-string';
}
Expand Down
4 changes: 2 additions & 2 deletions src/PseudoTypes/NonEmptyString.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
*/
final class NonEmptyString extends String_ implements PseudoType
{
public function underlyingType() : Type
public function underlyingType(): Type
{
return new String_();
}

/**
* Returns a rendered output of the Type as it would be used in a DocBlock.
*/
public function __toString() : string
public function __toString(): string
{
return 'non-empty-string';
}
Expand Down
4 changes: 2 additions & 2 deletions src/PseudoTypes/NumericString.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
*/
final class NumericString extends String_ implements PseudoType
{
public function underlyingType() : Type
public function underlyingType(): Type
{
return new String_();
}

/**
* Returns a rendered output of the Type as it would be used in a DocBlock.
*/
public function __toString() : string
public function __toString(): string
{
return 'numeric-string';
}
Expand Down
4 changes: 2 additions & 2 deletions src/PseudoTypes/PositiveInteger.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
*/
final class PositiveInteger extends Integer implements PseudoType
{
public function underlyingType() : Type
public function underlyingType(): Type
{
return new Integer();
}

/**
* Returns a rendered output of the Type as it would be used in a DocBlock.
*/
public function __toString() : string
public function __toString(): string
{
return 'positive-int';
}
Expand Down
4 changes: 2 additions & 2 deletions src/PseudoTypes/TraitString.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
*/
final class TraitString extends String_ implements PseudoType
{
public function underlyingType() : Type
public function underlyingType(): Type
{
return new String_();
}

/**
* Returns a rendered output of the Type as it would be used in a DocBlock.
*/
public function __toString() : string
public function __toString(): string
{
return 'trait-string';
}
Expand Down
5 changes: 3 additions & 2 deletions src/PseudoTypes/True_.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use phpDocumentor\Reflection\PseudoType;
use phpDocumentor\Reflection\Type;
use phpDocumentor\Reflection\Types\Boolean;

use function class_alias;

/**
Expand All @@ -25,12 +26,12 @@
*/
final class True_ extends Boolean implements PseudoType
{
public function underlyingType() : Type
public function underlyingType(): Type
{
return new Boolean();
}

public function __toString() : string
public function __toString(): string
{
return 'true';
}
Expand Down
2 changes: 1 addition & 1 deletion src/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ interface Type
/**
* Returns a rendered output of the Type as it would be used in a DocBlock.
*/
public function __toString() : string;
public function __toString(): string;
}
Loading