File: AbstractArraySniffTest.inc

package info (click to toggle)
php-codesniffer 3.7.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 10,988 kB
  • sloc: php: 67,146; xml: 12,380; pascal: 7,999; javascript: 2,078; makefile: 9; sh: 8
file content (51 lines) | stat: -rw-r--r-- 912 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php

/* testSimpleValues */
$foo = [1,2,3];

/* testSimpleKeyValues */
$foo = ['1'=>1,'2'=>2,'3'=>3];

/* testMissingKeys */
$foo = ['1'=>1,2,'3'=>3];

/* testMultiTokenKeys */
$paths = array(
    Init::ROOT_DIR.'/a' => 'a',
    Init::ROOT_DIR.'/b' => 'b',
);

/* testMissingKeysCoalesceTernary */
return [
    $a => static function () { return [1,2,3]; },
    $b ?? $c,
    $d ? [$e] : [$f],
];

/* testTernaryValues */
$foo = [
    '1' => $row['status'] === 'rejected'
        ? self::REJECTED_CODE
        : self::VERIFIED_CODE,
    '2' => in_array($row['status'], array('notverified', 'unverified'), true)
        ? self::STATUS_PENDING
        : self::STATUS_VERIFIED,
    '3' => strtotime($row['date']),
];

/* testHeredocValues */
$foo = array(
    <<<HERE
HERE
,
    <<<HERE
HERE
  ,
   );

/* testArrowFunctionValue */
$foo = array(
    1 => '1',
    2 => fn ($x) => yield 'a' => $x,
    3 => '3',
);