Skip to content

Commit c84ee65

Browse files
committed
minor symfony#22453 Fix minor phpdoc mismatches with the code(detected by phan) (TysonAndre)
This PR was squashed before being merged into the 2.7 branch (closes symfony#22453). Discussion ---------- Fix minor phpdoc mismatches with the code(detected by phan) | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | none | License | MIT | Doc PR | no Fix minor mismatches between phpdoc and the type of the code itself, detected by etsy/phan (Prevent confusion in the future) The actual return types of a few functions have changed from int to bool where preg_match or `&` was used. Fix optional param before required param in src/Symfony/Component/Serializer/Normalizer/AbstractObjectNormalizer.php The config used and the rest of the output is at https://gist.github.com/TysonAndre/91bed0e16583301f1e6e5cc2a4807081 (Uses some patches to etsy/phan that weren't merged to master yet) Commits ------- 12f1239 Fix minor phpdoc mismatches with the code(detected by phan)
2 parents c669b88 + 12f1239 commit c84ee65

File tree

16 files changed

+39
-32
lines changed

16 files changed

+39
-32
lines changed

src/Symfony/Component/CssSelector/Parser/Reader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function getOffset($string)
9595
/**
9696
* @param string $pattern
9797
*
98-
* @return bool
98+
* @return array|false
9999
*/
100100
public function findPattern($pattern)
101101
{

src/Symfony/Component/CssSelector/XPath/Extension/NodeExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function setFlag($flag, $on)
7070
*/
7171
public function hasFlag($flag)
7272
{
73-
return $this->flags & $flag;
73+
return (bool) ($this->flags & $flag);
7474
}
7575

7676
/**

src/Symfony/Component/ExpressionLanguage/Lexer.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function tokenize($expression)
4242
continue;
4343
}
4444

45-
if (preg_match('/[0-9]+(?:\.[0-9]+)?/A', $expression, $match, null, $cursor)) {
45+
if (preg_match('/[0-9]+(?:\.[0-9]+)?/A', $expression, $match, 0, $cursor)) {
4646
// numbers
4747
$number = (float) $match[0]; // floats
4848
if (preg_match('/^[0-9]+$/', $match[0]) && $number <= PHP_INT_MAX) {
@@ -69,19 +69,19 @@ public function tokenize($expression)
6969

7070
$tokens[] = new Token(Token::PUNCTUATION_TYPE, $expression[$cursor], $cursor + 1);
7171
++$cursor;
72-
} elseif (preg_match('/"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'/As', $expression, $match, null, $cursor)) {
72+
} elseif (preg_match('/"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'/As', $expression, $match, 0, $cursor)) {
7373
// strings
7474
$tokens[] = new Token(Token::STRING_TYPE, stripcslashes(substr($match[0], 1, -1)), $cursor + 1);
7575
$cursor += strlen($match[0]);
76-
} elseif (preg_match('/not in(?=[\s(])|\!\=\=|not(?=[\s(])|and(?=[\s(])|\=\=\=|\>\=|or(?=[\s(])|\<\=|\*\*|\.\.|in(?=[\s(])|&&|\|\||matches|\=\=|\!\=|\*|~|%|\/|\>|\||\!|\^|&|\+|\<|\-/A', $expression, $match, null, $cursor)) {
76+
} elseif (preg_match('/not in(?=[\s(])|\!\=\=|not(?=[\s(])|and(?=[\s(])|\=\=\=|\>\=|or(?=[\s(])|\<\=|\*\*|\.\.|in(?=[\s(])|&&|\|\||matches|\=\=|\!\=|\*|~|%|\/|\>|\||\!|\^|&|\+|\<|\-/A', $expression, $match, 0, $cursor)) {
7777
// operators
7878
$tokens[] = new Token(Token::OPERATOR_TYPE, $match[0], $cursor + 1);
7979
$cursor += strlen($match[0]);
8080
} elseif (false !== strpos('.,?:', $expression[$cursor])) {
8181
// punctuation
8282
$tokens[] = new Token(Token::PUNCTUATION_TYPE, $expression[$cursor], $cursor + 1);
8383
++$cursor;
84-
} elseif (preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/A', $expression, $match, null, $cursor)) {
84+
} elseif (preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/A', $expression, $match, 0, $cursor)) {
8585
// names
8686
$tokens[] = new Token(Token::NAME_TYPE, $match[0], $cursor + 1);
8787
$cursor += strlen($match[0]);

src/Symfony/Component/ExpressionLanguage/Token.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Token
3232
/**
3333
* Constructor.
3434
*
35-
* @param int $type The type of the token
35+
* @param string $type The type of the token (self::*_TYPE)
3636
* @param string $value The token value
3737
* @param int $cursor The cursor position in the source
3838
*/

src/Symfony/Component/HttpFoundation/FileBag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function add(array $files = array())
6969
*
7070
* @param array|UploadedFile $file A (multi-dimensional) array of uploaded file information
7171
*
72-
* @return array A (multi-dimensional) array of UploadedFile instances
72+
* @return UploadedFile|UploadedFile[] A (multi-dimensional) array of UploadedFile instances
7373
*/
7474
protected function convertFileInformation($file)
7575
{

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,7 @@ public function getScheme()
956956
* If your reverse proxy uses a different header name than "X-Forwarded-Port",
957957
* configure it via "setTrustedHeaderName()" with the "client-port" key.
958958
*
959-
* @return string
959+
* @return int|string can be a string if fetched from the server bag
960960
*/
961961
public function getPort()
962962
{

src/Symfony/Component/HttpKernel/Bundle/Bundle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public function getPath()
127127
/**
128128
* Returns the bundle parent name.
129129
*
130-
* @return string The Bundle parent name it overrides or null if no parent
130+
* @return string|null The Bundle parent name it overrides or null if no parent
131131
*/
132132
public function getParent()
133133
{

src/Symfony/Component/HttpKernel/Profiler/Profile.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public function setUrl($url)
156156
/**
157157
* Returns the time.
158158
*
159-
* @return string The time
159+
* @return int The time
160160
*/
161161
public function getTime()
162162
{
@@ -167,6 +167,9 @@ public function getTime()
167167
return $this->time;
168168
}
169169

170+
/**
171+
* @param int The time
172+
*/
170173
public function setTime($time)
171174
{
172175
$this->time = $time;

src/Symfony/Component/Intl/DateFormatter/DateFormat/FullTransformer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public function formatReplace($dateChars, $dateTime)
133133
* @param \DateTime $dateTime A configured DateTime object to use to perform the date calculation
134134
* @param string $value String to convert to a time value
135135
*
136-
* @return int The corresponding Unix timestamp
136+
* @return int|false The corresponding Unix timestamp
137137
*
138138
* @throws \InvalidArgumentException When the value can not be matched with pattern
139139
*/

src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ public function getPattern()
348348
/**
349349
* Returns the formatter's time type.
350350
*
351-
* @return string The time type used by the formatter
351+
* @return int The time type used by the formatter
352352
*
353353
* @see http://www.php.net/manual/en/intldateformatter.gettimetype.php
354354
*/
@@ -433,7 +433,7 @@ public function localtime($value, &$position = 0)
433433
* contain -1 otherwise it will contain the position at which parsing
434434
* ended. If $parse_pos > strlen($value), the parse fails immediately.
435435
*
436-
* @return string Parsed value as a timestamp
436+
* @return int Parsed value as a timestamp
437437
*
438438
* @see http://www.php.net/manual/en/intldateformatter.parse.php
439439
*

0 commit comments

Comments
 (0)