minor #33056 cleanup remaining param $options and internal Intl FullTransformer (Tobion)

This PR was merged into the 4.4 branch.

Discussion
----------

cleanup remaining param $options and internal Intl FullTransformer

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets |#...   <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        |

Continuation of #33020 and #33019

Commits
-------

5dbcdc6ff4 cleanup remaining param  and internal Intl FulLTransformer
This commit is contained in:
Nicolas Grekas 2019-08-08 17:14:45 +02:00
commit e0ccbf667a
29 changed files with 27 additions and 123 deletions

View File

@ -132,7 +132,6 @@ abstract class Descriptor implements DescriptorInterface
* * name: name of described service
*
* @param Definition|Alias|object $service
* @param array $options
*/
abstract protected function describeContainerService($service, array $options = [], ContainerBuilder $builder = null);
@ -176,7 +175,6 @@ abstract class Descriptor implements DescriptorInterface
* Describes a callable.
*
* @param callable $callable
* @param array $options
*/
abstract protected function describeCallable($callable, array $options = []);

View File

@ -37,7 +37,6 @@ class Router extends BaseRouter implements WarmableInterface, ServiceSubscriberI
/**
* @param mixed $resource The main resource to load
* @param array $options An array of options
*/
public function __construct(ContainerInterface $container, $resource, array $options = [], RequestContext $context = null, ContainerInterface $parameters = null, LoggerInterface $logger = null, string $defaultLocale = null)
{

View File

@ -36,8 +36,7 @@ class ActionsHelper extends Helper
/**
* Returns the fragment content for a given URI.
*
* @param string $uri A URI
* @param array $options An array of options
* @param string $uri
*
* @return string The fragment content
*

View File

@ -65,10 +65,6 @@ class Translator extends BaseTranslator implements WarmableInterface
* * debug: Whether to enable debugging or not (false by default)
* * resource_files: List of translation resources available grouped by locale.
*
* @param string $defaultLocale
* @param array $loaderIds An array of loader Ids
* @param array $options An array of options
*
* @throws InvalidArgumentException
*/
public function __construct(ContainerInterface $container, MessageFormatterInterface $formatter, string $defaultLocale, array $loaderIds = [], array $options = [])

View File

@ -71,7 +71,6 @@ trait MemcachedTrait
* - [['localhost', 11211, 33]]
*
* @param array[]|string|string[] $servers An array of servers, a DSN, or an array of DSNs
* @param array $options An array of options
*
* @return \Memcached
*

View File

@ -24,7 +24,6 @@ interface DescriptorInterface
* Describes an object if supported.
*
* @param object $object
* @param array $options
*/
public function describe(OutputInterface $output, $object, array $options = []);
}

View File

@ -61,7 +61,6 @@ class OutputFormatterStyle implements OutputFormatterStyleInterface
*
* @param string|null $foreground The style foreground color name
* @param string|null $background The style background color name
* @param array $options The style options
*/
public function __construct(string $foreground = null, string $background = null, array $options = [])
{

View File

@ -49,7 +49,6 @@ class DescriptorHelper extends Helper
* * raw_text: boolean, sets output type as raw
*
* @param object $object
* @param array $options
*
* @throws InvalidArgumentException when the given format is not supported
*/

View File

@ -21,8 +21,6 @@ interface DumperInterface
/**
* Dumps the service container.
*
* @param array $options An array of options
*
* @return string The representation of the service container
*/
public function dump(array $options = []);

View File

@ -32,8 +32,6 @@ class ResizeFormListener implements EventSubscriberInterface
private $deleteEmpty;
/**
* @param string $type
* @param array $options
* @param bool $allowAdd Whether children could be added to the group
* @param bool $allowDelete Whether children could be removed from the group
* @param bool|callable $deleteEmpty

View File

@ -16,6 +16,7 @@ use PHPUnit\Framework\TestCase;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Form\FormBuilder;
use Symfony\Component\Form\FormInterface;
abstract class AbstractFormTest extends TestCase
{
@ -30,7 +31,7 @@ abstract class AbstractFormTest extends TestCase
protected $factory;
/**
* @var \Symfony\Component\Form\FormInterface
* @var FormInterface
*/
protected $form;
@ -48,43 +49,24 @@ abstract class AbstractFormTest extends TestCase
$this->form = null;
}
/**
* @return \Symfony\Component\Form\FormInterface
*/
abstract protected function createForm();
abstract protected function createForm(): FormInterface;
/**
* @param string $name
* @param string|null $dataClass
* @param array $options
*
* @return FormBuilder
*/
protected function getBuilder($name = 'name', EventDispatcherInterface $dispatcher = null, $dataClass = null, array $options = [])
protected function getBuilder(?string $name = 'name', EventDispatcherInterface $dispatcher = null, string $dataClass = null, array $options = []): FormBuilder
{
return new FormBuilder($name, $dataClass, $dispatcher ?: $this->dispatcher, $this->factory, $options);
}
/**
* @return MockObject
*/
protected function getDataMapper()
protected function getDataMapper(): MockObject
{
return $this->getMockBuilder('Symfony\Component\Form\DataMapperInterface')->getMock();
}
/**
* @return MockObject
*/
protected function getDataTransformer()
protected function getDataTransformer(): MockObject
{
return $this->getMockBuilder('Symfony\Component\Form\DataTransformerInterface')->getMock();
}
/**
* @return MockObject
*/
protected function getFormValidator()
protected function getFormValidator(): MockObject
{
return $this->getMockBuilder('Symfony\Component\Form\FormValidatorInterface')->getMock();
}

View File

@ -17,6 +17,7 @@ use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationRequestHandler
use Symfony\Component\Form\FormError;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\Forms;
use Symfony\Component\Form\FormView;
use Symfony\Component\Form\SubmitButtonBuilder;
@ -190,7 +191,7 @@ class CompoundFormTest extends AbstractFormTest
public function testAddUsingIntegerNameAndType()
{
$child = $this->getBuilder(0)->getForm();
$child = $this->getBuilder('0')->getForm();
$this->factory->expects($this->once())
->method('createNamed')
@ -1123,7 +1124,7 @@ class CompoundFormTest extends AbstractFormTest
$this->assertNull($this->form->get('bar')->getData());
}
protected function createForm($name = 'name', $compound = true)
protected function createForm(string $name = 'name', bool $compound = true): FormInterface
{
$builder = $this->getBuilder($name);

View File

@ -18,6 +18,7 @@ use Symfony\Component\Form\FormConfigBuilder;
use Symfony\Component\Form\FormError;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\Tests\Fixtures\FixedDataTransformer;
use Symfony\Component\Form\Tests\Fixtures\FixedFilterListener;
use Symfony\Component\PropertyAccess\PropertyPath;
@ -1096,7 +1097,7 @@ class SimpleFormTest extends AbstractFormTest
$form->setData('foo');
}
protected function createForm()
protected function createForm(): FormInterface
{
return $this->getBuilder()->getForm();
}

View File

@ -41,7 +41,6 @@ class MemcachedSessionHandler extends AbstractSessionHandler
* * expiretime: The time to live in seconds.
*
* @param \Memcached $memcached A \Memcached instance
* @param array $options An associative array of Memcached options
*
* @throws \InvalidArgumentException When unsupported options are passed
*/

View File

@ -61,9 +61,6 @@ class MongoDbSessionHandler extends AbstractSessionHandler
* If you use such an index, you can drop `gc_probability` to 0 since
* no garbage-collection is required.
*
* @param \MongoDB\Client $mongo A MongoDB\Client instance
* @param array $options An associative array of field options
*
* @throws \InvalidArgumentException When "database" or "collection" not provided
*/
public function __construct(\MongoDB\Client $mongo, array $options)

View File

@ -165,7 +165,6 @@ class PdoSessionHandler extends AbstractSessionHandler
* * lock_mode: The strategy for locking, see constants [default: LOCK_TRANSACTIONAL]
*
* @param \PDO|string|null $pdoOrDsn A \PDO instance or DSN string or URL string or null
* @param array $options An associative array of options
*
* @throws \InvalidArgumentException When PDO error mode is not PDO::ERRMODE_EXCEPTION
*/

View File

@ -35,7 +35,6 @@ class RedisSessionHandler extends AbstractSessionHandler
* * prefix: The prefix to use for the keys in order to avoid collision on the Redis server.
*
* @param \Redis|\RedisArray|\RedisCluster|\Predis\Client|RedisProxy $redis
* @param array $options An associative array of options
*
* @throws \InvalidArgumentException When unsupported client or options are passed
*/

View File

@ -97,7 +97,6 @@ class NativeSessionStorage implements SessionStorageInterface
* trans_sid_hosts, $_SERVER['HTTP_HOST']
* trans_sid_tags, "a=href,area=href,frame=src,form="
*
* @param array $options Session configuration options
* @param \SessionHandlerInterface|null $handler
*/
public function __construct(array $options = [], $handler = null, MetadataBag $metaBag = null)

View File

@ -62,7 +62,6 @@ class FragmentHandler
*
* @param string|ControllerReference $uri A URI as a string or a ControllerReference instance
* @param string $renderer The renderer name
* @param array $options An array of options
*
* @return string|null The Response content or null when the Response is streamed
*

View File

@ -25,8 +25,7 @@ interface FragmentRendererInterface
/**
* Renders a URI and returns the Response content.
*
* @param string|ControllerReference $uri A URI as a string or a ControllerReference instance
* @param array $options An array of options
* @param string|ControllerReference $uri A URI as a string or a ControllerReference instance
*
* @return Response A Response instance
*/

View File

@ -69,21 +69,9 @@ class FullTransformer
];
}
/**
* Return the array of Transformer objects.
*
* @return Transformer[] Associative array of Transformer objects (format char => Transformer)
*/
public function getTransformers()
{
return $this->transformers;
}
/**
* Format a DateTime using ICU dateformat pattern.
*
* @param \DateTime $dateTime A DateTime object to be used to generate the formatted value
*
* @return string The formatted value
*/
public function format(\DateTime $dateTime)
@ -98,14 +86,9 @@ class FullTransformer
/**
* Return the formatted ICU value for the matched date characters.
*
* @param string $dateChars The date characters to be replaced with a formatted ICU value
* @param \DateTime $dateTime A DateTime object to be used to generate the formatted value
*
* @return string The formatted value
*
* @throws NotImplementedException When it encounters a not implemented date character
*/
public function formatReplace($dateChars, $dateTime)
private function formatReplace(string $dateChars, \DateTime $dateTime): string
{
$length = \strlen($dateChars);
@ -167,12 +150,10 @@ class FullTransformer
/**
* Retrieve a regular expression to match with a formatted value.
*
* @param string $pattern The pattern to create the reverse matching regular expression
*
* @return string The reverse matching regular expression with named captures being formed by the
* transformer index in the $transformer array
*/
public function getReverseMatchingRegExp($pattern)
private function getReverseMatchingRegExp(string $pattern): string
{
$escapedPattern = preg_quote($pattern, '/');
@ -189,9 +170,8 @@ class FullTransformer
return $this->replaceQuoteMatch($dateChars);
}
$transformers = $this->getTransformers();
if (isset($transformers[$transformerIndex])) {
$transformer = $transformers[$transformerIndex];
if (isset($this->transformers[$transformerIndex])) {
$transformer = $this->transformers[$transformerIndex];
$captureName = str_repeat($transformerIndex, $length);
return "(?P<$captureName>".$transformer->getReverseMatchingRegExp($length).')';
@ -203,24 +183,16 @@ class FullTransformer
/**
* Check if the first char of a string is a single quote.
*
* @param string $quoteMatch The string to check
*
* @return bool true if matches, false otherwise
*/
public function isQuoteMatch($quoteMatch)
private function isQuoteMatch(string $quoteMatch): bool
{
return "'" === $quoteMatch[0];
}
/**
* Replaces single quotes at the start or end of a string with two single quotes.
*
* @param string $quoteMatch The string to replace the quotes
*
* @return string A string with the single quotes replaced
*/
public function replaceQuoteMatch($quoteMatch)
private function replaceQuoteMatch(string $quoteMatch): string
{
if (preg_match("/^'+$/", $quoteMatch)) {
return str_replace("''", "'", $quoteMatch);
@ -231,12 +203,8 @@ class FullTransformer
/**
* Builds a chars match regular expression.
*
* @param string $specialChars A string of chars to build the regular expression
*
* @return string The chars match regular expression
*/
protected function buildCharsMatch($specialChars)
private function buildCharsMatch(string $specialChars): string
{
$specialCharsArray = str_split($specialChars);
@ -250,10 +218,8 @@ class FullTransformer
/**
* Normalize a preg_replace match array, removing the numeric keys and returning an associative array
* with the value and pattern values for the matched Transformer.
*
* @return array
*/
protected function normalizeArray(array $data)
private function normalizeArray(array $data): array
{
$ret = [];
@ -275,12 +241,9 @@ class FullTransformer
* Calculates the Unix timestamp based on the matched values by the reverse matching regular
* expression of parse().
*
* @param \DateTime $dateTime The DateTime object to be used to calculate the timestamp
* @param array $options An array with the matched values to be used to calculate the timestamp
*
* @return bool|int The calculated timestamp or false if matched date is invalid
*/
protected function calculateUnixTimestamp(\DateTime $dateTime, array $options)
private function calculateUnixTimestamp(\DateTime $dateTime, array $options)
{
$options = $this->getDefaultValueForOptions($options);

View File

@ -23,7 +23,6 @@ abstract class Transformer
/**
* Format a value using a configured DateTime as date/time source.
*
*
* @param \DateTime $dateTime A DateTime object to be used to generate the formatted value
* @param int $length The formatted value string length
*

View File

@ -1520,14 +1520,8 @@ EOTXT;
}
/**
* @param string $commandline
* @param string|null $cwd
* @param array|null $env
* @param string|null $input
* @param int $timeout
* @param array $options
*
* @return Process
* @param string|array $commandline
* @param mixed $input
*/
private function getProcess($commandline, string $cwd = null, array $env = null, $input = null, ?int $timeout = 60): Process
{

View File

@ -24,8 +24,6 @@ interface GeneratorDumperInterface
* Dumps a set of routes to a string representation of executable code
* that can then be used to generate a URL of such a route.
*
* @param array $options An array of options
*
* @return string Executable code
*/
public function dump(array $options = []);

View File

@ -24,8 +24,6 @@ interface MatcherDumperInterface
* Dumps a set of routes to a string representation of executable code
* that can then be used to match a request against these routes.
*
* @param array $options An array of options
*
* @return string Executable code
*/
public function dump(array $options = []);

View File

@ -45,10 +45,10 @@ class Route implements \Serializable
* @param array $defaults An array of default parameter values
* @param array $requirements An array of requirements for parameters (regexes)
* @param array $options An array of options
* @param string $host The host pattern to match
* @param string|null $host The host pattern to match
* @param string|string[] $schemes A required URI scheme or an array of restricted schemes
* @param string|string[] $methods A required HTTP method or an array of restricted methods
* @param string $condition A condition that should evaluate to true for the route to match
* @param string|null $condition A condition that should evaluate to true for the route to match
*/
public function __construct(string $path, array $defaults = [], array $requirements = [], array $options = [], ?string $host = '', $schemes = [], $methods = [], ?string $condition = '')
{

View File

@ -239,8 +239,6 @@ class RouteCollection implements \IteratorAggregate, \Countable
* Adds options to all routes.
*
* An existing option value under the same name in a route will be overridden.
*
* @param array $options An array of options
*/
public function addOptions(array $options)
{

View File

@ -97,7 +97,6 @@ class Router implements RouterInterface, RequestMatcherInterface
/**
* @param mixed $resource The main resource to load
* @param array $options An array of options
*/
public function __construct(LoaderInterface $loader, $resource, array $options = [], RequestContext $context = null, LoggerInterface $logger = null, string $defaultLocale = null)
{
@ -124,8 +123,6 @@ class Router implements RouterInterface, RequestMatcherInterface
* * strict_requirements: Configure strict requirement checking for generators
* implementing ConfigurableRequirementsInterface (default is true)
*
* @param array $options An array of options
*
* @throws \InvalidArgumentException When unsupported option is provided
*/
public function setOptions(array $options)

View File

@ -25,8 +25,6 @@ interface DumperInterface
/**
* Dumps a workflow definition.
*
* @param array $options An array of options
*
* @return string The representation of the workflow
*/
public function dump(Definition $definition, Marking $marking = null, array $options = []);