Skip to content

Commit

Permalink
Fixed Psalm errors (#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbyoung committed Aug 1, 2021
1 parent d0cec26 commit 990cf0d
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 9 deletions.
5 changes: 4 additions & 1 deletion src/Application/src/Configuration/HashTableConfiguration.php
Expand Up @@ -93,7 +93,10 @@ public function getValue(string $path): mixed

foreach ($explodedPath as $i => $pathPart) {
if (!isset($value[$pathPart])) {
$fullPathToThisPart = \implode($this->pathDelimiter, \array_slice($explodedPath, 0, $i + 1));
$fullPathToThisPart = \implode(
$this->pathDelimiter,
\array_map(static fn (mixed $value) => (string)$value, \array_slice($explodedPath, 0, $i + 1))
);

throw new MissingConfigurationValueException($fullPathToThisPart);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Console/src/Output/Formatters/TableFormatter.php
Expand Up @@ -69,7 +69,7 @@ public function format(array $rows, array $headers = []): string
'%s%s%s%s%s',
$this->verticalBorderChar,
$this->cellPaddingString,
\implode($this->cellPaddingString . $this->verticalBorderChar . $this->cellPaddingString, $row),
\implode($this->cellPaddingString . $this->verticalBorderChar . $this->cellPaddingString, \array_map(static fn (mixed $value) => (string)$value, $row)),
$this->cellPaddingString,
$this->verticalBorderChar
)
Expand Down
2 changes: 1 addition & 1 deletion src/Net/src/Http/Headers.php
Expand Up @@ -34,7 +34,7 @@ public function __toString(): string
$headerString = '';

foreach ($this->hashKeysToKvps as $kvp) {
$headerString .= "{$kvp->getKey()}: " . \implode(', ', (array)$kvp->getValue()) . "\r\n";
$headerString .= "{$kvp->getKey()}: " . \implode(', ', \array_map(static fn (mixed $value) => (string)$value, (array)$kvp->getValue())) . "\r\n";
}

return \rtrim($headerString);
Expand Down
2 changes: 1 addition & 1 deletion src/Net/src/Http/StreamResponseWriter.php
Expand Up @@ -81,7 +81,7 @@ public function writeResponse(IResponse $response): void
$this->header("$headerName: $headerValue", false);
}
} else {
$this->header("$headerName: " . \implode(', ', (array)$kvp->getValue()));
$this->header("$headerName: " . \implode(', ', \array_map(static fn (mixed $value) => (string)$value, (array)$kvp->getValue())));
}
}

Expand Down
5 changes: 0 additions & 5 deletions src/Router/tests/Attributes/AttributeRouteRegistrantTest.php
Expand Up @@ -54,7 +54,6 @@ public function testRegisteringRouteForNonControllerRegistersNothing(): void
public function testRegisteringRouteWithAllPropertiesSetCreatesRouteWithAllThosePropertiesSet(): void
{
$controller = new class() extends Controller {
/** @psalm-suppress ArgumentTypeCoercion https://github.com/vimeo/psalm/issues/4871 */
#[
Get('foo', 'example.com', 'routename', true, ['foo' => 'bar']),
RouteConstraint(DummyConstraint::class, ['param'])
Expand Down Expand Up @@ -85,7 +84,6 @@ public function route(): void
public function testRegisteringRouteWithMiddlewareCreatesRouteWithThatMiddleware(): void
{
$controller = new class() extends Controller {
/** @psalm-suppress ArgumentTypeCoercion https://github.com/vimeo/psalm/issues/4871 */
#[
Get('bar'),
Middleware(DummyMiddleware::class, ['foo' => 'bar'])
Expand All @@ -111,7 +109,6 @@ public function route(): void

public function testRegisteringRouteWithMiddlewareThatIsInRouteGroupWithMiddlewareCreatesRouteWithBothMiddleware(): void
{
/** @psalm-suppress ArgumentTypeCoercion https://github.com/vimeo/psalm/issues/4871 */
$controller = new #[Middleware(DummyMiddleware::class, ['foo' => 'bar'])] class() extends Controller
{
#[
Expand Down Expand Up @@ -142,7 +139,6 @@ public function route(): void
public function testRegisteringRouteWithMultipleMiddlewareCreatesRouteWithThoseMiddleware(): void
{
$controller = new class() extends Controller {
/** @psalm-suppress ArgumentTypeCoercion https://github.com/vimeo/psalm/issues/4871 */
#[
Get('bar'),
Middleware(DummyMiddleware::class, ['foo' => 'bar']),
Expand Down Expand Up @@ -293,7 +289,6 @@ public function routeWithParameters(): void

public function testRegisteringRoutesWithRouteConstraintsAppliesConstraintsToChildRoutes(): void
{
/** @psalm-suppress ArgumentTypeCoercion https://github.com/vimeo/psalm/issues/4871 */
$controller = new #[RouteConstraint(DummyConstraint::class, ['foo'])] class() extends Controller
{
#[Get('')]
Expand Down

0 comments on commit 990cf0d

Please sign in to comment.