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
7 changed files
with
126 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
includes: | ||
- vendor/phpstan/phpstan-phpunit/extension.neon | ||
- vendor/phpstan/phpstan-phpunit/rules.neon | ||
|
||
parameters: | ||
excludes_analyse: | ||
- %rootDir%/../../../tests/*/data/* |
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,35 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace Lookyman\PHPStan\Symfony\Rules; | ||
|
||
use Lookyman\PHPStan\Symfony\ServiceMap; | ||
use PHPStan\Rules\Rule; | ||
|
||
final class ContainerInterfacePrivateServiceRuleTest extends \PHPStan\Testing\RuleTestCase | ||
{ | ||
|
||
protected function setUp() | ||
{ | ||
include_once __DIR__ . '/data/Controller.php'; | ||
} | ||
|
||
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,35 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace Lookyman\PHPStan\Symfony\Rules; | ||
|
||
use Lookyman\PHPStan\Symfony\ServiceMap; | ||
use PHPStan\Rules\Rule; | ||
|
||
final class ContainerInterfaceUnknownServiceRuleTest extends \PHPStan\Testing\RuleTestCase | ||
{ | ||
|
||
protected function setUp() | ||
{ | ||
include_once __DIR__ . '/data/Controller.php'; | ||
} | ||
|
||
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,30 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace Lookyman\PHPStan\Symfony\Rules\data; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
|
||
final class ExampleController extends Controller | ||
{ | ||
|
||
public function getPrivateServiceAction() | ||
{ | ||
$service = $this->get('private'); | ||
$service->noMethod(); | ||
} | ||
|
||
public function getUnknownService() | ||
{ | ||
$service = $this->get('service.not.found'); | ||
$service->noMethod(); | ||
} | ||
|
||
public function getVariableService(string $serviceKey) | ||
{ | ||
$service = $this->get($serviceKey); | ||
$service->noMethod(); | ||
} | ||
|
||
} |