8000 Add return types to tests and final|internal|private methods by nicolas-grekas · Pull Request #33279 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Add return types to tests and final|internal|private methods #33279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 21, 2019
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 1 addition & 3 deletions src/Symfony/Bridge/Doctrine/Test/TestRepositoryFactory.php
8000
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ final class TestRepositoryFactory implements RepositoryFactory

/**
* {@inheritdoc}
*
* @return ObjectRepository
*/
public function getRepository(EntityManagerInterface $entityManager, $entityName)
public function getRepository(EntityManagerInterface $entityManager, $entityName): ObjectRepository
{
$repositoryHash = $this->getRepositoryHash($entityManager, $entityName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,7 @@ protected function invokeLoadCacheDriver(array $objectManager, ContainerBuilder
$method->invokeArgs($this->extension, [$objectManager, $container, $cacheName]);
}

/**
* @return \Symfony\Component\DependencyInjection\ContainerBuilder
*/
protected function createContainer(array $data = [])
protected function createContainer(array $data = []): ContainerBuilder
{
return new ContainerBuilder(new ParameterBag(array_merge([
'kernel.bundles' => ['FrameworkBundle' => 'Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle'],
Expand Down
8 changes: 1 addition & 7 deletions src/Symfony/Bridge/Doctrine/Tests/Fixtures/BaseUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ class BaseUser

/**
* BaseUser constructor.
*
* @param int $id
* @param string $username
*/
public function __construct(int $id, string $username)
{
Expand All @@ -42,10 +39,7 @@ public function getId()
return $this->id;
}

/**
* @return string
*/
public function getUsername()
public function getUsername(): string
{
return $this->username;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,12 @@ public function __construct(SingleIntIdNoToStringEntity $objectOne, SingleIntIdN
$this->objectTwo = $objectTwo;
}

/**
* @return SingleIntIdNoToStringEntity
*/
public function getObjectOne()
public function getObjectOne(): SingleIntIdNoToStringEntity
{
return $this->objectOne;
}

/**
* @return SingleIntIdNoToStringEntity
*/
public function getObjectTwo()
public function getObjectTwo(): SingleIntIdNoToStringEntity
{
return $this->objectTwo;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ public function __construct(string $string = null)
$this->string = $string;
}

/**
* @return string
*/
public function getString()
public function getString(): string
{
return $this->string;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@ public function convertToPHPValue($value, AbstractPlatform $platform)

/**
* {@inheritdoc}
*
* @return string
*/
public function getName()
public function getName(): string
{
return 'string_wrapper';
}
Expand Down
8 changes: 4 additions & 4 deletions src/Symfony/Bridge/Doctrine/Tests/Fixtures/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ public function __construct($id1, $id2, $name)
$this->name = $name;
}

public function getRoles()
public function getRoles(): array
{
}

public function getPassword()
public function getPassword(): ?string
{
}

public function getSalt()
public function getSalt(): ?string
{
}

public function getUsername()
public function getUsername(): string
{
return $this->name;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Doctrine/Tests/ManagerRegistryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function setTestContainer($container)
$this->container = $container;
}

public function getAliasNamespace($alias)
public function getAliasNamespace($alias): string
{
return 'Foo';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,16 @@ class DoctrineFooType extends Type

/**
* {@inheritdoc}
*
* @return string
*/
public function getName()
public function getName(): string
{
return self::NAME;
}

/**
* {@inheritdoc}
*
* @return string
*/
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform): string
{
return $platform->getClobTypeDeclarationSQL([]);
}
Expand Down Expand Up @@ -80,10 +76,8 @@ public function convertToPHPValue($value, AbstractPlatform $platform)

/**
* {@inheritdoc}
*
* @return bool
*/
public function requiresSQLCommentHint(AbstractPlatform $platform)
public function requiresSQLCommentHint(AbstractPlatform $platform): bool
{
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ public function testFormat(array $record, $expectedMessage)
self::assertSame($expectedMessage, $formatter->format($record));
}

/**
* @return array
*/
public function providerFormatTests()
public function providerFormatTests(): array
{
$currentDateTime = new \DateTime();

Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Bridge/Monolog/Tests/LoggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ public function testInheritedClassCallCountErrorsWithoutArgument()

class ClassThatInheritLogger extends Logger
{
public function getLogs()
public function getLogs(): array
{
parent::getLogs();
return parent::getLogs();
}

public function countErrors()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ private function getRecord($level = Logger::WARNING, $message = 'test')

class ClassThatInheritDebugProcessor extends DebugProcessor
{
public function getLogs()
public function getLogs(): array
{
parent::getLogs();
return parent::getLogs();
}

public function countErrors()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,7 @@ protected function createProxy(\$class, \Closure \$factory)
$this->assertSame(123, @$foo->dynamicProp);
}

/**
* @return array
*/
public function getProxyCandidates()
public function getProxyCandidates(): array
{
$definitions = [
[new Definition(__CLASS__), true],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class StubTranslator implements TranslatorInterface
{
public function trans($id, array $parameters = [], $domain = null, $locale = null)
public function trans($id, array $parameters = [], $domain = null, $locale = null): string
{
return '[trans]'.strtr($id, $parameters).'[/trans]';
}
Expand Down
10 changes: 2 additions & 8 deletions src/Symfony/Bridge/Twig/Tests/Translation/TwigExtractorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,7 @@ public function testExtractSyntaxError($resources)
}
}

/**
* @return array
*/
public function resourcesWithSyntaxErrorsProvider()
public function resourcesWithSyntaxErrorsProvider(): array
{
return [
[__DIR__.'/../Fixtures'],
Expand Down Expand Up @@ -157,10 +154,7 @@ public function testExtractWithFiles($resource)
$this->assertEquals('Hi!', $catalogue->get('Hi!', 'messages'));
}

/**
* @return array
*/
public function resourceProvider()
public function resourceProvider(): array
{
$directory = __DIR__.'/../Fixtures/extractor/';

Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Bundle/FrameworkBundle/Test/TestContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ public function has($id): bool

/**
* {@inheritdoc}
*
* @return object|null
*/
public function get($id, $invalidBehavior = /* self::EXCEPTION_ON_INVALID_REFERENCE */ 1)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@

class TestAppKernel extends Kernel
{
public function registerBundles()
public function registerBundles(): iterable
{
return [
new FrameworkBundle(),
];
}

public function getProjectDir()
public function getProjectDir(): string
{
return __DIR__.'/test';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public static function staticMethod()

class RouteStub extends Route
{
public function compile()
public function compile(): CompiledRoute
{
return new CompiledRoute('', '#PATH_REGEX#', [], [], '#HOST_REGEX#');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function getNotImplementingTranslatorBagInterfaceTranslatorClassNames()

class TranslatorWithTranslatorBag implements TranslatorInterface
{
public function trans($id, array $parameters = [], $domain = null, $locale = null)
public function trans($id, array $parameters = [], $domain = null, $locale = null): string
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

class CustomPathBundle extends Bundle
{
public function getPath()
public function getPath(): string
{
return __DIR__.'/..';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase as BaseWebTestCase;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpKernel\KernelInterface;

abstract class AbstractWebTestCase extends BaseWebTestCase
{
Expand Down Expand Up @@ -42,14 +43,14 @@ protected static function deleteTmpDir()
$fs->remove($dir);
}

protected static function getKernelClass()
protected static function getKernelClass(): string
{
require_once __DIR__.'/app/AppKernel.php';

return 'Symfony\Bundle\FrameworkBundle\Tests\Functional\app\AppKernel';
}

protected static function createKernel(array $options = [])
protected static function createKernel(array $options = []): KernelInterface
{
$class = self::getKernelClass();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Templating\EngineInterface as ComponentEngineInterface;

class AutowiringTypesTest extends AbstractWebTestCase
Expand Down Expand Up @@ -70,7 +71,7 @@ public function testCacheAutowiring()
$this->assertInstanceOf(FilesystemAdapter::class, $autowiredServices->getCachePool());
}

protected static function createKernel(array $options = [])
protected static function createKernel(array $options = []): KernelInterface
{
return parent::createKernel(['test_case' => 'AutowiringTypes'] + $options);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct($customConfig = null)
$this->customConfig = $customConfig;
}

public function getConfigTreeBuilder()
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('test');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\DependencyInjection;

use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;
Expand Down Expand Up @@ -42,7 +43,7 @@ public function prepend(ContainerBuilder $container)
/**
* {@inheritdoc}
*/
public function getConfiguration(array $config, ContainerBuilder $container)
public function getConfiguration(array $config, ContainerBuilder $container): ?ConfigurationInterface
{
return new Configuration($this->customConfig);
}
Expand Down
Original file line number Diff line number Diff line E0BF change
Expand Up @@ -24,7 +24,7 @@ public function __construct(ContainerInterface $container)
$this->container = $container;
}

public static function getSubscribedServices()
public static function getSubscribedServices(): array
{
return ['translator' => TranslatorInterface::class];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Symfony\Component\Cache\Adapter\RedisAdapter;
use Symfony\Component\Cache\Adapter\TagAwareAdapter;
use Symfony\Component\Cache\Exception\InvalidArgumentException;
use Symfony\Component\HttpKernel\KernelInterface;

class CachePoolsTest extends AbstractWebTestCase
{
Expand Down Expand Up @@ -116,7 +117,7 @@ private function doTestCachePools($options, $adapterClass)
$this->assertNotInstanceof(TagAwareAdapter::class, $pool7);
}

protected static function createKernel(array $options = [])
protected static function createKernel(array $options = []): KernelInterface
{
return parent::createKernel(['test_case' => 'CachePools'] + $options);
}
Expand Down
Loading
0