1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* The MIT License (MIT) |
7
|
|
|
* |
8
|
|
|
* Copyright (c) 2014-2018 Spomky-Labs |
9
|
|
|
* |
10
|
|
|
* This software may be modified and distributed under the terms |
11
|
|
|
* of the MIT license. See the LICENSE file for details. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace OAuth2Framework\Bundle\Tests; |
15
|
|
|
|
16
|
|
|
/* |
17
|
|
|
* The MIT License (MIT) |
18
|
|
|
* |
19
|
|
|
* Copyright (c) 2014-2017 Spomky-Labs |
20
|
|
|
* |
21
|
|
|
* This software may be modified and distributed under the terms |
22
|
|
|
* of the MIT license. See the LICENSE file for details. |
23
|
|
|
*/ |
24
|
|
|
|
25
|
|
|
use Http\HttplugBundle\HttplugBundle; |
26
|
|
|
use OAuth2Framework\Bundle\OAuth2FrameworkBundle; |
27
|
|
|
use OAuth2Framework\Bundle\Tests\TestBundle\TestBundle; |
28
|
|
|
use Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle; |
29
|
|
|
use SimpleBus\SymfonyBridge\SimpleBusCommandBusBundle; |
30
|
|
|
use SimpleBus\SymfonyBridge\SimpleBusEventBusBundle; |
31
|
|
|
use Symfony\Bundle\SecurityBundle\SecurityBundle; |
32
|
|
|
use Symfony\Bundle\TwigBundle\TwigBundle; |
33
|
|
|
use Symfony\Component\Config\Loader\LoaderInterface; |
34
|
|
|
use Symfony\Component\HttpKernel\Kernel; |
35
|
|
|
use Symfony\Bundle\FrameworkBundle\FrameworkBundle; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Class AppKernel. |
39
|
|
|
*/ |
40
|
|
|
final class AppKernel extends Kernel |
41
|
|
|
{ |
42
|
|
|
/** |
43
|
|
|
* {@inheritdoc} |
44
|
|
|
*/ |
45
|
|
|
public function __construct(string $environment, bool $debug) |
46
|
|
|
{ |
47
|
|
|
parent::__construct($environment, false); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* {@inheritdoc} |
52
|
|
|
*/ |
53
|
|
|
public function registerBundles() |
54
|
|
|
{ |
55
|
|
|
$bundles = [ |
56
|
|
|
new FrameworkBundle(), |
57
|
|
|
new SecurityBundle(), |
58
|
|
|
new TwigBundle(), |
59
|
|
|
new SensioFrameworkExtraBundle(), |
60
|
|
|
new HttplugBundle(), |
61
|
|
|
|
62
|
|
|
new OAuth2FrameworkBundle(), |
63
|
|
|
new TestBundle(), |
64
|
|
|
|
65
|
|
|
new SimpleBusEventBusBundle(), |
66
|
|
|
new SimpleBusCommandBusBundle(), |
67
|
|
|
]; |
68
|
|
|
|
69
|
|
|
return $bundles; |
|
|
|
|
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* {@inheritdoc} |
74
|
|
|
*/ |
75
|
|
|
public function getCacheDir() |
76
|
|
|
{ |
77
|
|
|
return sys_get_temp_dir().'/OAuth2FrameworkBundle/Test'; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* {@inheritdoc} |
82
|
|
|
*/ |
83
|
|
|
public function getLogDir() |
84
|
|
|
{ |
85
|
|
|
return sys_get_temp_dir().'/OAuth2FrameworkBundle/log'; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* {@inheritdoc} |
90
|
|
|
*/ |
91
|
|
|
public function registerContainerConfiguration(LoaderInterface $loader) |
92
|
|
|
{ |
93
|
|
|
$loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml'); |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|
If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.
Let’s take a look at an example:
Our function
my_function
expects aPost
object, and outputs the author of the post. The base classPost
returns a simple string and outputting a simple string will work just fine. However, the child classBlogPost
which is a sub-type ofPost
instead decided to return anobject
, and is therefore violating the SOLID principles. If aBlogPost
were passed tomy_function
, PHP would not complain, but ultimately fail when executing thestrtoupper
call in its body.