This repository has been archived by the owner on Jun 26, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
103 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Lookyman\PHPStan\Symfony\Rules; | ||
|
||
use Lookyman\PHPStan\Symfony\ServiceMap; | ||
use PHPStan\Rules\Rule; | ||
|
||
class ContainerInterfacePrivateServiceRuleTest extends \PHPStan\Testing\RuleTestCase | ||
{ | ||
|
||
protected function getRule(): Rule | ||
{ | ||
$serviceMap = new ServiceMap(__DIR__ . '/../container.xml'); | ||
|
||
return new ContainerInterfacePrivateServiceRule($serviceMap); | ||
} | ||
|
||
public function testGetPrivateService() | ||
{ | ||
$this->analyse([__DIR__ . '/data/ExampleController.php'], [ | ||
[ | ||
'Service "private" is private.', | ||
14, | ||
], | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Lookyman\PHPStan\Symfony\Rules; | ||
|
||
use Lookyman\PHPStan\Symfony\ServiceMap; | ||
use PHPStan\Rules\Rule; | ||
|
||
class ContainerInterfaceUnknownServiceRuleTest extends \PHPStan\Testing\RuleTestCase | ||
{ | ||
|
||
protected function getRule(): Rule | ||
{ | ||
$serviceMap = new ServiceMap(__DIR__ . '/../container.xml'); | ||
|
||
return new ContainerInterfaceUnknownServiceRule($serviceMap); | ||
} | ||
|
||
public function testGetUnknownService() | ||
{ | ||
$this->analyse([__DIR__ . '/data/ExampleController.php'], [ | ||
[ | ||
'Service "service.not.found" is not registered in the container.', | ||
20, | ||
], | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace Symfony\Bundle\FrameworkBundle\Controller; | ||
|
||
abstract class Controller | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Lookyman\PHPStan\Symfony\Rules\data; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
|
||
include __DIR__ . '/Controller.php'; | ||
|
||
class ExampleController extends Controller | ||
{ | ||
|
||
public function getPrivateServiceAction() | ||
{ | ||
$service = $this->get('private'); | ||
$service->noMethod(); | ||
} | ||
|
||
public function getUnknownService() | ||
{ | ||
$service = $this->get('service.not.found'); | ||
$service->noMethod(); | ||
} | ||
} |