Skip to content

Commit

Permalink
Apply changes to reach green psalm
Browse files Browse the repository at this point in the history
Signed-off-by: Aleksei Khudiakov <[email protected]>
  • Loading branch information
Xerkus committed Nov 28, 2023
1 parent 28b6700 commit a9a974a
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 4 deletions.
8 changes: 8 additions & 0 deletions .phpstorm.meta.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace PHPSTORM_META {
override(
\Psr\Container\ContainerInterface::get(0),
map(['@'])
);
}
17 changes: 17 additions & 0 deletions .psalm-stubs.meta.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Psr\Container {
interface ContainerInterface
{
/**
* @psalm-template T of object
* @psalm-param class-string<T>|string $id
* @return (
* $id is class-string<T>
* ? T
* : mixed
* )
*/
public function get(string $id): mixed;
}
}
4 changes: 3 additions & 1 deletion config/container.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
// Retrieve configuration
$appConfig = require __DIR__ . '/application.config.php';
if (file_exists(__DIR__ . '/development.config.php')) {
$appConfig = ArrayUtils::merge($appConfig, require __DIR__ . '/development.config.php');
/** @var array $devConfig */
$devConfig = require __DIR__ . '/development.config.php';
$appConfig = ArrayUtils::merge($appConfig, $devConfig);
}

return Application::init($appConfig)
Expand Down
23 changes: 23 additions & 0 deletions module/Application/test/ModuleTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace ApplicationTest;

use Application\Module;
use PHPUnit\Framework\TestCase;

/**
* @covers \Application\Module;
*/
class ModuleTest extends TestCase
{
public function testProvidesConfig(): void
{
$module = new Module();
$config = $module->getConfig();

self::assertArrayHasKey('router', $config);
self::assertArrayHasKey('controllers', $config);
}
}
4 changes: 4 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
</InternalMethod>
</issueHandlers>

<stubs>
<file name=".psalm-stubs.meta.php"/>
</stubs>

<plugins>
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
</plugins>
Expand Down
7 changes: 4 additions & 3 deletions public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

// Decline static file requests back to the PHP built-in webserver
if (php_sapi_name() === 'cli-server') {
$path = realpath(__DIR__ . parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
$path = realpath(__DIR__ . parse_url($_SERVER['REQUEST_URI'] ?? '', PHP_URL_PATH));
if (is_string($path) && __FILE__ !== $path && is_file($path)) {
return false;
}
Expand All @@ -32,5 +32,6 @@

$container = require __DIR__ . '/../config/container.php';
// Run the application!
$container->get('Application')
->run();
/** @var Application $app */
$app = $container->get('Application');
$app->run();

0 comments on commit a9a974a

Please sign in to comment.