File tree Expand file tree Collapse file tree 2 files changed +46
-7
lines changed Expand file tree Collapse file tree 2 files changed +46
-7
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types = 1 );
4
+
5
+ namespace Lookyman \PHPStan \Symfony \Rules ;
6
+
7
+ use Lookyman \PHPStan \Symfony \ServiceMap ;
8
+ use PHPStan \Rules \Rule ;
9
+
10
+ final class ContainerInterfaceUnknownServiceRuleTest extends \PHPStan \Testing \RuleTestCase
11
+ {
12
+
13
+ protected function getRule (): Rule
14
+ {
15
+ $ serviceMap = new ServiceMap (__DIR__ . '/../container.xml ' );
16
+
17
+ return new ContainerInterfaceUnknownServiceRule ($ serviceMap );
18
+ }
19
+
20
+ public function testGetUnknownService ()
21
+ {
22
+ $ this ->analyse ([__DIR__ . '/data/ExampleController.php ' ], [
23
+ [
24
+ 'Service "service.not.found" is not registered in the container. ' ,
25
+ 20 ,
26
+ ],
27
+ ]);
28
+ }
29
+
30
+ }
Original file line number Diff line number Diff line change 1
- <?php declare (strict_types = 1 );
1
+ <?php
2
+
3
+ declare (strict_types = 1 );
2
4
3
5
namespace Lookyman \PHPStan \Symfony \Rules \data ;
4
6
5
7
use Symfony \Bundle \FrameworkBundle \Controller \Controller ;
6
8
7
9
include __DIR__ . '/Controller.php ' ;
8
10
9
- class ExampleController extends Controller
11
+ final class ExampleController extends Controller
10
12
{
11
13
12
- public function getPrivateServiceAction ()
13
- {
14
- $ service = $ this ->get ('private ' );
15
- $ service ->noMethod ();
16
- }
14
+ public function getPrivateServiceAction ()
15
+ {
16
+ $ service = $ this ->get ('private ' );
17
+ $ service ->noMethod ();
18
+ }
19
+
20
+ public function getUnknownService ()
21
+ {
22
+ $ service = $ this ->get ('service.not.found ' );
23
+ $ service ->noMethod ();
24
+ }
25
+
17
26
}
You can’t perform that action at this time.
0 commit comments