minor #33294 Add return types to internal & magic methods when possible (nicolas-grekas)

This PR was merged into the 4.4 branch.

Discussion
----------

Add return types to internal & magic methods when possible

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #33236 #33228
| License       | MIT
| Doc PR        | -

Commits
-------

962dcfeed0 Add return types to internal & magic methods when possible
This commit is contained in:
Nicolas Grekas 2019-08-22 15:37:25 +02:00
commit 47322db110
80 changed files with 171 additions and 138 deletions

View File

@ -205,7 +205,7 @@ class DoctrineDataCollectorTest extends TestCase
class StringRepresentableClass
{
public function __toString()
public function __toString(): string
{
return 'string representation';
}

View File

@ -34,7 +34,7 @@ class CompositeIntIdEntity
$this->name = $name;
}
public function __toString()
public function __toString(): string
{
return $this->name;
}

View File

@ -34,7 +34,7 @@ class CompositeStringIdEntity
$this->name = $name;
}
public function __toString()
public function __toString(): string
{
return $this->name;
}

View File

@ -38,7 +38,7 @@ class Person
$this->name = $name;
}
public function __toString()
public function __toString(): string
{
return (string) $this->name;
}

View File

@ -31,7 +31,7 @@ class SingleAssociationToIntIdEntity
$this->name = $name;
}
public function __toString()
public function __toString(): string
{
return (string) $this->name;
}

View File

@ -33,7 +33,7 @@ class SingleIntIdEntity
$this->name = $name;
}
public function __toString()
public function __toString(): string
{
return (string) $this->name;
}

View File

@ -35,7 +35,7 @@ class SingleStringCastableIdEntity
$this->name = $name;
}
public function __toString()
public function __toString(): string
{
return (string) $this->name;
}
@ -50,7 +50,7 @@ class StringCastableObjectIdentity
$this->id = $id;
}
public function __toString()
public function __toString(): string
{
return (string) $this->id;
}

View File

@ -30,7 +30,7 @@ class SingleStringIdEntity
$this->name = $name;
}
public function __toString()
public function __toString(): string
{
return $this->name;
}

View File

@ -79,7 +79,7 @@ class AppKernel extends Kernel
$container->register('logger', NullLogger::class);
}
public function __sleep()
public function __sleep(): array
{
return ['varDir', 'testCase', 'rootConfig', 'environment', 'debug'];
}

View File

@ -64,7 +64,7 @@ class ConcreteMicroKernel extends Kernel implements EventSubscriberInterface
return $this->cacheDir;
}
public function __sleep()
public function __sleep(): array
{
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}

View File

@ -43,7 +43,7 @@ class TemplateIterator implements \IteratorAggregate
}
/**
* {@inheritdoc}
* @return \Traversable
*/
public function getIterator()
{

View File

@ -91,6 +91,9 @@ class GlobResource implements \IteratorAggregate, SelfCheckingResourceInterface
return ['prefix', 'pattern', 'recursive', 'hash', 'forExclusion', 'excludedPrefixes'];
}
/**
* @return \Traversable
*/
public function getIterator()
{
if (!file_exists($this->prefix) || (!$this->recursive && '' === $this->pattern)) {

View File

@ -23,7 +23,7 @@ class TableRows implements \IteratorAggregate
$this->generator = $generator;
}
public function getIterator()
public function getIterator(): \Traversable
{
$g = $this->generator;

View File

@ -339,7 +339,7 @@ EOF
class TableCell
{
public function __toString()
public function __toString(): string
{
return '<info>some info</info>';
}

View File

@ -835,7 +835,7 @@ class AutocompleteValues implements \IteratorAggregate
$this->values = $values;
}
public function getIterator()
public function getIterator(): \Traversable
{
return new \ArrayIterator($this->values);
}

View File

@ -204,7 +204,7 @@ class ConsoleLoggerTest extends TestCase
class DummyTest
{
public function __toString()
public function __toString(): string
{
}
}

View File

@ -28,14 +28,14 @@ class RewindableGenerator implements \IteratorAggregate, \Countable
$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();

View File

@ -25,17 +25,17 @@ class ProjectExtension implements ExtensionInterface
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';
}

View File

@ -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';
}

View File

@ -83,17 +83,17 @@ class MethodCallClass
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";
}

View File

@ -11,17 +11,17 @@ $phar->addFromString('ProjectWithXsdExtensionInPhar.php', <<<'EOT'
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';
}

View File

@ -68,6 +68,9 @@ class ExcludeDirectoryFilterIterator extends \FilterIterator implements \Recursi
return true;
}
/**
* @return bool
*/
public function hasChildren()
{
return $this->isRecursive && $this->iterator->hasChildren();

View File

@ -80,6 +80,9 @@ class SortableIterator implements \IteratorAggregate
}
}
/**
* @return \Traversable
*/
public function getIterator()
{
if (1 === $this->sort) {

View File

@ -33,7 +33,7 @@ class Iterator implements \Iterator
reset($this->values);
}
public function valid()
public function valid(): bool
{
return false !== $this->current();
}

View File

@ -234,7 +234,7 @@ class FormDataCollector extends DataCollector implements FormDataCollectorInterf
/**
* @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) {

View File

@ -158,7 +158,7 @@ class FormBuilder extends FormConfigBuilder implements \IteratorAggregate, FormB
}
/**
* {@inheritdoc}
* @return int
*/
public function count()
{

View File

@ -860,7 +860,7 @@ class DefaultChoiceListFactoryTest_Castable
$this->property = $property;
}
public function __toString()
public function __toString(): string
{
return $this->property;
}

View File

@ -24,7 +24,7 @@ class CustomArrayObject implements \ArrayAccess, \IteratorAggregate, \Countable,
$this->array = $array ?: [];
}
public function offsetExists($offset)
public function offsetExists($offset): bool
{
return \array_key_exists($offset, $this->array);
}
@ -48,12 +48,12 @@ class CustomArrayObject implements \ArrayAccess, \IteratorAggregate, \Countable,
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);
}
@ -63,7 +63,7 @@ class CustomArrayObject implements \ArrayAccess, \IteratorAggregate, \Countable,
return $this->array;
}
public function serialize()
public function serialize(): string
{
return serialize($this->__serialize());
}

View File

@ -32,7 +32,7 @@ class SimpleFormTest_Countable implements \Countable
$this->count = $count;
}
public function count()
public function count(): int
{
return $this->count;
}
@ -47,7 +47,7 @@ class SimpleFormTest_Traversable implements \IteratorAggregate
$this->iterator = new \ArrayIterator($count > 0 ? array_fill(0, $count, 'Foo') : []);
}
public function getIterator()
public function getIterator(): \Traversable
{
return $this->iterator;
}

View File

@ -34,7 +34,7 @@ class InheritDataAwareIterator extends \IteratorIterator implements \RecursiveIt
}
/**
* {@inheritdoc}
* @return bool
*/
public function hasChildren()
{

View File

@ -99,7 +99,7 @@ class OrderedHashMap implements \ArrayAccess, \IteratorAggregate, \Countable
}
/**
* {@inheritdoc}
* @return bool
*/
public function offsetExists($key)
{
@ -157,7 +157,7 @@ class OrderedHashMap implements \ArrayAccess, \IteratorAggregate, \Countable
}
/**
* {@inheritdoc}
* @return \Traversable
*/
public function getIterator()
{
@ -165,7 +165,7 @@ class OrderedHashMap implements \ArrayAccess, \IteratorAggregate, \Countable
}
/**
* {@inheritdoc}
* @return int
*/
public function count()
{

View File

@ -128,7 +128,7 @@ class OrderedHashMapIterator implements \Iterator
/**
* {@inheritdoc}
*/
public function valid()
public function valid(): bool
{
return null !== $this->key;
}

View File

@ -29,7 +29,7 @@ abstract class AbstractSessionHandler implements \SessionHandlerInterface, \Sess
private $igbinaryEmptyData;
/**
* {@inheritdoc}
* @return bool
*/
public function open($savePath, $sessionName)
{
@ -64,7 +64,7 @@ abstract class AbstractSessionHandler implements \SessionHandlerInterface, \Sess
abstract protected function doDestroy($sessionId);
/**
* {@inheritdoc}
* @return bool
*/
public function validateId($sessionId)
{
@ -75,7 +75,7 @@ abstract class AbstractSessionHandler implements \SessionHandlerInterface, \Sess
}
/**
* {@inheritdoc}
* @return string
*/
public function read($sessionId)
{
@ -98,7 +98,7 @@ abstract class AbstractSessionHandler implements \SessionHandlerInterface, \Sess
}
/**
* {@inheritdoc}
* @return bool
*/
public function write($sessionId, $data)
{
@ -115,7 +115,7 @@ abstract class AbstractSessionHandler implements \SessionHandlerInterface, \Sess
}
/**
* {@inheritdoc}
* @return bool
*/
public function destroy($sessionId)
{

View File

@ -55,7 +55,7 @@ class MemcachedSessionHandler extends AbstractSessionHandler
}
/**
* {@inheritdoc}
* @return bool
*/
public function close()
{
@ -71,7 +71,7 @@ class MemcachedSessionHandler extends AbstractSessionHandler
}
/**
* {@inheritdoc}
* @return bool
*/
public function updateTimestamp($sessionId, $data)
{
@ -99,7 +99,7 @@ class MemcachedSessionHandler extends AbstractSessionHandler
}
/**
* {@inheritdoc}
* @return int
*/
public function gc($maxlifetime)
{

View File

@ -39,7 +39,7 @@ class MigratingSessionHandler implements \SessionHandlerInterface, \SessionUpdat
}
/**
* {@inheritdoc}
* @return bool
*/
public function close()
{
@ -50,7 +50,7 @@ class MigratingSessionHandler implements \SessionHandlerInterface, \SessionUpdat
}
/**
* {@inheritdoc}
* @return bool
*/
public function destroy($sessionId)
{
@ -61,7 +61,7 @@ class MigratingSessionHandler implements \SessionHandlerInterface, \SessionUpdat
}
/**
* {@inheritdoc}
* @return int
*/
public function gc($maxlifetime)
{
@ -72,7 +72,7 @@ class MigratingSessionHandler implements \SessionHandlerInterface, \SessionUpdat
}
/**
* {@inheritdoc}
* @return bool
*/
public function open($savePath, $sessionName)
{
@ -83,7 +83,7 @@ class MigratingSessionHandler implements \SessionHandlerInterface, \SessionUpdat
}
/**
* {@inheritdoc}
* @return string
*/
public function read($sessionId)
{
@ -92,7 +92,7 @@ class MigratingSessionHandler implements \SessionHandlerInterface, \SessionUpdat
}
/**
* {@inheritdoc}
* @return bool
*/
public function write($sessionId, $sessionData)
{
@ -103,7 +103,7 @@ class MigratingSessionHandler implements \SessionHandlerInterface, \SessionUpdat
}
/**
* {@inheritdoc}
* @return bool
*/
public function validateId($sessionId)
{
@ -112,7 +112,7 @@ class MigratingSessionHandler implements \SessionHandlerInterface, \SessionUpdat
}
/**
* {@inheritdoc}
* @return bool
*/
public function updateTimestamp($sessionId, $sessionData)
{

View File

@ -80,7 +80,7 @@ class MongoDbSessionHandler extends AbstractSessionHandler
}
/**
* {@inheritdoc}
* @return bool
*/
public function close()
{
@ -100,7 +100,7 @@ class MongoDbSessionHandler extends AbstractSessionHandler
}
/**
* {@inheritdoc}
* @return int
*/
public function gc($maxlifetime)
{
@ -134,7 +134,7 @@ class MongoDbSessionHandler extends AbstractSessionHandler
}
/**
* {@inheritdoc}
* @return bool
*/
public function updateTimestamp($sessionId, $data)
{

View File

@ -19,7 +19,7 @@ namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
class NullSessionHandler extends AbstractSessionHandler
{
/**
* {@inheritdoc}
* @return bool
*/
public function close()
{
@ -27,7 +27,7 @@ class NullSessionHandler extends AbstractSessionHandler
}
/**
* {@inheritdoc}
* @return bool
*/
public function validateId($sessionId)
{
@ -43,7 +43,7 @@ class NullSessionHandler extends AbstractSessionHandler
}
/**
* {@inheritdoc}
* @return bool
*/
public function updateTimestamp($sessionId, $data)
{
@ -67,7 +67,7 @@ class NullSessionHandler extends AbstractSessionHandler
}
/**
* {@inheritdoc}
* @return int
*/
public function gc($maxlifetime)
{

View File

@ -260,7 +260,7 @@ class PdoSessionHandler extends AbstractSessionHandler
}
/**
* {@inheritdoc}
* @return bool
*/
public function open($savePath, $sessionName)
{
@ -274,7 +274,7 @@ class PdoSessionHandler extends AbstractSessionHandler
}
/**
* {@inheritdoc}
* @return string
*/
public function read($sessionId)
{
@ -288,7 +288,7 @@ class PdoSessionHandler extends AbstractSessionHandler
}
/**
* {@inheritdoc}
* @return int
*/
public function gc($maxlifetime)
{
@ -367,7 +367,7 @@ class PdoSessionHandler extends AbstractSessionHandler
}
/**
* {@inheritdoc}
* @return bool
*/
public function updateTimestamp($sessionId, $data)
{
@ -391,7 +391,7 @@ class PdoSessionHandler extends AbstractSessionHandler
}
/**
* {@inheritdoc}
* @return bool
*/
public function close()
{

View File

@ -104,7 +104,7 @@ class RedisSessionHandler extends AbstractSessionHandler
}
/**
* {@inheritdoc}
* @return bool
*/
public function updateTimestamp($sessionId, $data)
{

View File

@ -31,7 +31,7 @@ class StrictSessionHandler extends AbstractSessionHandler
}
/**
* {@inheritdoc}
* @return bool
*/
public function open($savePath, $sessionName)
{
@ -49,7 +49,7 @@ class StrictSessionHandler extends AbstractSessionHandler
}
/**
* {@inheritdoc}
* @return bool
*/
public function updateTimestamp($sessionId, $data)
{
@ -65,7 +65,7 @@ class StrictSessionHandler extends AbstractSessionHandler
}
/**
* {@inheritdoc}
* @return bool
*/
public function destroy($sessionId)
{
@ -86,7 +86,7 @@ class StrictSessionHandler extends AbstractSessionHandler
}
/**
* {@inheritdoc}
* @return bool
*/
public function close()
{
@ -94,7 +94,7 @@ class StrictSessionHandler extends AbstractSessionHandler
}
/**
* {@inheritdoc}
* @return int
*/
public function gc($maxlifetime)
{

View File

@ -36,7 +36,7 @@ class SessionHandlerProxy extends AbstractProxy implements \SessionHandlerInterf
// \SessionHandlerInterface
/**
* {@inheritdoc}
* @return bool
*/
public function open($savePath, $sessionName)
{
@ -44,7 +44,7 @@ class SessionHandlerProxy extends AbstractProxy implements \SessionHandlerInterf
}
/**
* {@inheritdoc}
* @return bool
*/
public function close()
{
@ -52,7 +52,7 @@ class SessionHandlerProxy extends AbstractProxy implements \SessionHandlerInterf
}
/**
* {@inheritdoc}
* @return string
*/
public function read($sessionId)
{
@ -60,7 +60,7 @@ class SessionHandlerProxy extends AbstractProxy implements \SessionHandlerInterf
}
/**
* {@inheritdoc}
* @return bool
*/
public function write($sessionId, $data)
{
@ -68,7 +68,7 @@ class SessionHandlerProxy extends AbstractProxy implements \SessionHandlerInterf
}
/**
* {@inheritdoc}
* @return bool
*/
public function destroy($sessionId)
{
@ -76,7 +76,7 @@ class SessionHandlerProxy extends AbstractProxy implements \SessionHandlerInterf
}
/**
* {@inheritdoc}
* @return int
*/
public function gc($maxlifetime)
{
@ -84,7 +84,7 @@ class SessionHandlerProxy extends AbstractProxy implements \SessionHandlerInterf
}
/**
* {@inheritdoc}
* @return bool
*/
public function validateId($sessionId)
{
@ -92,7 +92,7 @@ class SessionHandlerProxy extends AbstractProxy implements \SessionHandlerInterf
}
/**
* {@inheritdoc}
* @return bool
*/
public function updateTimestamp($sessionId, $data)
{

View File

@ -1054,7 +1054,7 @@ class ResponseTest extends ResponseTestCase
class StringableObject
{
public function __toString()
public function __toString(): string
{
return 'Foo';
}

View File

@ -148,7 +148,7 @@ class DumpDataCollector extends DataCollector implements DataDumperInterface
/**
* @internal
*/
public function __sleep()
public function __sleep(): array
{
if (!$this->dataCount) {
$this->data = [];

View File

@ -203,7 +203,7 @@ class ControllerTest
{
}
public function __toString()
public function __toString(): string
{
return '';
}

View File

@ -21,7 +21,6 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
use Symfony\Component\HttpKernel\DependencyInjection\ResettableServicePass;
use Symfony\Component\HttpKernel\DependencyInjection\ServicesResetter;
use Symfony\Component\HttpKernel\HttpKernel;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\HttpKernel\Tests\Fixtures\KernelForOverrideName;

View File

@ -200,7 +200,7 @@ class LoggerTest extends TestCase
class DummyTest
{
public function __toString()
public function __toString(): string
{
}
}

View File

@ -39,7 +39,7 @@ class ArrayAccessibleResourceBundle implements \ArrayAccess, \IteratorAggregate,
return $value instanceof \ResourceBundle ? new static($value) : $value;
}
public function offsetExists($offset)
public function offsetExists($offset): bool
{
return null !== $this->bundleImpl->get($offset);
}
@ -59,12 +59,12 @@ class ArrayAccessibleResourceBundle implements \ArrayAccess, \IteratorAggregate,
throw new BadMethodCallException('Resource bundles cannot be modified.');
}
public function getIterator()
public function getIterator(): \Traversable
{
return $this->bundleImpl;
}
public function count()
public function count(): int
{
return $this->bundleImpl->count();
}

View File

@ -42,7 +42,7 @@ class RingBuffer implements \ArrayAccess
/**
* {@inheritdoc}
*/
public function offsetExists($key)
public function offsetExists($key): bool
{
return isset($this->indices[$key]);
}

View File

@ -42,6 +42,9 @@ class Collection implements CollectionInterface
return $this->entries;
}
/**
* @return int
*/
public function count()
{
$con = $this->connection->getResource();
@ -58,6 +61,9 @@ class Collection implements CollectionInterface
return $count;
}
/**
* @return \Traversable
*/
public function getIterator()
{
if (0 === $this->count()) {
@ -81,6 +87,9 @@ class Collection implements CollectionInterface
}
}
/**
* @return bool
*/
public function offsetExists($offset)
{
$this->toArray();

View File

@ -55,8 +55,9 @@ class LdapTest extends TestCase
->expects($this->once())
->method('escape')
->with('foo', 'bar', 'baz')
->willReturn('');
->willReturn('')
;
$this->ldap->escape('foo', 'bar', 'baz');
}

View File

@ -27,7 +27,7 @@ final class Key
$this->resource = $resource;
}
public function __toString()
public function __toString(): string
{
return $this->resource;
}

View File

@ -54,7 +54,7 @@ class RawMessage implements \Serializable
/**
* @internal
*/
final public function serialize()
final public function serialize(): string
{
return serialize($this->__serialize());
}

View File

@ -66,6 +66,9 @@ class InputStream implements \IteratorAggregate
return !$this->open;
}
/**
* @return \Traversable
*/
public function getIterator()
{
$this->open = true;

View File

@ -24,7 +24,7 @@ class NonTraversableArrayObject implements \ArrayAccess, \Countable, \Serializab
$this->array = $array ?: [];
}
public function offsetExists($offset)
public function offsetExists($offset): bool
{
return \array_key_exists($offset, $this->array);
}
@ -48,7 +48,7 @@ class NonTraversableArrayObject implements \ArrayAccess, \Countable, \Serializab
unset($this->array[$offset]);
}
public function count()
public function count(): int
{
return \count($this->array);
}
@ -58,7 +58,7 @@ class NonTraversableArrayObject implements \ArrayAccess, \Countable, \Serializab
return $this->array;
}
public function serialize()
public function serialize(): string
{
return serialize($this->__serialize());
}

View File

@ -24,7 +24,7 @@ class TraversableArrayObject implements \ArrayAccess, \IteratorAggregate, \Count
$this->array = $array ?: [];
}
public function offsetExists($offset)
public function offsetExists($offset): bool
{
return \array_key_exists($offset, $this->array);
}
@ -48,12 +48,12 @@ class TraversableArrayObject implements \ArrayAccess, \IteratorAggregate, \Count
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);
}
@ -63,7 +63,7 @@ class TraversableArrayObject implements \ArrayAccess, \IteratorAggregate, \Count
return $this->array;
}
public function serialize()
public function serialize(): string
{
return serialize($this->__serialize());
}

View File

@ -64,6 +64,8 @@ class CompiledRoute implements \Serializable
}
/**
* @return string
*
* @internal since Symfony 4.3
* @final since Symfony 4.3
*/

View File

@ -78,6 +78,8 @@ class Route implements \Serializable
}
/**
* @return string
*
* @internal since Symfony 4.3
* @final since Symfony 4.3
*/

View File

@ -163,10 +163,9 @@ abstract class AbstractToken implements TokenInterface
}
/**
* {@inheritdoc}
* @return string
*
* @final since Symfony 4.3, use __serialize() instead
*
* @internal since Symfony 4.3, use __serialize() instead
*/
public function serialize()

View File

@ -113,7 +113,7 @@ class AuthenticationException extends RuntimeException
/**
* @internal
*/
public function __sleep()
public function __sleep(): array
{
if (__CLASS__ !== $c = (new \ReflectionMethod($this, 'serialize'))->getDeclaringClass()->name) {
@trigger_error(sprintf('Implementing the "%s::serialize()" method is deprecated since Symfony 4.3, implement the __serialize() and __unserialize() methods instead.', $c), E_USER_DEPRECATED);

View File

@ -152,7 +152,7 @@ class FakeCustomToken implements TokenInterface
{
}
public function serialize()
public function serialize(): string
{
}

View File

@ -259,7 +259,7 @@ class TestUser
$this->name = $name;
}
public function __toString()
public function __toString(): string
{
return $this->name;
}

View File

@ -122,7 +122,7 @@ class SecurityTest extends TestCase
class StringishUser
{
public function __toString()
public function __toString(): string
{
return 'stringish_user';
}

View File

@ -45,7 +45,7 @@ final class User implements UserInterface, EquatableInterface, AdvancedUserInter
$this->extraFields = $extraFields;
}
public function __toString()
public function __toString(): string
{
return $this->getUsername();
}

View File

@ -111,7 +111,7 @@ class TestFormLoginAuthenticator extends AbstractFormLoginAuthenticator
/**
* @param mixed $defaultSuccessRedirectUrl
*/
public function setDefaultSuccessRedirectUrl($defaultSuccessRedirectUrl): TestFormLoginAuthenticator
public function setDefaultSuccessRedirectUrl($defaultSuccessRedirectUrl): self
{
$this->defaultSuccessRedirectUrl = $defaultSuccessRedirectUrl;
@ -121,7 +121,7 @@ class TestFormLoginAuthenticator extends AbstractFormLoginAuthenticator
/**
* @param mixed $loginUrl
*/
public function setLoginUrl($loginUrl): TestFormLoginAuthenticator
public function setLoginUrl($loginUrl): self
{
$this->loginUrl = $loginUrl;

View File

@ -191,7 +191,7 @@ class UsernamePasswordFormAuthenticationListenerTest extends TestCase
class DummyUserClass
{
public function __toString()
public function __toString(): string
{
return '';
}

View File

@ -16,7 +16,7 @@ class TraversableDummy implements \IteratorAggregate
public $foo = 'foo';
public $bar = 'bar';
public function getIterator()
public function getIterator(): \Traversable
{
return new \ArrayIterator(get_object_vars($this));
}

View File

@ -22,7 +22,7 @@ class SimpleHelper extends Helper
$this->value = $value;
}
public function __toString()
public function __toString(): string
{
return $this->value;
}

View File

@ -662,7 +662,7 @@ class StringClass
$this->str = $str;
}
public function __toString()
public function __toString(): string
{
return $this->str;
}

View File

@ -116,7 +116,7 @@ class ConstraintViolationList implements \IteratorAggregate, ConstraintViolation
}
/**
* {@inheritdoc}
* @return int
*/
public function count()
{
@ -124,7 +124,7 @@ class ConstraintViolationList implements \IteratorAggregate, ConstraintViolation
}
/**
* {@inheritdoc}
* @return bool
*/
public function offsetExists($offset)
{

View File

@ -25,7 +25,7 @@ class ComparisonTest_Class
$this->value = $value;
}
public function __toString()
public function __toString(): string
{
return (string) $this->value;
}

View File

@ -248,7 +248,7 @@ class BicComparisonTestClass
$this->value = $value;
}
public function __toString()
public function __toString(): string
{
return (string) $this->value;
}

View File

@ -387,7 +387,7 @@ class UrlValidatorTest extends ConstraintValidatorTestCase
class EmailProvider
{
public function __toString()
public function __toString(): string
{
return '';
}

View File

@ -20,7 +20,7 @@ class Countable implements \Countable
$this->content = $content;
}
public function count()
public function count(): int
{
return \count($this->content);
}

View File

@ -24,7 +24,7 @@ class CustomArrayObject implements \ArrayAccess, \IteratorAggregate, \Countable,
$this->array = $array ?: [];
}
public function offsetExists($offset)
public function offsetExists($offset): bool
{
return \array_key_exists($offset, $this->array);
}
@ -48,12 +48,12 @@ class CustomArrayObject implements \ArrayAccess, \IteratorAggregate, \Countable,
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);
}
@ -63,7 +63,7 @@ class CustomArrayObject implements \ArrayAccess, \IteratorAggregate, \Countable,
return $this->array;
}
public function serialize()
public function serialize(): string
{
return serialize($this->__serialize());
}

View File

@ -15,7 +15,7 @@ class ToString
{
public $data;
public function __toString()
public function __toString(): string
{
return 'toString';
}

View File

@ -106,11 +106,17 @@ class Data implements \ArrayAccess, \Countable, \IteratorAggregate
return $children;
}
/**
* @return int
*/
public function count()
{
return \count($this->getValue());
}
/**
* @return \Traversable
*/
public function getIterator()
{
if (!\is_array($value = $this->getValue())) {
@ -136,6 +142,9 @@ class Data implements \ArrayAccess, \Countable, \IteratorAggregate
return null !== $this->seek($key);
}
/**
* @return bool
*/
public function offsetExists($key)
{
return $this->__isset($key);

View File

@ -44,7 +44,7 @@ class Stub
/**
* @internal
*/
public function __sleep()
public function __sleep(): array
{
$properties = [];

View File

@ -209,7 +209,7 @@ class VarExporterTest extends TestCase
class MySerializable implements \Serializable
{
public function serialize()
public function serialize(): string
{
return '123';
}
@ -227,7 +227,7 @@ class MyWakeup
public $baz;
public $def = 234;
public function __sleep()
public function __sleep(): array
{
return ['sub', 'baz'];
}
@ -305,7 +305,7 @@ class MyArrayObject extends \ArrayObject
class GoodNight
{
public function __sleep()
public function __sleep(): array
{
$this->good = 'night';
@ -395,7 +395,7 @@ class FooSerializable implements \Serializable
class Php74Serializable implements \Serializable
{
public function __serialize()
public function __serialize(): array
{
return [$this->foo = new \stdClass()];
}
@ -405,7 +405,7 @@ class Php74Serializable implements \Serializable
list($this->foo) = $data;
}
public function __sleep()
public function __sleep(): array
{
throw new \BadMethodCallException();
}
@ -415,7 +415,7 @@ class Php74Serializable implements \Serializable
throw new \BadMethodCallException();
}
public function serialize()
public function serialize(): string
{
throw new \BadMethodCallException();
}

View File

@ -63,7 +63,7 @@ final class TransitionBlockerList implements \IteratorAggregate, \Countable
*
* @return \ArrayIterator|TransitionBlocker[]
*/
public function getIterator()
public function getIterator(): \Traversable
{
return new \ArrayIterator($this->blockers);
}