Skip to content

Wiki: fatal error in code sample in the Coding Standard Tutorial page #496

Closed
@rodrigoprimo

Description

@rodrigoprimo

The Coding Standard Tutorial page contains an example of a sniff to disallow hash comments: https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Coding-Standard-Tutorial#disallowhashcommentssniffphp

The code uses curly braces for array offset access, which causes a fatal error in PHP >= 8.0:

if ($tokens[$stackPtr]['content']{0} === '#') {

The line above should be replaced with the following:

if ($tokens[$stackPtr]['content'][0] === '#') {

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions