Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add return types to internal & magic methods when possible #33294

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 1 commit into from
Aug 22, 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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ private function createCollector($queries)

class StringRepresentableClass
{
public function __toString()
public function __toString(): string
{
return 'string representation';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct($id1, $id2, $name)
$this->name = $name;
}

public function __toString()
public function __toString(): string
{
return $this->name;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct($id1, $id2, $name)
$this->name = $name;
}

public function __toString()
public function __toString(): string
{
return $this->name;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Doctrine/Tests/Fixtures/Person.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function __construct($id, $name)
$this->name = $name;
}

public function __toString()
public function __toString(): string
{
return (string) $this->name;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct(SingleIntIdNoToStringEntity $entity, $name)
$this->name = $name;
}

public function __toString()
public function __toString(): string
{
return (string) $this->name;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct($id, $name)
$this->name = $name;
}

public function __toString()
public function __toString(): string
{
return (string) $this->name;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __construct($id, $name)
$this->name = $name;
}

public function __toString()
public function __toString(): string
{
return (string) $this->name;
}
Expand All @@ -50,7 +50,7 @@ public function __construct($id)
$this->id = $id;
}

public function __toString()
public function __toString(): string
{
return (string) $this->id;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct($id, $name)
$this->name = $name;
}

public function __toString()
public function __toString(): string
{
return $this->name;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ protected function build(ContainerBuilder $container)
$container->register('logger', NullLogger::class);
}

public function __sleep()
public function __sleep(): array
{
return ['varDir', 'testCase', 'rootConfig', 'environment', 'debug'];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function getLogDir(): string
return $this->cacheDir;
}

public function __sleep()
public function __sleep(): array
{
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/TwigBundle/TemplateIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct(KernelInterface $kernel, string $rootDir, array $pat
}

/**
* {@inheritdoc}
* @return \Traversable
*/
public function getIterator()
{
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/Config/Resource/GlobResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ public function __sleep(): array
return ['prefix', 'pattern', 'recursive', 'hash', 'forExclusion', 'excludedPrefixes'];
}

/**
* @return \Traversable
*/
public function getIterator()
{
if (!file_exists($this->prefix) || (!$this->recursive && '' === $this->pattern)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Console/Helper/TableRows.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function __construct(callable $generator)
$this->generator = $generator;
}

public function getIterator()
public function getIterator(): \Traversable
{
$g = $this->generator;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ public function testFormatAndWrap()

class TableCell
{
public function __toString()
public function __toString(): string
{
return '<info>some info</info>';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ public function __construct(array $values)
$this->values = $values;
}

public function getIterator()
public function getIterator(): \Traversable
{
return new \ArrayIterator($this->values);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public function testContextExceptionKeyCanBeExceptionOrOtherValues()

class DummyTest
{
public function __toString()
public function __toString(): string
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ public function __construct(callable $generator, $count)
$this->count = $count;
}

public function getIterator()
public function getIterator(): \Traversable
{
$g = $this->generator;

return $g();
}

public function count()
public function count(): int
{
if (\is_callable($count = $this->count)) {
$this->count = $count();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ public function load(array $configs, ContainerBuilder $configuration)
return $configuration;
}

public function getXsdValidationBasePath()
public function getXsdValidationBasePath(): string
{
return false;
}

public function getNamespace()
public function getNamespace(): string
{
return 'http://www.example.com/schema/project';
}

public function getAlias()
public function getAlias(): string
{
return 'project';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

class ProjectWithXsdExtension extends ProjectExtension
{
public function getXsdValidationBasePath()
public function getXsdValidationBasePath(): string
{
return __DIR__.'/schema';
}

public function getNamespace()
public function getNamespace(): string
{
return 'http://www.example.com/schema/projectwithxsd';
}

public function getAlias()
public function getAlias(): string
{
return 'projectwithxsd';
}
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,17 @@ public function callPassed()

class DummyProxyDumper implements ProxyDumper
{
public function isProxyCandidate(Definition $definition)
public function isProxyCandidate(Definition $definition): bool
{
return $definition->isLazy();
}

public function getProxyFactoryCode(Definition $definition, $id, $factoryCall = null)
public function getProxyFactoryCode(Definition $definition, $id, $factoryCall = null): string
{
return " // lazy factory for {$definition->getClass()}\n\n";
}

public function getProxyCode(Definition $definition)
public function getProxyCode(Definition $definition): string
{
return "// proxy code for {$definition->getClass()}\n";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@

class ProjectWithXsdExtensionInPhar extends ProjectExtension
{
public function getXsdValidationBasePath()
public function getXsdValidationBasePath(): string
{
return __DIR__.'/schema';
}

public function getNamespace()
public function getNamespace(): string
{
return 'http://www.example.com/schema/projectwithxsdinphar';
}

public function getAlias()
public function getAlias(): string
{
return 'projectwithxsdinphar';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ public function accept()
return true;
}

/**
* @return bool
*/
public function hasChildren()
{
return $this->isRecursive && $this->iterator->hasChildren();
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/Finder/Iterator/SortableIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ public function __construct(\Traversable $iterator, $sort, bool $reverseOrder =
}
}

/**
* @return \Traversable
*/
public function getIterator()
{
if (1 === $this->sort) {
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Finder/Tests/Iterator/Iterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function rewind()
reset($this->values);
}

public function valid()
public function valid(): bool
{
return false !== $this->current();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public function getData()
/**
* @internal
*/
public function __sleep()
public function __sleep(): array
{
foreach ($this->data['forms_by_hash'] as &$form) {
if (isset($form['type_class']) && !$form['type_class'] instanceof ClassStub) {
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Form/FormBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public function all()
}

/**
* {@inheritdoc}
* @return int
*/
public function count()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ public function __construct($property)
$this->property = $property;
}

public function __toString()
public function __toString(): string
{
return $this->property;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __construct(array $array = null)
$this->array = $array ?: [];
}

public function offsetExists($offset)
public function offsetExists($offset): bool
{
return \array_key_exists($offset, $this->array);
}
Expand All @@ -48,12 +48,12 @@ public function offsetUnset($offset)
unset($this->array[$offset]);
}

public function getIterator()
public function getIterator(): \Traversable
{
return new \ArrayIterator($this->array);
}

public function count()
public function count(): int
{
return \count($this->array);
}
Expand All @@ -63,7 +63,7 @@ public function __serialize(): array
return $this->array;
}

public function serialize()
public function serialize(): string
{
return serialize($this->__serialize());
}
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Form/Tests/SimpleFormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct($count)
$this->count = $count;
}

public function count()
public function count(): int
{
return $this->count;
}
Expand All @@ -47,7 +47,7 @@ public function __construct($count)
$this->iterator = new \ArrayIterator($count > 0 ? array_fill(0, $count, 'Foo') : []);
}

public function getIterator()
public function getIterator(): \Traversable
{
return $this->iterator;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function getChildren()
}

/**
* {@inheritdoc}
* @return bool
*/
public function hasChildren()
{
Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Component/Form/Util/OrderedHashMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function __construct(array $elements = [])
}

/**
* {@inheritdoc}
* @return bool
*/
public function offsetExists($key)
{
Expand Down Expand Up @@ -157,15 +157,15 @@ public function offsetUnset($key)
}

/**
* {@inheritdoc}
* @return \Traversable
*/
public function getIterator()
{
return new OrderedHashMapIterator($this->elements, $this->orderedKeys, $this->managedCursors);
}

/**
* {@inheritdoc}
* @return int
*/
public function count()
{
Expand Down
Loading