Skip to content

Commit

Permalink
Fix psalm config move from psalm.xml to docBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
devanych committed Aug 25, 2020
1 parent e41252a commit 69cd602
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 14 deletions.
11 changes: 0 additions & 11 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,6 @@
</projectFiles>

<issueHandlers>
<DocblockTypeContradiction errorLevel="info" />
<MixedArgument errorLevel="info" />
<MixedArgumentTypeCoercion errorLevel="info" />
<MixedAssignment errorLevel="info" />
<MixedPropertyTypeCoercion errorLevel="info" />
<PossiblyNullArgument errorLevel="info" />
<PossiblyNullOperand errorLevel="info" />
<PossiblyNullReference errorLevel="info" />
<PropertyNotSetInConstructor errorLevel="info" />
<RedundantCondition errorLevel="info" />
<RedundantConditionGivenDocblockType errorLevel="info" />
<TypeDoesNotContainType errorLevel="info" />
</issueHandlers>
</psalm>
10 changes: 8 additions & 2 deletions src/MessageTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public function getHeaders(): array
* @return bool Returns true if any header names match the given header
* name using a case-insensitive string comparison. Returns false if
* no matching header name is found in the message.
* @psalm-suppress RedundantConditionGivenDocblockType
*/
public function hasHeader($name): bool
{
Expand Down Expand Up @@ -199,6 +200,7 @@ public function getHeaderLine($name): string
* @param string|string[] $value Header value(s).
* @return static
* @throws InvalidArgumentException for invalid header names or values.
* @psalm-suppress MixedPropertyTypeCoercion
*/
public function withHeader($name, $value): MessageInterface
{
Expand Down Expand Up @@ -233,6 +235,7 @@ public function withHeader($name, $value): MessageInterface
* @param string|string[] $value Header value(s).
* @return static
* @throws InvalidArgumentException for invalid header names or values.
* @psalm-suppress MixedPropertyTypeCoercion
*/
public function withAddedHeader($name, $value): MessageInterface
{
Expand Down Expand Up @@ -308,6 +311,7 @@ public function withBody(StreamInterface $body): MessageInterface
/**
* @param StreamInterface|string|resource $stream
* @param string $mode
* @psalm-suppress RedundantConditionGivenDocblockType
*/
private function registerStream($stream, string $mode = 'wb+'): void
{
Expand All @@ -329,8 +333,9 @@ private function registerStream($stream, string $mode = 'wb+'): void
}

/**
* @param array $originalHeaders
* @param array<string, string|int|float> $originalHeaders
* @throws InvalidArgumentException When the header name or header value is not valid.
* @psalm-suppress MixedPropertyTypeCoercion
*/
private function registerHeaders(array $originalHeaders = []): void
{
Expand Down Expand Up @@ -393,6 +398,7 @@ private function validateHeaderName($name): void
/**
* @param mixed $value
* @throws InvalidArgumentException for invalid header value.
* @psalm-suppress MixedAssignment
*/
private function validateHeaderValue($value): void
{
Expand All @@ -415,7 +421,7 @@ private function validateHeaderValue($value): void
}

/**
* @param string $protocol
* @param mixed $protocol
* @throws InvalidArgumentException for invalid HTTP protocol version.
*/
private function validateProtocolVersion($protocol): void
Expand Down
3 changes: 3 additions & 0 deletions src/RequestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ public function getMethod(): string
* @param string $method Case-sensitive method.
* @return static
* @throws InvalidArgumentException for invalid HTTP methods.
* @psalm-suppress DocblockTypeContradiction
*/
public function withMethod($method): RequestInterface
{
Expand Down Expand Up @@ -216,6 +217,7 @@ public function withUri(UriInterface $uri, $preserveHost = false): RequestInterf
* @param array $headers
* @param StreamInterface|string|resource $body
* @param string $protocol
* @psalm-suppress MixedArgumentTypeCoercion
*/
private function init(
string $method = 'GET',
Expand All @@ -239,6 +241,7 @@ private function init(
/**
* @param UriInterface|string $uri
* @throws InvalidArgumentException for invalid URI.
* @psalm-suppress RedundantConditionGivenDocblockType
*/
private function setUri($uri): void
{
Expand Down
7 changes: 6 additions & 1 deletion src/ResponseTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ trait ResponseTrait
* Map of standard HTTP status code and reason phrases.
*
* @link https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
* @var array
* @var array<int, string>
*/
private static array $phrases = [
// Informational 1xx
Expand Down Expand Up @@ -144,6 +144,9 @@ public function getStatusCode(): int
* use the defaults as suggested in the HTTP specification.
* @return static
* @throws InvalidArgumentException for invalid status code arguments.
* @psalm-suppress DocblockTypeContradiction
* @psalm-suppress TypeDoesNotContainType
* @psalm-suppress RedundantCondition
*/
public function withStatus($code, $reasonPhrase = ''): ResponseInterface
{
Expand Down Expand Up @@ -181,6 +184,7 @@ public function withStatus($code, $reasonPhrase = ''): ResponseInterface
* @link http://tools.ietf.org/html/rfc7231#section-6
* @link http://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
* @return string Reason phrase; must return an empty string if none present.
* @psalm-suppress RedundantCondition
*/
public function getReasonPhrase(): string
{
Expand All @@ -193,6 +197,7 @@ public function getReasonPhrase(): string
* @param StreamInterface|string|resource $body
* @param array $headers
* @param string $protocol
* @psalm-suppress MixedArgumentTypeCoercion
*/
private function init(
int $statusCode = 200,
Expand Down
3 changes: 3 additions & 0 deletions src/ServerRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ public function getParsedBody()

/**
* {@inheritDoc}
*
* @psalm-suppress DocblockTypeContradiction
*/
public function withParsedBody($data): self
{
Expand Down Expand Up @@ -223,6 +225,7 @@ public function withoutAttribute($name): self
/**
* @param array $uploadedFiles
* @throws InvalidArgumentException
* @psalm-suppress MixedAssignment
*/
private function validateUploadedFiles(array $uploadedFiles): void
{
Expand Down
2 changes: 2 additions & 0 deletions src/StreamFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public function createStreamFromFile(string $filename, string $mode = 'r'): Stre

/**
* {@inheritdoc}
*
* @psalm-suppress DocblockTypeContradiction
*/
public function createStreamFromResource($resource): StreamInterface
{
Expand Down
4 changes: 4 additions & 0 deletions src/StreamTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public function __toString(): string
* Closes the stream and any underlying resources.
*
* @return void
* @psalm-suppress PossiblyNullArgument
*/
public function close(): void
{
Expand Down Expand Up @@ -196,6 +197,7 @@ public function rewind(): void
* Returns whether or not the stream is writable.
*
* @return bool
* @psalm-suppress MixedAssignment
*/
public function isWritable(): bool
{
Expand Down Expand Up @@ -240,6 +242,7 @@ public function write($string): int
* Returns whether or not the stream is readable.
*
* @return bool
* @psalm-suppress MixedAssignment
*/
public function isReadable(): bool
{
Expand Down Expand Up @@ -282,6 +285,7 @@ public function read($length): string
*
* @return string
* @throws RuntimeException if unable to read or an error occurs while reading.
* @psalm-suppress PossiblyNullArgument
*/
public function getContents(): string
{
Expand Down
6 changes: 6 additions & 0 deletions src/UploadedFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ final class UploadedFile implements UploadedFileInterface
* @param int $error
* @param string|null $clientFilename
* @param string|null $clientMediaType
* @psalm-suppress RedundantConditionGivenDocblockType
*/
public function __construct(
$streamOrFile,
Expand Down Expand Up @@ -145,6 +146,8 @@ public function __construct(

/**
* {@inheritdoc}
*
* @psalm-suppress PossiblyNullArgument
*/
public function getStream(): StreamInterface
{
Expand All @@ -165,6 +168,8 @@ public function getStream(): StreamInterface

/**
* {@inheritdoc}
*
* @psalm-suppress DocblockTypeContradiction
*/
public function moveTo($targetPath): void
{
Expand Down Expand Up @@ -237,6 +242,7 @@ public function getClientMediaType(): ?string
* files via is_uploaded_file() and move_uploaded_file() or writes If SAPI is not used.
*
* @param string $targetPath
* @psalm-suppress PossiblyNullReference
*/
private function moveOrWriteFile(string $targetPath): void
{
Expand Down
3 changes: 3 additions & 0 deletions src/Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ public function getScheme(): string

/**
* {@inheritDoc}
*
* @psalm-suppress PossiblyNullOperand
*/
public function getAuthority(): string
{
Expand Down Expand Up @@ -480,6 +482,7 @@ private function normalizeFragment(string $fragment): string
* @param string $string
* @param string $pattern
* @return string
* @psalm-suppress MixedArgument
*/
private function encode(string $string, string $pattern): string
{
Expand Down

0 comments on commit 69cd602

Please sign in to comment.