Skip to content

Update typehints #12867

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
Oct 21, 2020
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
4 changes: 2 additions & 2 deletions components/asset.rst
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,12 @@ every day::
$this->version = date('Ymd');
}

public function getVersion($path)
public function getVersion(string $path)
{
return $this->version;
}

public function applyVersion($path)
public function applyVersion(string $path)
{
return sprintf('%s?v=%s', $path, $this->getVersion($path));
}
Expand Down
2 changes: 1 addition & 1 deletion configuration/env_var_processors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ create a class that implements

class LowercasingEnvVarProcessor implements EnvVarProcessorInterface
{
public function getEnv($prefix, $name, \Closure $getEnv)
public function getEnv(string $prefix, string $name, \Closure $getEnv)
{
$env = $getEnv($name);

Expand Down
4 changes: 2 additions & 2 deletions form/data_mappers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ in your form type::
/**
* @param Color|null $viewData
*/
public function mapDataToForms($viewData, $forms)
public function mapDataToForms($viewData, iterable $forms)
{
// there is no data yet, so nothing to prepopulate
if (null === $viewData) {
Expand All @@ -119,7 +119,7 @@ in your form type::
$forms['blue']->setData($viewData->getBlue());
}

public function mapFormsToData($forms, &$viewData)
public function mapFormsToData(iterable $forms, &$viewData)
{
/** @var FormInterface[] $forms */
$forms = iterator_to_array($forms);
Expand Down
12 changes: 6 additions & 6 deletions form/type_guesser.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@ Start by creating the class and these methods. Next, you'll learn how to fill ea

class PHPDocTypeGuesser implements FormTypeGuesserInterface
{
public function guessType($class, $property)
public function guessType(string $class, string $property)
{
}

public function guessRequired($class, $property)
public function guessRequired(string $class, string $property)
{
}

public function guessMaxLength($class, $property)
public function guessMaxLength(string $class, string $property)
{
}

public function guessPattern($class, $property)
public function guessPattern(string $class, string $property)
{
}
}
Expand Down Expand Up @@ -94,7 +94,7 @@ With this knowledge, you can implement the ``guessType()`` method of the

class PHPDocTypeGuesser implements FormTypeGuesserInterface
{
public function guessType($class, $property)
public function guessType(string $class, string $property)
{
$annotations = $this->readPhpDocAnnotations($class, $property);

Expand Down Expand Up @@ -129,7 +129,7 @@ With this knowledge, you can implement the ``guessType()`` method of the
}
}

protected function readPhpDocAnnotations($class, $property)
protected function readPhpDocAnnotations(string $class, string $property)
{
$reflectionProperty = new \ReflectionProperty($class, $property);
$phpdoc = $reflectionProperty->getDocComment();
Expand Down
2 changes: 1 addition & 1 deletion forms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ Set the ``label`` option on fields to define their labels explicitly::

->add('dueDate', DateType::class, [
// set it to FALSE to not display the label for this field
'label' => 'To Be Completed Before',
'label' => 'To Be Completed Before',
])

.. tip::
Expand Down
6 changes: 3 additions & 3 deletions frontend/custom_version_strategy.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ version string::
* @param string $manifestPath
* @param string|null $format
*/
public function __construct($manifestPath, $format = null)
public function __construct(string $manifestPath, string $format = null)
{
$this->manifestPath = $manifestPath;
$this->format = $format ?: '%s?%s';
}

public function getVersion($path)
public function getVersion(string $path)
{
if (!is_array($this->hashes)) {
$this->hashes = $this->loadManifest();
Expand All @@ -86,7 +86,7 @@ version string::
return isset($this->hashes[$path]) ? $this->hashes[$path] : '';
}

public function applyVersion($path)
public function applyVersion(string $path)
{
$version = $this->getVersion($path);

Expand Down
4 changes: 2 additions & 2 deletions reference/dic_tags.rst
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ service class::

class MyClearer implements CacheClearerInterface
{
public function clear($cacheDirectory)
public function clear(string $cacheDirectory)
{
// clear your cache
}
Expand Down Expand Up @@ -1062,7 +1062,7 @@ required option: ``alias``, which defines the name of the extractor::
/**
* Sets the prefix that should be used for new found messages.
*/
public function setPrefix($prefix)
public function setPrefix(string $prefix)
{
$this->prefix = $prefix;
}
Expand Down
2 changes: 1 addition & 1 deletion security/access_control.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Take the following ``access_control`` entries as an example:
'path' => '^/admin',
'roles' => 'ROLE_USER_METHOD',
'methods' => 'POST, PUT',
]
],
],
]);

Expand Down
2 changes: 1 addition & 1 deletion security/custom_authentication_provider.rst
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ to service ids that may not exist yet: ``App\Security\Authentication\Provider\Ws

<services>
<service id="App\Security\Authentication\Provider\WsseProvider">
<argument key="$cachePool" type="service" id="cache.app"></argument>
<argument key="$cachePool" type="service" id="cache.app"/>
</service>

<service id="App\Security\Firewall\WsseListener">
Expand Down
6 changes: 3 additions & 3 deletions security/user_provider.rst
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ interface only requires one method: ``loadUserByUsername($username)``::
{
// ...

public function loadUserByUsername($usernameOrEmail)
public function loadUserByUsername(string $usernameOrEmail)
{
$entityManager = $this->getEntityManager();

Expand Down Expand Up @@ -376,7 +376,7 @@ command will generate a nice skeleton to get you started::
*
* @throws UsernameNotFoundException if the user is not found
*/
public function loadUserByUsername($username)
public function loadUserByUsername(string $username)
{
// Load a User object from your data source or throw UsernameNotFoundException.
// The $username argument may not actually be a username:
Expand Down Expand Up @@ -412,7 +412,7 @@ command will generate a nice skeleton to get you started::
/**
* Tells Symfony to use this provider for this User class.
*/
public function supportsClass($class)
public function supportsClass(string $class)
{
return User::class === $class || is_subclass_of($class, User::class);
}
Expand Down
8 changes: 4 additions & 4 deletions serializer/custom_encoders.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@ create your own encoder that uses the

class YamlEncoder implements EncoderInterface, DecoderInterface
{
public function encode($data, $format, array $context = [])
public function encode($data, string $format, array $context = [])
{
return Yaml::dump($data);
}

public function supportsEncoding($format)
public function supportsEncoding(string $format)
{
return 'yaml' === $format;
}

public function decode($data, $format, array $context = [])
public function decode(string $data, string $format, array $context = [])
{
return Yaml::parse($data);
}

public function supportsDecoding($format)
public function supportsDecoding(string $format)
{
return 'yaml' === $format;
}
Expand Down
2 changes: 1 addition & 1 deletion session/locale_sticky_session.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ correct locale however you want::
{
private $defaultLocale;

public function __construct($defaultLocale = 'en')
public function __construct(string $defaultLocale = 'en')
{
$this->defaultLocale = $defaultLocale;
}
Expand Down