Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@
"phpstan/phpstan-phpunit": "^2.0.8",
"phpstan/phpstan-strict-rules": "^2.0",
"phpunit/phpunit": "^9.6",
"psr/container": "1.1.2",
"symfony/config": "^5.4 || ^6.1",
"symfony/console": "^5.4 || ^6.1",
"symfony/dependency-injection": "^5.4 || ^6.1",
"symfony/form": "^5.4 || ^6.1",
"symfony/framework-bundle": "^5.4 || ^6.1",
"symfony/http-foundation": "^5.4 || ^6.1",
"symfony/messenger": "^5.4",
"psr/container": "^1.1.2 || ^2.0",
"symfony/config": "^5.4 || ^6.1 || ^7.0 || ^8.0",
"symfony/console": "^5.4 || ^6.1 || ^7.0 || ^8.0",
"symfony/dependency-injection": "^5.4 || ^6.1 || ^7.0 || ^8.0",
"symfony/form": "^5.4 || ^6.1 || ^7.0 || ^8.0",
"symfony/framework-bundle": "^5.4 || ^6.1 || ^7.0 || ^8.0",
"symfony/http-foundation": "^5.4 || ^6.1 || ^7.0 || ^8.0",
"symfony/messenger": "^5.4 || ^6.1 || ^7.0 || ^8.0",
"symfony/polyfill-php80": "^1.24",
"symfony/serializer": "^5.4",
"symfony/service-contracts": "^2.2.0"
"symfony/serializer": "^5.4 || ^6.1 || ^7.0 || ^8.0",
"symfony/service-contracts": "^2.2.0 || ^3.0"
},
"config": {
"sort-packages": true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@

public function testGetPrivateServiceInAbstractController(): void
{
if (!class_exists('Symfony\Bundle\FrameworkBundle\Controller\Controller')) {
if (!class_exists('Symfony\Bundle\FrameworkBundle\Controller\AbstractController')) {
self::markTestSkipped();
}
if (!method_exists('Symfony\Bundle\FrameworkBundle\Controller\AbstractController', 'get')) {

Check failure on line 40 in tests/Rules/Symfony/ContainerInterfacePrivateServiceRuleFakeTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2, lowest)

Call to function method_exists() with 'Symfony\\Bundle…' and 'get' will always evaluate to true.

Check failure on line 40 in tests/Rules/Symfony/ContainerInterfacePrivateServiceRuleFakeTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, lowest)

Call to function method_exists() with 'Symfony\\Bundle…' and 'get' will always evaluate to true.

Check failure on line 40 in tests/Rules/Symfony/ContainerInterfacePrivateServiceRuleFakeTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, highest)

Call to function method_exists() with 'Symfony\\Bundle…' and 'get' will always evaluate to true.

Check failure on line 40 in tests/Rules/Symfony/ContainerInterfacePrivateServiceRuleFakeTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.4, lowest)

Call to function method_exists() with 'Symfony\\Bundle…' and 'get' will always evaluate to true.

Check failure on line 40 in tests/Rules/Symfony/ContainerInterfacePrivateServiceRuleFakeTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, highest)

Call to function method_exists() with 'Symfony\\Bundle…' and 'get' will always evaluate to true.

Check failure on line 40 in tests/Rules/Symfony/ContainerInterfacePrivateServiceRuleFakeTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, lowest)

Call to function method_exists() with 'Symfony\\Bundle…' and 'get' will always evaluate to true.

Check failure on line 40 in tests/Rules/Symfony/ContainerInterfacePrivateServiceRuleFakeTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.5, lowest)

Call to function method_exists() with 'Symfony\\Bundle…' and 'get' will always evaluate to true.

Check failure on line 40 in tests/Rules/Symfony/ContainerInterfacePrivateServiceRuleFakeTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, lowest)

Call to function method_exists() with 'Symfony\\Bundle…' and 'get' will always evaluate to true.

Check failure on line 40 in tests/Rules/Symfony/ContainerInterfacePrivateServiceRuleFakeTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.3, lowest)

Call to function method_exists() with 'Symfony\\Bundle…' and 'get' will always evaluate to true.
self::markTestSkipped();
}
$this->analyse(
Expand Down
2 changes: 1 addition & 1 deletion tests/Rules/Symfony/console_application_loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
require_once __DIR__ . '/../../../vendor/autoload.php';

$application = new Application();
$application->add(new ExampleCommand());
$application->addCommands([new ExampleCommand()]);
return $application;
4 changes: 4 additions & 0 deletions tests/Type/Symfony/ExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@

if (class_exists('Symfony\Bundle\FrameworkBundle\Controller\AbstractController')) {
yield from $this->gatherAssertTypes(__DIR__ . '/data/ExampleAbstractController.php');

if (method_exists('Symfony\Bundle\FrameworkBundle\Controller\AbstractController', 'get')) {

Check failure on line 56 in tests/Type/Symfony/ExtensionTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2, lowest)

Call to function method_exists() with 'Symfony\\Bundle…' and 'get' will always evaluate to true.

Check failure on line 56 in tests/Type/Symfony/ExtensionTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, lowest)

Call to function method_exists() with 'Symfony\\Bundle…' and 'get' will always evaluate to true.

Check failure on line 56 in tests/Type/Symfony/ExtensionTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, highest)

Call to function method_exists() with 'Symfony\\Bundle…' and 'get' will always evaluate to true.

Check failure on line 56 in tests/Type/Symfony/ExtensionTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.4, lowest)

Call to function method_exists() with 'Symfony\\Bundle…' and 'get' will always evaluate to true.

Check failure on line 56 in tests/Type/Symfony/ExtensionTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, highest)

Call to function method_exists() with 'Symfony\\Bundle…' and 'get' will always evaluate to true.

Check failure on line 56 in tests/Type/Symfony/ExtensionTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, lowest)

Call to function method_exists() with 'Symfony\\Bundle…' and 'get' will always evaluate to true.

Check failure on line 56 in tests/Type/Symfony/ExtensionTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.5, lowest)

Call to function method_exists() with 'Symfony\\Bundle…' and 'get' will always evaluate to true.

Check failure on line 56 in tests/Type/Symfony/ExtensionTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, lowest)

Call to function method_exists() with 'Symfony\\Bundle…' and 'get' will always evaluate to true.

Check failure on line 56 in tests/Type/Symfony/ExtensionTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.3, lowest)

Call to function method_exists() with 'Symfony\\Bundle…' and 'get' will always evaluate to true.
yield from $this->gatherAssertTypes(__DIR__ . '/data/ExampleAbstractControllerServices.php');
}
}

yield from $this->gatherAssertTypes(__DIR__ . '/data/serializer.php');
Expand Down
4 changes: 4 additions & 0 deletions tests/Type/Symfony/ExtensionWithoutContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
}

yield from $this->gatherAssertTypes(__DIR__ . '/data/ExampleAbstractControllerWithoutContainer.php');

if (method_exists('Symfony\Bundle\FrameworkBundle\Controller\AbstractController', 'get')) {

Check failure on line 28 in tests/Type/Symfony/ExtensionWithoutContainerTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.2, lowest)

Call to function method_exists() with 'Symfony\\Bundle…' and 'get' will always evaluate to true.

Check failure on line 28 in tests/Type/Symfony/ExtensionWithoutContainerTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, lowest)

Call to function method_exists() with 'Symfony\\Bundle…' and 'get' will always evaluate to true.

Check failure on line 28 in tests/Type/Symfony/ExtensionWithoutContainerTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, highest)

Call to function method_exists() with 'Symfony\\Bundle…' and 'get' will always evaluate to true.

Check failure on line 28 in tests/Type/Symfony/ExtensionWithoutContainerTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.4, lowest)

Call to function method_exists() with 'Symfony\\Bundle…' and 'get' will always evaluate to true.

Check failure on line 28 in tests/Type/Symfony/ExtensionWithoutContainerTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (7.4, highest)

Call to function method_exists() with 'Symfony\\Bundle…' and 'get' will always evaluate to true.

Check failure on line 28 in tests/Type/Symfony/ExtensionWithoutContainerTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.1, lowest)

Call to function method_exists() with 'Symfony\\Bundle…' and 'get' will always evaluate to true.

Check failure on line 28 in tests/Type/Symfony/ExtensionWithoutContainerTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.5, lowest)

Call to function method_exists() with 'Symfony\\Bundle…' and 'get' will always evaluate to true.

Check failure on line 28 in tests/Type/Symfony/ExtensionWithoutContainerTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.0, lowest)

Call to function method_exists() with 'Symfony\\Bundle…' and 'get' will always evaluate to true.

Check failure on line 28 in tests/Type/Symfony/ExtensionWithoutContainerTest.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.3, lowest)

Call to function method_exists() with 'Symfony\\Bundle…' and 'get' will always evaluate to true.
yield from $this->gatherAssertTypes(__DIR__ . '/data/ExampleAbstractControllerServicesWithoutContainer.php');
}
}

/**
Expand Down
8 changes: 3 additions & 5 deletions tests/Type/Symfony/console_application_loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@
require_once __DIR__ . '/../../../vendor/autoload.php';

$application = new Application();
$application->add(new ExampleACommand());
$application->add(new ExampleBCommand());
$application->add(new ExampleOptionCommand());
$application->addCommands([new ExampleACommand(), new ExampleBCommand(), new ExampleOptionCommand()]);

if (class_exists(LazyCommand::class)) {
$application->add(new LazyCommand('lazy-example-option', [], '', false, static fn () => new ExampleOptionLazyCommand()));
$application->addCommands([new LazyCommand('lazy-example-option', [], '', false, static fn () => new ExampleOptionLazyCommand())]);
} else {
$application->add(new ExampleOptionLazyCommand());
$application->addCommands([new ExampleOptionLazyCommand()]);
}

return $application;
17 changes: 0 additions & 17 deletions tests/Type/Symfony/data/ExampleAbstractController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,6 @@
final class ExampleAbstractController extends AbstractController
{

public function services(): void
{
assertType('Foo', $this->get('foo'));
assertType('Foo', $this->get('parameterised_foo'));
assertType('Foo\Bar', $this->get('parameterised_bar'));
assertType('Synthetic', $this->get('synthetic'));
assertType('object', $this->get('bar'));
assertType('object', $this->get(doFoo()));
assertType('object', $this->get());

assertType('true', $this->has('foo'));
assertType('true', $this->has('synthetic'));
assertType('false', $this->has('bar'));
assertType('bool', $this->has(doFoo()));
assertType('bool', $this->has());
}

public function parameters(ContainerInterface $container, ParameterBagInterface $parameterBag): void
{
assertType('array|bool|float|int|string|null', $container->getParameter('unknown'));
Expand Down
30 changes: 30 additions & 0 deletions tests/Type/Symfony/data/ExampleAbstractControllerServices.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php declare(strict_types = 1);

namespace PHPStan\Type\Symfony;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use function PHPStan\Testing\assertType;

final class ExampleAbstractControllerServices extends AbstractController
{

public function services(): void
{
assertType('Foo', $this->get('foo'));
assertType('Foo', $this->get('parameterised_foo'));
assertType('Foo\Bar', $this->get('parameterised_bar'));
assertType('Synthetic', $this->get('synthetic'));
assertType('object', $this->get('bar'));
assertType('object', $this->get(doFoo()));
assertType('object', $this->get());

assertType('true', $this->has('foo'));
assertType('true', $this->has('synthetic'));
assertType('false', $this->has('bar'));
assertType('bool', $this->has(doFoo()));
assertType('bool', $this->has());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php declare(strict_types = 1);

namespace PHPStan\Type\Symfony;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use function PHPStan\Testing\assertType;

final class ExampleAbstractControllerServicesWithoutContainer extends AbstractController
{

public function services(): void
{
assertType('object', $this->get('foo'));
assertType('object', $this->get('synthetic'));
assertType('object', $this->get('bar'));
assertType('object', $this->get(doFoo()));
assertType('object', $this->get());

assertType('bool', $this->has('foo'));
assertType('bool', $this->has('synthetic'));
assertType('bool', $this->has('bar'));
assertType('bool', $this->has(doFoo()));
assertType('bool', $this->has());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,6 @@
final class ExampleAbstractControllerWithoutContainer extends AbstractController
{

public function services(): void
{
assertType('object', $this->get('foo'));
assertType('object', $this->get('synthetic'));
assertType('object', $this->get('bar'));
assertType('object', $this->get(doFoo()));
assertType('object', $this->get());

assertType('bool', $this->has('foo'));
assertType('bool', $this->has('synthetic'));
assertType('bool', $this->has('bar'));
assertType('bool', $this->has(doFoo()));
assertType('bool', $this->has());
}

public function parameters(ContainerInterface $container, ParameterBagInterface $parameterBag): void
{
assertType('array|bool|float|int|string|null', $container->getParameter('unknown'));
Expand Down
Loading