Skip to content

Commit 7685cdd

Browse files
Add more callable type hints
1 parent 4e0c6e1 commit 7685cdd

File tree

23 files changed

+36
-54
lines changed

23 files changed

+36
-54
lines changed

src/Symfony/Bridge/Twig/Command/DebugCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ private function getMetadata($type, $entity)
149149
return;
150150
}
151151
$refl = new \ReflectionMethod($cb[0], $cb[1]);
152-
} elseif (is_object($cb) && is_callable($cb)) {
152+
} elseif (is_object($cb) && method_exists($cb, '__invoke')) {
153153
$refl = new \ReflectionMethod($cb, '__invoke');
154154
} elseif (function_exists($cb)) {
155155
$refl = new \ReflectionFunction($cb);

src/Symfony/Bundle/FrameworkBundle/Resources/config/debug_prod.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<service id="debug.debug_handlers_listener" class="Symfony\Component\HttpKernel\EventListener\DebugHandlersListener">
1313
<tag name="kernel.event_subscriber" />
1414
<tag name="monolog.logger" channel="php" />
15-
<argument /><!-- Exception handler -->
15+
<argument>null</argument><!-- Exception handler -->
1616
<argument type="service" id="logger" on-invalid="null" />
1717
<argument>null</argument><!-- Log levels map for enabled error levels -->
1818
<argument>null</argument>

src/Symfony/Component/Console/Helper/ProcessHelper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class ProcessHelper extends Helper
3636
*
3737
* @return Process The process that ran
3838
*/
39-
public function run(OutputInterface $output, $cmd, $error = null, $callback = null, $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE)
39+
public function run(OutputInterface $output, $cmd, $error = null, callable $callback = null, $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE)
4040
{
4141
if ($output instanceof ConsoleOutputInterface) {
4242
$output = $output->getErrorOutput();
@@ -92,7 +92,7 @@ public function run(OutputInterface $output, $cmd, $error = null, $callback = nu
9292
*
9393
* @see run()
9494
*/
95-
public function mustRun(OutputInterface $output, $cmd, $error = null, $callback = null)
95+
public function mustRun(OutputInterface $output, $cmd, $error = null, callable $callback = null)
9696
{
9797
$process = $this->run($output, $cmd, $error, $callback);
9898

@@ -112,7 +112,7 @@ public function mustRun(OutputInterface $output, $cmd, $error = null, $callback
112112
*
113113
* @return callable
114114
*/
115-
public function wrapCallback(OutputInterface $output, Process $process, $callback = null)
115+
public function wrapCallback(OutputInterface $output, Process $process, callable $callback = null)
116116
{
117117
if ($output instanceof ConsoleOutputInterface) {
118118
$output = $output->getErrorOutput();

src/Symfony/Component/Console/Helper/ProgressBar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function __construct(OutputInterface $output, $max = 0)
8686
* @param string $name The placeholder name (including the delimiter char like %)
8787
* @param callable $callable A PHP callable
8888
*/
89-
public static function setPlaceholderFormatterDefinition($name, $callable)
89+
public static function setPlaceholderFormatterDefinition($name, callable $callable)
9090
{
9191
if (!self::$formatters) {
9292
self::$formatters = self::initPlaceholderFormatters();

src/Symfony/Component/Console/Helper/QuestionHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ private function getHiddenResponse(OutputInterface $output, $inputStream)
377377
*
378378
* @throws \Exception In case the max number of attempts has been reached and no valid response has been given
379379
*/
380-
private function validateAttempts($interviewer, OutputInterface $output, Question $question)
380+
private function validateAttempts(callable $interviewer, OutputInterface $output, Question $question)
381381
{
382382
$error = null;
383383
$attempts = $question->getMaxAttempts();

src/Symfony/Component/Console/Question/Question.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public function setAutocompleterValues($values)
164164
*
165165
* @return Question The current instance
166166
*/
167-
public function setValidator($validator)
167+
public function setValidator(callable $validator = null)
168168
{
169169
$this->validator = $validator;
170170

@@ -220,11 +220,11 @@ public function getMaxAttempts()
220220
*
221221
* The normalizer can be a callable (a string), a closure or a class implementing __invoke.
222222
*
223-
* @param string|\Closure $normalizer
223+
* @param callable $normalizer
224224
*
225225
* @return Question The current instance
226226
*/
227-
public function setNormalizer($normalizer)
227+
public function setNormalizer(callable $normalizer)
228228
{
229229
$this->normalizer = $normalizer;
230230

@@ -236,7 +236,7 @@ public function setNormalizer($normalizer)
236236
*
237237
* The normalizer can ba a callable (a string), a closure or a class implementing __invoke.
238238
*
239-
* @return string|\Closure
239+
* @return callable
240240
*/
241241
public function getNormalizer()
242242
{

src/Symfony/Component/ExpressionLanguage/ExpressionFunction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class ExpressionFunction
4141
* @param callable $compiler A callable able to compile the function
4242
* @param callable $evaluator A callable able to evaluate the function
4343
*/
44-
public function __construct($name, $compiler, $evaluator)
44+
public function __construct($name, callable $compiler, callable $evaluator)
4545
{
4646
$this->name = $name;
4747
$this->compiler = $compiler;

src/Symfony/Component/ExpressionLanguage/ExpressionLanguage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function parse($expression, $names)
112112
*
113113
* @see ExpressionFunction
114114
*/
115-
public function register($name, $compiler, $evaluator)
115+
public function register($name, callable $compiler, callable $evaluator)
116116
{
117117
$this->functions[$name] = array('compiler' => $compiler, 'evaluator' => $evaluator);
118118
}

src/Symfony/Component/Finder/Iterator/CustomFilterIterator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ class CustomFilterIterator extends FilterIterator
2626
/**
2727
* Constructor.
2828
*
29-
* @param \Iterator $iterator The Iterator to filter
30-
* @param array $filters An array of PHP callbacks
29+
* @param \Iterator $iterator The Iterator to filter
30+
* @param callable[] $filters An array of PHP callbacks
3131
*
3232
* @throws \InvalidArgumentException
3333
*/

src/Symfony/Component/Form/ChoiceList/ArrayKeyChoiceList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public static function toArrayKey($choice)
101101
* the keys of the values or if any of the
102102
* choices is not scalar
103103
*/
104-
public function __construct($choices, $value = null)
104+
public function __construct($choices, callable $value = null)
105105
{
106106
// If no values are given, use the choices as values
107107
// Since the choices are stored in the collection keys, i.e. they are

0 commit comments

Comments
 (0)