Merge pull request #37 from pamil/phpstan
Install PHPStan and require it passing on the max level
This commit is contained in:
@@ -25,4 +25,6 @@ install:
|
|||||||
script:
|
script:
|
||||||
- composer validate --strict
|
- composer validate --strict
|
||||||
|
|
||||||
|
- vendor/bin/phpstan analyse -c phpstan.neon -l max src -vvv
|
||||||
|
|
||||||
- vendor/bin/behat --strict -vvv --no-interaction
|
- vendor/bin/behat --strict -vvv --no-interaction
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
"behat/mink-extension": "^2.2",
|
"behat/mink-extension": "^2.2",
|
||||||
"friends-of-behat/cross-container-extension": "^1.0",
|
"friends-of-behat/cross-container-extension": "^1.0",
|
||||||
"friends-of-behat/test-context": "^1.0",
|
"friends-of-behat/test-context": "^1.0",
|
||||||
|
"phpstan/phpstan-shim": "^0.10",
|
||||||
"sylius-labs/coding-standard": "^2.0",
|
"sylius-labs/coding-standard": "^2.0",
|
||||||
"symfony/framework-bundle": "^3.4|^4.0"
|
"symfony/framework-bundle": "^3.4|^4.0"
|
||||||
},
|
},
|
||||||
|
|||||||
5
phpstan.neon
Normal file
5
phpstan.neon
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
parameters:
|
||||||
|
reportUnmatchedIgnoredErrors: false
|
||||||
|
|
||||||
|
ignoreErrors:
|
||||||
|
- '/Cannot call method [a-zA-Z0-9]+\(\) on Symfony\\Component\\Config\\Definition\\Builder\\NodeParentInterface|null\./'
|
||||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||||||
namespace FriendsOfBehat\SymfonyExtension\Driver;
|
namespace FriendsOfBehat\SymfonyExtension\Driver;
|
||||||
|
|
||||||
use Behat\Mink\Driver\BrowserKitDriver;
|
use Behat\Mink\Driver\BrowserKitDriver;
|
||||||
|
use Symfony\Component\BrowserKit\Client;
|
||||||
use Symfony\Component\HttpKernel\KernelInterface;
|
use Symfony\Component\HttpKernel\KernelInterface;
|
||||||
|
|
||||||
final class SymfonyDriver extends BrowserKitDriver
|
final class SymfonyDriver extends BrowserKitDriver
|
||||||
@@ -15,6 +16,16 @@ final class SymfonyDriver extends BrowserKitDriver
|
|||||||
*/
|
*/
|
||||||
public function __construct(KernelInterface $kernel, string $baseUrl)
|
public function __construct(KernelInterface $kernel, string $baseUrl)
|
||||||
{
|
{
|
||||||
parent::__construct($kernel->getContainer()->get('test.client'), $baseUrl);
|
$testClient = $kernel->getContainer()->get('test.client');
|
||||||
|
|
||||||
|
if (!$testClient instanceof Client) {
|
||||||
|
throw new \RuntimeException(sprintf(
|
||||||
|
'Expected service "test.client" to be an instance of "%s", got "%s" instead.',
|
||||||
|
Client::class,
|
||||||
|
\is_object($testClient) ? \get_class($testClient) : \gettype($testClient)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
parent::__construct($testClient, $baseUrl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|||||||
use Symfony\Component\DependencyInjection\Definition;
|
use Symfony\Component\DependencyInjection\Definition;
|
||||||
use Symfony\Component\DependencyInjection\Reference;
|
use Symfony\Component\DependencyInjection\Reference;
|
||||||
use Symfony\Component\Dotenv\Dotenv;
|
use Symfony\Component\Dotenv\Dotenv;
|
||||||
|
use Symfony\Component\HttpKernel\KernelInterface;
|
||||||
|
|
||||||
final class SymfonyExtension implements Extension
|
final class SymfonyExtension implements Extension
|
||||||
{
|
{
|
||||||
@@ -162,9 +163,13 @@ final class SymfonyExtension implements Extension
|
|||||||
$config['debug'],
|
$config['debug'],
|
||||||
]);
|
]);
|
||||||
$definition->addMethodCall('boot');
|
$definition->addMethodCall('boot');
|
||||||
$definition->setFile($this->getKernelFile($container->getParameter('paths.base'), $config['path']));
|
|
||||||
$definition->setPublic(true);
|
$definition->setPublic(true);
|
||||||
|
|
||||||
|
$file = $this->getKernelFile($container->getParameter('paths.base'), $config['path']);
|
||||||
|
if (null !== $file) {
|
||||||
|
$definition->setFile($file);
|
||||||
|
}
|
||||||
|
|
||||||
$container->setDefinition(self::KERNEL_ID, $definition);
|
$container->setDefinition(self::KERNEL_ID, $definition);
|
||||||
|
|
||||||
$this->requireKernelBootstrapFile($container->getParameter('paths.base'), $config['bootstrap']);
|
$this->requireKernelBootstrapFile($container->getParameter('paths.base'), $config['bootstrap']);
|
||||||
@@ -221,7 +226,7 @@ final class SymfonyExtension implements Extension
|
|||||||
*/
|
*/
|
||||||
private function loadKernelRebooter(ContainerBuilder $container): void
|
private function loadKernelRebooter(ContainerBuilder $container): void
|
||||||
{
|
{
|
||||||
$definition = new Definition(KernelRebooter::class, [$container->get(self::KERNEL_ID)]);
|
$definition = new Definition(KernelRebooter::class, [new Reference(self::KERNEL_ID)]);
|
||||||
$definition->addTag(EventDispatcherExtension::SUBSCRIBER_TAG);
|
$definition->addTag(EventDispatcherExtension::SUBSCRIBER_TAG);
|
||||||
|
|
||||||
$container->setDefinition(self::KERNEL_ID . '.rebooter', $definition);
|
$container->setDefinition(self::KERNEL_ID . '.rebooter', $definition);
|
||||||
@@ -234,21 +239,29 @@ final class SymfonyExtension implements Extension
|
|||||||
*/
|
*/
|
||||||
private function declareSymfonyContainers(ContainerBuilder $container): void
|
private function declareSymfonyContainers(ContainerBuilder $container): void
|
||||||
{
|
{
|
||||||
if (null !== $this->crossContainerProcessor) {
|
if (null === $this->crossContainerProcessor) {
|
||||||
$this->crossContainerProcessor->addContainerAccessor(
|
return;
|
||||||
'symfony',
|
}
|
||||||
new KernelBasedContainerAccessor($container->get(self::KERNEL_ID))
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->crossContainerProcessor->addContainerAccessor(
|
$containerAccessors = [
|
||||||
'symfony_driver',
|
'symfony' => self::KERNEL_ID,
|
||||||
new KernelBasedContainerAccessor($container->get(self::DRIVER_KERNEL_ID))
|
'symfony_driver' => self::DRIVER_KERNEL_ID,
|
||||||
);
|
'symfony_shared' => self::SHARED_KERNEL_ID,
|
||||||
|
];
|
||||||
|
|
||||||
$this->crossContainerProcessor->addContainerAccessor(
|
foreach ($containerAccessors as $containerName => $kernelIdentifier) {
|
||||||
'symfony_shared',
|
$kernel = $container->get($kernelIdentifier);
|
||||||
new KernelBasedContainerAccessor($container->get(self::SHARED_KERNEL_ID))
|
|
||||||
);
|
if (!$kernel instanceof KernelInterface) {
|
||||||
|
throw new \RuntimeException(sprintf(
|
||||||
|
'Expected service "%s" to be an instance of "%s", got "%s" instead.',
|
||||||
|
$kernelIdentifier,
|
||||||
|
KernelInterface::class,
|
||||||
|
\is_object($kernel) ? \get_class($kernel) : \gettype($kernel)
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->crossContainerProcessor->addContainerAccessor($containerName, new KernelBasedContainerAccessor($kernel));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -269,7 +282,7 @@ final class SymfonyExtension implements Extension
|
|||||||
*/
|
*/
|
||||||
private function registerSymfonyDriverFactory(ExtensionManager $extensionManager): void
|
private function registerSymfonyDriverFactory(ExtensionManager $extensionManager): void
|
||||||
{
|
{
|
||||||
/** @var MinkExtension $minkExtension */
|
/** @var MinkExtension|null $minkExtension */
|
||||||
$minkExtension = $extensionManager->getExtension('mink');
|
$minkExtension = $extensionManager->getExtension('mink');
|
||||||
if (null === $minkExtension) {
|
if (null === $minkExtension) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user