JFIF $ d d 7 * Z qn )ZP 0 !1 A "#a$2Qr D8 a Ri [f \m I ykI w0 c u F c Rı?lO7 к _f˓ [C $殷WF< _W ԣ s Kc ëI zyQy /_LK ℂ ;C",p F A : /] =H ~ , l s / 9 ć: [=/#f ; ) x { ٛE Q )~ = 𘙲r*2~ a _V = ' ku m F D } KYYC )( { * g& f `툪 r y ` = ^ c J. I ]( * `wq 1dđ #̩ ͑ 0 ; H ] u 搂 @:~ ו K L N s h } O I R* 8 :2 ! lD JV o ( 3 = M ( z Ȱ+i *N A r6K n S l ) ! J J Ӂ* % ݉?|D } d5: eP0 R; {$X' x F @ .ÊB {,WJ uQ ɲRI ;9 Q E琯 6 2fT .DU J ;*c P A\IL Nj! J ۱+ O\ ͔ ] ޒ S J ȧ c%A N ol ՎprU L Zԛe r E2= X D Xg VQeӓ k y P7 U* o m Q I s ,K `) 6\G3t?pgjr m ۛجw luGt f h 9uyP 0D;Uڽ"OXl i f $ ) &|ML 0 Z rm1 [ H XP l P R0 'G=i 2N +0 e 2 ]] 9 VT P O 7 h(F * 癈 ' = Q VZD F,d ߬ ~ T X G[ `le 69C R(!S2! P < 0 x < !1AQ "Raq 02Br #S CTb ? Ζ "]mH5WR 7 k.ۛ ! } Q~ + yԏ z |@ T20 S~ K e k *zF f^2X *( @ 8 r ? C I uI|֓>^Ex LgNU Y+{.R Ѫ τV YT D I 6 2 '8Y2 7'\T P.6 d &˦ @V q i |8 -O Ε ] ʔ U= T L 8= ;6c | !qfF3 a ů& ~$ l} 'NW U s$U k^S V : U#6w + +s &r+n ڐ { @ 29gL u " T Ù M=6 (^ "7 r}=6Yݾ lC u hquymp Ǧ G jhs ǜNl ɻ} o 7 #S6 a w 4 ! OS r D 5 7 % | ?x> L | / nD 6?/8 w # [ ) L 7 +6〼T A T g ! %5 Mm Z /c -{1_Je "| ^$ 'O & ޱմ < H vNqϡQ$ < 6 &Nݛ ֨tǻN (9 n ru~'όN sMG& ,uH Kw *Ī 5@ u6 BԒ i YN * f 0 _ GhKW u lT <nj- 0{ M L~ | /a v\ E = ?1 \ɟuq Ђ Y O a K ޡP q $ H8o Q˼EV ~ k 0 h' L Pp M -M" m^ !6l nմ 쮝C U T . ! :vMǨb h ډ Vc r @~p # !1QAa q ? AL0L x LU 4 d ; x " 16ad0 7.\ߋ 0 = P l v/ " c A Ay A|2pO8"d MV #1] = \ " ˡ ] k v I9 d ۓ & q ) ǐq E ꞅ v "P )q X &Q З non]я u ג./ ; gZ$ M QР 2M ]h ni 0 P $ێ 3CɏGjώy : m c # S_ l@ '_ \m|C 2`K _ 1 cIvGc $? PCQ S+D ? K aײ k Fr b 8 ύ NEدg ĝ U 3 6 #Ik+ v { v i ( ވ ? a e) X xy/*@Q Ǽ Ծ ) $ IWO l c G; !i k{ gOŀ L ('x T rb $ w) R $ & N1E td U3Uȉ1p M"N* (DNy d96.(jQ) X 5 c QɎMy W ? Q *!R > 6=7)Xj 5`J ] e 8%t ! + ' ! 1Q 5 !1 AQaq ё #2 "0BRb ? G t^ ## .l lQ T $ v , ,m 㵜5u bV =sY+ @d { N ! dn O < .- B; _w J t 6;Q Jd. Q c%p{ 1 ,sND dF H I0 Гo X ш e黅X ۢ F :)[ F G X ƹ / w _c MeD ,ʡc c . W D tA $ j@ : ) - #u c1< @ۗ9F ) KJ- hpP] _ x [ q B lb p ʖ w q " LFGd ƶ * s +ډ_Zc " ? % t[I P 6 J ]# =ɺ V v v CGs Gh1 > )6 |e y ? L ӣ m,4 G W Ui ` ] uJVo VDG< SB 6ϏQ @ TiU l y O U 0 kfV ~ ~}S Z @ *WU Ui ## ; s /[ = ! 7}" W N ] ' (L ! ~ y5 g9T̅J kbM' +s :S +B) v @ M j e C f j E 0 Y\Qn z G 1 д~ W o{T 9?` Rm yhsy3 !HAD ] m c1 ~ 2 L S u7x T ;j$ `} 4-> L# vzŏ I L S ֭ T { r jGK C ; b pU= - ` Bs K. S F w4 M q] Z dH S 0 ) tLg
<?php
/**
* PHPCSUtils, utility functions and classes for PHP_CodeSniffer sniff developers.
*
* @package PHPCSUtils
* @copyright 2019-2020 PHPCSUtils Contributors
* @license https://opensource.org/licenses/LGPL-3.0 LGPL3
* @link https://github.com/PHPCSStandards/PHPCSUtils
*/
namespace PHPCSUtils\Utils;
use PHP_CodeSniffer\Files\File;
use PHPCSUtils\Exceptions\LogicException;
use PHPCSUtils\Exceptions\OutOfBoundsStackPtr;
use PHPCSUtils\Exceptions\TypeError;
use PHPCSUtils\Internal\Cache;
use PHPCSUtils\Internal\IsShortArrayOrListWithCache;
use PHPCSUtils\Tokens\Collections;
/**
* Utility functions for use when examining arrays.
*
* @since 1.0.0
*/
final class Arrays
{
/**
* The tokens to target to find the double arrow in an array item.
*
* @since 1.0.0
*
* @var array<int|string, int|string>
*/
private static $doubleArrowTargets = [
\T_DOUBLE_ARROW => \T_DOUBLE_ARROW,
// Nested arrays.
\T_ARRAY => \T_ARRAY,
\T_OPEN_SHORT_ARRAY => \T_OPEN_SHORT_ARRAY,
// Inline function, control structures and other things to skip over.
\T_LIST => \T_LIST,
\T_FN => \T_FN,
\T_MATCH => \T_MATCH,
\T_ATTRIBUTE => \T_ATTRIBUTE,
];
/**
* Determine whether a T_OPEN/CLOSE_SHORT_ARRAY token is a short array construct
* and not a short list.
*
* This method also accepts `T_OPEN/CLOSE_SQUARE_BRACKET` tokens to allow it to be
* PHPCS cross-version compatible as the short array tokenizing has been plagued by
* a number of bugs over time.
*
* @since 1.0.0
*
* @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
* @param int $stackPtr The position of the short array bracket token.
*
* @return bool `TRUE` if the token passed is the open/close bracket of a short array.
* `FALSE` if the token is a short list bracket, a plain square bracket
* or not one of the accepted tokens.
*/
public static function isShortArray(File $phpcsFile, $stackPtr)
{
return IsShortArrayOrListWithCache::isShortArray($phpcsFile, $stackPtr);
}
/**
* Find the array opener and closer based on a T_ARRAY or T_OPEN_SHORT_ARRAY token.
*
* This method also accepts `T_OPEN_SQUARE_BRACKET` tokens to allow it to be
* PHPCS cross-version compatible as the short array tokenizing has been plagued by
* a number of bugs over time, which affects the short array determination.
*
* @since 1.0.0
*
* @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
* @param int $stackPtr The position of the `T_ARRAY` or `T_OPEN_SHORT_ARRAY`
* token in the stack.
* @param true|null $isShortArray Short-circuit the short array check for `T_OPEN_SHORT_ARRAY`
* tokens if it isn't necessary.
* Efficiency tweak for when this has already been established,
* i.e. when encountering a nested array while walking the
* tokens in an array.
* Use with care.
*
* @return array<string, int>|false An array with the token pointers; or `FALSE` if this is not a
* (short) array token or if the opener/closer could not be determined.
* The format of the array return value is:
* ```php
* array(
* 'opener' => integer, // Stack pointer to the array open bracket.
* 'closer' => integer, // Stack pointer to the array close bracket.
* )
* ```
*/
public static function getOpenClose(File $phpcsFile, $stackPtr, $isShortArray = null)
{
$tokens = $phpcsFile->getTokens();
// Is this one of the tokens this function handles ?
if (isset($tokens[$stackPtr]) === false
|| isset(Collections::arrayOpenTokensBC()[$tokens[$stackPtr]['code']]) === false
) {
return false;
}
switch ($tokens[$stackPtr]['code']) {
case \T_ARRAY:
if (isset($tokens[$stackPtr]['parenthesis_opener'])) {
$opener = $tokens[$stackPtr]['parenthesis_opener'];
if (isset($tokens[$opener]['parenthesis_closer'])) {
$closer = $tokens[$opener]['parenthesis_closer'];
}
}
break;
case \T_OPEN_SHORT_ARRAY:
case \T_OPEN_SQUARE_BRACKET:
if ($isShortArray === true || self::isShortArray($phpcsFile, $stackPtr) === true) {
$opener = $stackPtr;
$closer = $tokens[$stackPtr]['bracket_closer'];
}
break;
}
if (isset($opener, $closer)) {
return [
'opener' => $opener,
'closer' => $closer,
];
}
return false;
}
/**
* Get the stack pointer position of the double arrow within an array item.
*
* Expects to be passed the array item start and end tokens as retrieved via
* {@see \PHPCSUtils\Utils\PassedParameters::getParameters()}.
*
* @since 1.0.0
*
* @param \PHP_CodeSniffer\Files\File $phpcsFile The file being examined.
* @param int $start Stack pointer to the start of the array item.
* @param int $end Stack pointer to the last token in the array item.
*
* @return int|false Stack pointer to the double arrow if this array item has a key; or `FALSE` otherwise.
*
* @throws \PHPCSUtils\Exceptions\TypeError If the $start or $end parameters are not integers.
* @throws \PHPCSUtils\Exceptions\OutOfBoundsStackPtr If the tokens passed do not exist in the $phpcsFile.
* @throws \PHPCSUtils\Exceptions\LogicException If $end pointer is before the $start pointer.
*/
public static function getDoubleArrowPtr(File $phpcsFile, $start, $end)
{
$tokens = $phpcsFile->getTokens();
if (\is_int($start) === false) {
throw TypeError::create(2, '$start', 'integer', $start);
}
if (\is_int($end) === false) {
throw TypeError::create(3, '$end', 'integer', $end);
}
if (isset($tokens[$start]) === false) {
throw OutOfBoundsStackPtr::create(2, '$start', $start);
}
if (isset($tokens[$end]) === false) {
throw OutOfBoundsStackPtr::create(3, '$end', $end);
}
if ($start > $end) {
throw LogicException::create(
\sprintf('The $start token must be before the $end token. Received: $start %d, $end %d', $start, $end)
);
}
$cacheId = "$start-$end";
if (Cache::isCached($phpcsFile, __METHOD__, $cacheId) === true) {
return Cache::get($phpcsFile, __METHOD__, $cacheId);
}
$targets = self::$doubleArrowTargets;
$targets += Collections::closedScopes();
$doubleArrow = ($start - 1);
$returnValue = false;
++$end;
do {
$doubleArrow = $phpcsFile->findNext(
$targets,
($doubleArrow + 1),
$end
);
if ($doubleArrow === false) {
break;
}
if ($tokens[$doubleArrow]['code'] === \T_DOUBLE_ARROW) {
$returnValue = $doubleArrow;
break;
}
// Skip over closed scopes which may contain foreach structures or generators.
if ((isset(Collections::closedScopes()[$tokens[$doubleArrow]['code']]) === true
|| $tokens[$doubleArrow]['code'] === \T_FN
|| $tokens[$doubleArrow]['code'] === \T_MATCH)
&& isset($tokens[$doubleArrow]['scope_closer']) === true
) {
$doubleArrow = $tokens[$doubleArrow]['scope_closer'];
continue;
}
// Skip over attributes which may contain arrays as a passed parameters.
if ($tokens[$doubleArrow]['code'] === \T_ATTRIBUTE
&& isset($tokens[$doubleArrow]['attribute_closer'])
) {
$doubleArrow = $tokens[$doubleArrow]['attribute_closer'];
continue;
}
// Skip over any parenthesized/bracketed expression (potential keyed list or callback in array format).
if (isset($tokens[$doubleArrow]['parenthesis_closer'])) {
$doubleArrow = $tokens[$doubleArrow]['parenthesis_closer'];
continue;
}
if (isset($tokens[$doubleArrow]['bracket_closer'])) {
$doubleArrow = $tokens[$doubleArrow]['bracket_closer'];
continue;
}
break;
} while ($doubleArrow < $end);
Cache::set($phpcsFile, __METHOD__, $cacheId, $returnValue);
return $returnValue;
}
}