Skip to content

Different parsing of # comment on PHP 8 #3069

@kukulich

Description

@kukulich

Describe the bug
The # comment produces different tokens on PHP 8

Code sample

<?php

#

PHP 7.4

array(2) {
  [0]=>
  array(8) {
    ["type"]=>
    string(10) "T_OPEN_TAG"
    ["code"]=>
    int(382)
    ["content"]=>
    string(6) "<?php
"
    ["line"]=>
    int(1)
    ["column"]=>
    int(1)
    ["length"]=>
    int(5)
    ["level"]=>
    int(0)
    ["conditions"]=>
    array(0) {
    }
  }
  [1]=>
  array(8) {
    ["type"]=>
    string(9) "T_COMMENT"
    ["code"]=>
    int(380)
    ["content"]=>
    string(2) "#
"
    ["line"]=>
    int(2)
    ["column"]=>
    int(1)
    ["length"]=>
    int(1)
    ["level"]=>
    int(0)
    ["conditions"]=>
    array(0) {
    }
  }
}

PHP 8

array(3) {
  [0]=>
  array(8) {
    ["type"]=>
    string(10) "T_OPEN_TAG"
    ["code"]=>
    int(390)
    ["content"]=>
    string(6) "<?php
"
    ["line"]=>
    int(1)
    ["column"]=>
    int(1)
    ["length"]=>
    int(5)
    ["level"]=>
    int(0)
    ["conditions"]=>
    array(0) {
    }
  }
  [1]=>
  array(8) {
    ["code"]=>
    int(388)
    ["type"]=>
    string(9) "T_COMMENT"
    ["content"]=>
    string(1) "#"
    ["line"]=>
    int(2)
    ["column"]=>
    int(1)
    ["length"]=>
    int(1)
    ["level"]=>
    int(0)
    ["conditions"]=>
    array(0) {
    }
  }
  [2]=>
  array(8) {
    ["type"]=>
    string(12) "T_WHITESPACE"
    ["code"]=>
    int(393)
    ["content"]=>
    string(1) "
"
    ["line"]=>
    int(2)
    ["column"]=>
    int(2)
    ["length"]=>
    int(0)
    ["level"]=>
    int(0)
    ["conditions"]=>
    array(0) {
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions