File: NullsafeObjectOperatorTest.inc

package info (click to toggle)
php-codesniffer 3.5.8-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 9,808 kB
  • sloc: php: 59,806; xml: 11,787; pascal: 6,386; javascript: 2,078; makefile: 9; sh: 8
file content (29 lines) | stat: -rw-r--r-- 567 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
<?php

/*
 * Null safe operator.
 */

/* testObjectOperator */
echo $obj->foo;

/* testNullsafeObjectOperator */
echo $obj?->foo;

/* testNullsafeObjectOperatorWriteContext */
// Intentional parse error, but not the concern of the tokenizer.
$foo?->bar->baz = 'baz';

/* testTernaryThen */
echo $obj ? $obj->prop : $other->prop;

/* testParseErrorWhitespaceNotAllowed */
echo $obj ?
    -> foo;

/* testParseErrorCommentNotAllowed */
echo $obj ?/*comment*/-> foo;

/* testLiveCoding */
// Intentional parse error. This has to be the last test in the file.
echo $obj?