Skip to content

Commit 9e65151

Browse files
author
HugoFara
committed
chore(psalm): simplifying the psalm config, removing stubs at last.
1 parent 77294e7 commit 9e65151

File tree

8 files changed

+17
-136
lines changed

8 files changed

+17
-136
lines changed

.psalm/stubs.php

Lines changed: 0 additions & 66 deletions
This file was deleted.

psalm.xml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
xmlns="https://getpsalm.org/schema/config"
99
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
1010
>
11-
<stubs>
12-
<file name=".psalm/stubs.php" />
13-
</stubs>
1411
<projectFiles>
1512
<directory name="." />
1613
<ignoreFiles>
@@ -19,7 +16,6 @@
1916
<directory name="assets" />
2017
<directory name="docs" />
2118
<directory name="src/tools" />
22-
<directory name=".psalm" />
2319
<directory name="tests" />
2420
</ignoreFiles>
2521
</projectFiles>
@@ -91,13 +87,6 @@
9187
</errorLevel>
9288
</UnusedClass>
9389

94-
<!-- Legacy files may be missing during refactoring -->
95-
<MissingFile>
96-
<errorLevel type="suppress">
97-
<directory name="src/backend/Controllers" />
98-
</errorLevel>
99-
</MissingFile>
100-
10190
<!-- Views call global functions that may be dynamically loaded -->
10291
<UndefinedFunction>
10392
<errorLevel type="suppress">

src/backend/Application.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,6 @@ public function __construct(string $basePath)
8383
*/
8484
public function bootstrap(): void
8585
{
86-
// Define base path constant if not already defined
87-
if (!defined('LWT_BASE_PATH')) {
88-
define('LWT_BASE_PATH', $this->basePath);
89-
}
90-
9186
// Determine if we're in debug mode (development)
9287
$debug = $this->isDebugMode();
9388

@@ -250,8 +245,8 @@ public function run(): void
250245
return;
251246
}
252247

253-
// Initialize router with DI container
254-
$router = new Router($this->container);
248+
// Initialize router with base path and DI container
249+
$router = new Router($this->basePath, $this->container);
255250

256251
// Load route configuration
257252
require_once $this->basePath . '/src/backend/Router/routes.php';

src/backend/Controllers/TextController.php

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -538,30 +538,6 @@ public function display(array $params): void
538538
PageLayoutHelper::renderPageEnd();
539539
}
540540

541-
/**
542-
* Print text (replaces text_print.php)
543-
*
544-
* @param array $params Route parameters
545-
*
546-
* @return void
547-
*/
548-
public function printText(array $params): void
549-
{
550-
include __DIR__ . '/../Legacy/text_print.php';
551-
}
552-
553-
/**
554-
* Print plain text (replaces text_print_plain.php)
555-
*
556-
* @param array $params Route parameters
557-
*
558-
* @return void
559-
*/
560-
public function printPlain(array $params): void
561-
{
562-
include __DIR__ . '/../Legacy/text_print_plain.php';
563-
}
564-
565541
/**
566542
* Import long text (replaces text_import_long.php)
567543
*

src/backend/Router/Router.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,22 @@ class Router
5858
*/
5959
private ?Container $container;
6060

61+
/**
62+
* Base path for resolving file paths.
63+
*
64+
* @var string
65+
*/
66+
private string $basePath;
67+
6168
/**
6269
* Create a new Router instance.
6370
*
71+
* @param string $basePath Base path for resolving file paths
6472
* @param Container|null $container Optional DI container for resolving controllers
6573
*/
66-
public function __construct(?Container $container = null)
74+
public function __construct(string $basePath, ?Container $container = null)
6775
{
76+
$this->basePath = $basePath;
6877
$this->container = $container;
6978
}
7079

@@ -294,7 +303,7 @@ private function resolveStaticAsset(string $path): ?array
294303
foreach ($mappings as $oldPrefix => $newPrefix) {
295304
if (str_starts_with($path, $oldPrefix)) {
296305
$newPath = $newPrefix . substr($path, strlen($oldPrefix));
297-
$filePath = LWT_BASE_PATH . $newPath;
306+
$filePath = $this->basePath . $newPath;
298307

299308
if (file_exists($filePath) && is_file($filePath)) {
300309
return [
@@ -312,7 +321,7 @@ private function resolveStaticAsset(string $path): ?array
312321
$directPaths = ['/assets/', '/docs/', '/media/'];
313322
foreach ($directPaths as $prefix) {
314323
if (str_starts_with($path, $prefix)) {
315-
$filePath = LWT_BASE_PATH . $path;
324+
$filePath = $this->basePath . $path;
316325
if (file_exists($filePath) && is_file($filePath)) {
317326
return [
318327
'type' => 'static',
@@ -328,7 +337,7 @@ private function resolveStaticAsset(string $path): ?array
328337
// Special files at root level
329338
$rootFiles = ['/favicon.ico', '/UNLICENSE.md'];
330339
if (in_array($path, $rootFiles)) {
331-
$filePath = LWT_BASE_PATH . $path;
340+
$filePath = $this->basePath . $path;
332341
if (file_exists($filePath)) {
333342
return [
334343
'type' => 'static',

tests/backend/Controllers/TextControllerEditTest.php

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -179,28 +179,6 @@ public function testControllerHasDisplayMethod(): void
179179
$this->assertTrue(method_exists($controller, 'display'));
180180
}
181181

182-
public function testControllerHasPrintTextMethod(): void
183-
{
184-
if (!self::$dbConnected) {
185-
$this->markTestSkipped('Database connection required');
186-
}
187-
188-
$controller = new TextController(new \Lwt\Services\TextService(), new \Lwt\Services\LanguageService());
189-
190-
$this->assertTrue(method_exists($controller, 'printText'));
191-
}
192-
193-
public function testControllerHasPrintPlainMethod(): void
194-
{
195-
if (!self::$dbConnected) {
196-
$this->markTestSkipped('Database connection required');
197-
}
198-
199-
$controller = new TextController(new \Lwt\Services\TextService(), new \Lwt\Services\LanguageService());
200-
201-
$this->assertTrue(method_exists($controller, 'printPlain'));
202-
}
203-
204182
public function testControllerHasImportLongMethod(): void
205183
{
206184
if (!self::$dbConnected) {

tests/backend/Router/RouterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class RouterTest extends TestCase
2121
protected function setUp(): void
2222
{
2323
parent::setUp();
24-
$this->router = new Router();
24+
$this->router = new Router(dirname(__DIR__, 3));
2525

2626
// Save original superglobals
2727
$this->originalServer = $_SERVER;

tests/backend/Router/RoutesTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ protected function setUp(): void
2626
{
2727
parent::setUp();
2828

29-
$this->router = new Router();
3029
$this->basePath = dirname(__DIR__, 3); // Go up to project root
30+
$this->router = new Router($this->basePath);
3131

3232
// Load routes
3333
require_once $this->basePath . '/src/backend/Router/routes.php';

0 commit comments

Comments
 (0)