Issues (63)

Tests/TestKernel.php (2 issues)

1
<?php
2
3
use Bdf\Prime\Entity\Model;
4
use Bdf\Prime\Mapper\Mapper;
5
use Symfony\Component\Config\Loader\LoaderInterface;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\Routing\RouteCollectionBuilder;
8
9
class TestKernel extends \Symfony\Component\HttpKernel\Kernel
10
{
11
    use \Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
0 ignored issues
show
The trait Symfony\Bundle\Framework...Kernel\MicroKernelTrait requires the property $instanceof which is not provided by TestKernel.
Loading history...
12
13
    public function registerBundles(): iterable
14
    {
15
        return [
16
            new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
17
            new \Symfony\Bundle\WebProfilerBundle\WebProfilerBundle(),
18
            new \Symfony\Bundle\TwigBundle\TwigBundle(),
19
            // new \Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
20
            new \Bdf\PrimeBundle\PrimeBundle(),
21
        ];
22
    }
23
24
    protected function configureRoutes($routes)
25
    {
26
        // $routes->add('index', '/')->controller([$this, 'indexAction']);
27
        if ($routes instanceof RouteCollectionBuilder) {
28
            $routes->add('/', 'kernel::indexAction');
29
            $routes->import('@WebProfilerBundle/Resources/config/routing/wdt.xml', '/_wdt');
30
            $routes->import('@WebProfilerBundle/Resources/config/routing/profiler.xml', '/_profiler');
31
        } else {
32
            $routes->add('index', '/')->controller([$this, 'indexAction']);
33
            $routes->import('@WebProfilerBundle/Resources/config/routing/wdt.xml');
34
            $routes->import('@WebProfilerBundle/Resources/config/routing/profiler.xml');
35
        }
36
    }
37
38
    protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader)
0 ignored issues
show
The parameter $c is not used and could be removed. ( Ignorable by Annotation )

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

38
    protected function configureContainer(/** @scrutinizer ignore-unused */ ContainerBuilder $c, LoaderInterface $loader)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
39
    {
40
        $loader->load(__DIR__.'/conf.yaml');
41
        // $c->import(__DIR__.'/conf.yaml');
42
    }
43
44
    public function indexAction()
45
    {
46
        TestEntity::repository()->schema()->migrate();
47
        TestEntity::findById(5);
48
49
        return new \Symfony\Component\HttpFoundation\Response(<<<HTML
50
<!DOCTYPE html>
51
<html>
52
    <body>Hello World !</body>
53
</html>
54
HTML
55
        );
56
    }
57
}
58
59
class TestEntity extends Model
60
{
61
    public $id;
62
    public $name;
63
    public $dateInsert;
64
    public $parentId;
65
    public $parent;
66
67
    public function __construct(array $attributes = [])
68
    {
69
        $this->import($attributes);
70
    }
71
}
72
73
class TestEntityMapper extends Mapper
74
{
75
    /**
76
     * {@inheritdoc}
77
     */
78
    public function schema(): array
79
    {
80
        return [
81
            'connection' => 'test',
82
            'database' => 'test',
83
            'table' => 'test_',
84
        ];
85
    }
86
87
    /**
88
     * {@inheritdoc}
89
     */
90
    public function buildFields($builder): void
91
    {
92
        $builder
93
            ->integer('id')->autoincrement()
94
            ->string('name')
95
            ->datetime('dateInsert')->alias('date_insert')->nillable()
96
        ;
97
    }
98
}
99