Skip to content

Commit

Permalink
Remove @param Something&MockObject annotations (see contao#1936)
Browse files Browse the repository at this point in the history
Description
-----------

Because they will no longer trigger `type MockObject is not within the annotated types` warnings in PhpStorm (see contao#1924 (comment)).

Commits
-------

2584d3d Remove @param Something&MockObject annotations
  • Loading branch information
leofeyer authored and Alexej Kossmann committed Apr 6, 2021
1 parent fcf2cc6 commit ca3af1d
Show file tree
Hide file tree
Showing 21 changed files with 2 additions and 85 deletions.
4 changes: 0 additions & 4 deletions core-bundle/tests/Cache/ContaoCacheWarmerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,6 @@ public function testDoesNotCreateTheCacheFolderIfTheInstallationIsIncomplete():
$this->assertFileNotExists(Path::join($this->getTempDir(), 'var/cache/contao'));
}

/**
* @param Connection&MockObject $connection
* @param ContaoFramework&MockObject $framework
*/
private function getCacheWarmer(Connection $connection = null, ContaoFramework $framework = null, string $bundle = 'test-bundle'): ContaoCacheWarmer
{
if (null === $connection) {
Expand Down
2 changes: 0 additions & 2 deletions core-bundle/tests/Command/MigrateCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use Contao\CoreBundle\Migration\MigrationResult;
use Contao\CoreBundle\Tests\TestCase;
use Contao\InstallationBundle\Database\Installer;
use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\Filesystem\Filesystem;
Expand Down Expand Up @@ -179,7 +178,6 @@ public function testDoesNotAbortIfMigrationFails(): void
* @param array<array<string>> $pendingMigrations
* @param array<array<MigrationResult>> $migrationResults
* @param array<array<string>> $runonceFiles
* @param Installer&MockObject $installer
*/
private function getCommand(array $pendingMigrations = [], array $migrationResults = [], array $runonceFiles = [], Installer $installer = null): MigrateCommand
{
Expand Down
6 changes: 0 additions & 6 deletions core-bundle/tests/Command/ResizeImagesCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use Contao\Image\DeferredImageStorageInterface;
use Contao\Image\DeferredResizerInterface;
use Contao\Image\ImageInterface;
use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Bridge\PhpUnit\ClockMock;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\Filesystem\Filesystem;
Expand Down Expand Up @@ -131,11 +130,6 @@ function () {
$this->assertNotRegExp('/image2.jpg/', $display);
}

/**
* @param ImageFactoryInterface&MockObject $factory
* @param DeferredResizerInterface&MockObject $resizer
* @param DeferredImageStorageInterface&MockObject $storage
*/
private function getCommand(ImageFactoryInterface $factory = null, DeferredResizerInterface $resizer = null, DeferredImageStorageInterface $storage = null): ResizeImagesCommand
{
return new ResizeImagesCommand(
Expand Down
3 changes: 0 additions & 3 deletions core-bundle/tests/Command/UserPasswordCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,6 @@ public function testResetsPasswordWithRequiredChangeOnNextLogin(): void
(new CommandTester($command))->execute($input, ['interactive' => false]);
}

/**
* @param Connection&MockObject $connection
*/
private function getCommand(Connection $connection = null, string $password = null): UserPasswordCommand
{
if (null === $connection) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
use Contao\CoreBundle\Fixtures\Exception\PageErrorResponseException;
use Contao\CoreBundle\Tests\TestCase;
use Lexik\Bundle\MaintenanceBundle\Exception\ServiceUnavailableException;
use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
Expand Down Expand Up @@ -308,9 +307,6 @@ public function testDoesNotLogUnloggableExceptions(): void
$this->assertSame(500, $event->getResponse()->getStatusCode());
}

/**
* @param Environment&MockObject $twig
*/
private function getListener(bool $isBackendUser = false, bool $expectLogging = false, Environment $twig = null): PrettyErrorScreenListener
{
if (null === $twig) {
Expand Down
7 changes: 0 additions & 7 deletions core-bundle/tests/EventListener/UserSessionListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,13 +335,6 @@ public function testFailsToStoreTheSessionIfThereIsNoSession(): void
$listener->write($this->getResponseEvent($request));
}

/**
* Mocks a session listener.
*
* @param Connection&MockObject $connection
* @param Security&MockObject $security
* @param EventDispatcherInterface&MockObject $eventDispatcher
*/
private function getListener(Connection $connection = null, Security $security = null, EventDispatcherInterface $eventDispatcher = null): UserSessionListener
{
if (null === $connection) {
Expand Down
3 changes: 0 additions & 3 deletions core-bundle/tests/Fragment/FragmentHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,6 @@ public function testConvertsExceptionsToResponseExceptions(): void
$fragmentHandler->render($uri);
}

/**
* @param BaseFragmentHandler&MockObject $fragmentHandler
*/
private function getFragmentHandler(FragmentRegistry $registry = null, ServiceLocator $renderers = null, ServiceLocator $preHandlers = null, Request $request = null, BaseFragmentHandler $fragmentHandler = null): FragmentHandler
{
if (null === $registry) {
Expand Down
3 changes: 0 additions & 3 deletions core-bundle/tests/Framework/ContaoFrameworkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -690,9 +690,6 @@ public function testDelegatesTheResetCalls(): void
$this->assertCount(0, $registry);
}

/**
* @param TokenChecker&MockObject $tokenChecker
*/
private function mockFramework(Request $request = null, ScopeMatcher $scopeMatcher = null, TokenChecker $tokenChecker = null): ContaoFramework
{
$requestStack = new RequestStack();
Expand Down
6 changes: 0 additions & 6 deletions core-bundle/tests/Image/ImageFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -839,12 +839,6 @@ public static function emptyHookCallback(): void
{
}

/**
* @param ResizerInterface&MockObject $resizer
* @param ImagineInterface&MockObject $imagine
* @param ImagineInterface&MockObject $imagineSvg
* @param ContaoFramework&MockObject $framework
*/
private function getImageFactory(ResizerInterface $resizer = null, ImagineInterface $imagine = null, ImagineInterface $imagineSvg = null, Filesystem $filesystem = null, ContaoFramework $framework = null, bool $bypassCache = null, array $imagineOptions = null, array $validExtensions = null, string $uploadDir = null): ImageFactory
{
if (null === $resizer) {
Expand Down
5 changes: 0 additions & 5 deletions core-bundle/tests/Image/PictureFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -722,11 +722,6 @@ public function getAspectRatios(): \Generator
yield [false, 20, 100, 22, 100];
}

/**
* @param PictureGeneratorInterface&MockObject $pictureGenerator
* @param ImageFactoryInterface&MockObject $imageFactory
* @param ContaoFramework&MockObject $framework
*/
private function getPictureFactory(PictureGeneratorInterface $pictureGenerator = null, ImageFactoryInterface $imageFactory = null, ContaoFramework $framework = null, bool $bypassCache = null, array $imagineOptions = null): PictureFactory
{
if (null === $pictureGenerator) {
Expand Down
5 changes: 0 additions & 5 deletions core-bundle/tests/Monolog/ContaoTableProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Contao\CoreBundle\Monolog\ContaoTableProcessor;
use Contao\CoreBundle\Tests\TestCase;
use Monolog\Logger;
use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
Expand Down Expand Up @@ -232,10 +231,6 @@ public function sourceProvider(): \Generator
yield [ContaoCoreBundle::SCOPE_BACKEND, null, 'BE'];
}

/**
* @param RequestStack&MockObject $requestStack
* @param TokenStorageInterface&MockObject $tokenStorage
*/
private function getContaoTableProcessor(RequestStack $requestStack = null, TokenStorageInterface $tokenStorage = null): ContaoTableProcessor
{
if (null === $requestStack) {
Expand Down
3 changes: 0 additions & 3 deletions core-bundle/tests/OptIn/OptInTokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,6 @@ public function testDoesNotRequireSubjectAndTextToResendToken(): void
$this->assertTrue($token->hasBeenSent());
}

/**
* @param ContaoFramework&MockObject $framework
*/
private function getToken(OptInModel $model, ContaoFramework $framework = null): OptInTokenInterface
{
if (null === $framework) {
Expand Down
3 changes: 0 additions & 3 deletions core-bundle/tests/Routing/Matcher/LanguageFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,13 @@
use Contao\CoreBundle\Routing\Matcher\LanguageFilter;
use Contao\CoreBundle\Tests\TestCase;
use Contao\PageModel;
use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;

class LanguageFilterTest extends TestCase
{
/**
* @param PageModel&MockObject $page
*
* @dataProvider getRoutesAndLanguages
*/
public function testRemovesARouteIfTheAcceptedLanguagesDoNotMatch(string $name, ?PageModel $page, string $acceptLanguage, bool $expectPageModel, bool $expectRemoval, bool $prependLocale = false): void
Expand Down
3 changes: 0 additions & 3 deletions core-bundle/tests/Routing/RouteProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -774,9 +774,6 @@ private function createRootPage(string $language, string $alias, bool $fallback
return $page;
}

/**
* @param ContaoFramework&MockObject $framework
*/
private function getRouteProvider(ContaoFramework $framework = null, string $urlSuffix = '.html', bool $prependLocale = false): RouteProvider
{
if (null === $framework) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,10 +453,6 @@ public function testRemovesTheTargetPathInTheSessionOnLogin(): void
$this->getHandler()->onAuthenticationSuccess($request, $token);
}

/**
* @param ContaoFramework&MockObject $framework
* @param LoggerInterface&MockObject $logger
*/
private function getHandler(ContaoFramework $framework = null, LoggerInterface $logger = null): AuthenticationSuccessHandler
{
if (null === $framework) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,6 @@ public function testDoesNotRemoveTheAuthenticationIfTheSessionDoesNotContainATok
$this->assertFalse($authenticator->removeFrontendAuthentication());
}

/**
* @param Security&MockObject $security
* @param SessionInterface&MockObject $session
* @param UserProviderInterface&MockObject $userProvider
* @param LoggerInterface&MockObject $logger
*/
private function getAuthenticator(Security $security = null, SessionInterface $session = null, UserProviderInterface $userProvider = null, LoggerInterface $logger = null): FrontendPreviewAuthenticator
{
if (null === $security) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,11 +523,6 @@ public function onInvalidCredentials($username): bool
return false;
}

/**
* @param ContaoFramework&MockObject $framework
* @param AuthenticationHandlerInterface&MockObject $twoFactorHandler
* @param TrustedDeviceManagerInterface&MockObject $trustedDeviceManager
*/
private function createUsernamePasswordProvider(ContaoFramework $framework = null, AuthenticationHandlerInterface $twoFactorHandler = null, TrustedDeviceManagerInterface $trustedDeviceManager = null): AuthenticationProvider
{
$userProvider = $this->createMock(UserProviderInterface::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,6 @@ private function mockUser(string $class): User
}

/**
* @param Request&MockObject $request
*
* @return RequestStack&MockObject
*/
private function mockRequestStack(Request $request = null): RequestStack
Expand Down
3 changes: 0 additions & 3 deletions core-bundle/tests/Security/User/ContaoUserProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,6 @@ public function onPostAuthenticate(): void
// Dummy method to test the postAuthenticate hook
}

/**
* @param ContaoFramework&MockObject $framework
*/
private function getProvider(ContaoFramework $framework = null, string $userClass = BackendUser::class): ContaoUserProvider
{
if (null === $framework) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Contao\CoreBundle\Framework\ContaoFramework;
use Contao\CoreBundle\Tests\TestCase;
use Contao\CoreBundle\Twig\Extension\ContaoTemplateExtension;
use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;
Expand Down Expand Up @@ -75,9 +74,6 @@ public function testDoesNotRenderTheBackEndTemplateIfNotInBackEndScope(): void
$this->assertEmpty($this->getExtension(null, 'frontend')->renderContaoBackendTemplate());
}

/**
* @param ContaoFramework&MockObject $framework
*/
private function getExtension(ContaoFramework $framework = null, string $scope = 'backend'): ContaoTemplateExtension
{
$request = new Request();
Expand Down
6 changes: 2 additions & 4 deletions core-bundle/tests/Util/SimpleTokenParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -524,11 +524,9 @@ public function parseSimpleTokensInvalidComparison(): \Generator
public function testParseSimpleTokenWithCustomExtensionProvider(): void
{
$stringExtensionProvider = new class() implements ExpressionFunctionProviderInterface {
public function getFunctions()
public function getFunctions(): array
{
return [
ExpressionFunction::fromPhp('strtoupper'),
];
return [ExpressionFunction::fromPhp('strtoupper')];
}
};

Expand Down

0 comments on commit ca3af1d

Please sign in to comment.