Issues (20)

Branch: di

scripts/test-app-di.php (4 issues)

1
<?php
2
3
require __DIR__ . '/../src/bootstrap.php';
4
5
use Cecil\Application;
6
7
error_reporting(E_ALL);
8
ini_set('display_errors', '1');
9
10
try {
11
    echo "Test de l'application avec DI...\n";
12
    $app = new Application(true);
0 ignored issues
show
The call to Cecil\Application::__construct() has too many arguments starting with true. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

12
    $app = /** @scrutinizer ignore-call */ new Application(true);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
13
    echo "✓ Application créée\n";
14
15
    $container = $app->getContainer();
16
    if ($container) {
0 ignored issues
show
$container is of type Symfony\Component\Depend...tion\ContainerInterface, thus it always evaluated to true.
Loading history...
17
        echo "✓ Container disponible\n";
18
        echo "  Services: " . count($container->getServiceIds()) . "\n";
0 ignored issues
show
The method getServiceIds() does not exist on Symfony\Component\Depend...tion\ContainerInterface. It seems like you code against a sub-type of said class. However, the method does not exist in Symfony\Component\Depend...aggedContainerInterface. Are you sure you never get one of those? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

18
        echo "  Services: " . count($container->/** @scrutinizer ignore-call */ getServiceIds()) . "\n";
Loading history...
19
    } else {
20
        echo "✗ Container non disponible\n";
21
    }
22
23
    echo "\nTest des commandes:\n";
24
    $commands = $app->all();
25
    echo "✓ " . count($commands) . " commandes chargées\n";
26
27
    if (count($commands) < 10) {
28
        echo "\nERREUR: Trop peu de commandes chargées!\n";
29
        echo "Vérification du container:\n";
30
        if ($container) {
0 ignored issues
show
$container is of type Symfony\Component\Depend...tion\ContainerInterface, thus it always evaluated to true.
Loading history...
31
            $ids = $container->getServiceIds();
32
            echo "Services dans le container:\n";
33
            foreach ($ids as $id) {
34
                if (strpos($id, 'Cecil\Command') !== false) {
35
                    echo "  - $id\n";
36
                }
37
            }
38
        }
39
    }
40
41
    foreach ($commands as $name => $command) {
42
        echo "  - $name: " . get_class($command) . "\n";
43
    }
44
} catch (\Exception $e) {
45
    echo "✗ Erreur: " . $e->getMessage() . "\n";
46
    echo "  File: " . $e->getFile() . ":" . $e->getLine() . "\n";
47
    echo "  Trace:\n" . $e->getTraceAsString() . "\n";
48
    exit(1);
49
}
50
51
echo "\n✓ Tests réussis\n";
52