Bug #81632 [Com]: Shuffled parser tokens on PHP 8.1?

From: Date: Wed, 17 Nov 2021 16:28:26 +0000
Subject: Bug #81632 [Com]: Shuffled parser tokens on PHP 8.1?
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-237824@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81632&edit=1

 ID:                 81632
 Comment by:         ondrej at mirtes dot cz
 Reported by:        ondrej at mirtes dot cz
 Summary:            Shuffled parser tokens on PHP 8.1?
 Status:             Feedback
 Type:               Bug
 Package:            *General Issues
 Operating System:   Ubuntu
 PHP Version:        8.1Git-2021-11-17 (Git)
 Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

This is the debug code that outputs the log: https://github.com/phpstan/phpstan-src/blob/ec1ea7c50bcc35d9506e86746a0a2f46171599e7/NetteReflection.php#L307


Previous Comments:
------------------------------------------------------------------------
[2021-11-17 16:21:20] cmb@php.net

Looks good here: <https://3v4l.org/MJA67>.

How do you map the token values to string representations?

------------------------------------------------------------------------
[2021-11-17 16:11:23] ondrej at mirtes dot cz

Description:
------------
I have a really weird bug to report. I have a case of test failure that's happening on PHP 8.1
nightly in GitHub Actions and only on Ubuntu.

I tracked it down to weird value returned from token_get_all when parsing this file: https://github.com/phpstan/phpstan-src/blob/master/src/Rules/Debug/DumpTypeRule.php

On other systems and versions, the exported tokens look correct: https://github.com/phpstan/phpstan-src/runs/4240472132?check_suite_focus=true

This is generally what I'd expect:

array (
  0 => 
  array (
    0 => 'T_OPEN_TAG',
    1 => '<?php ',
    2 => 1,
  ),
  1 => 
  array (
    0 => 'T_DECLARE',
    1 => 'declare',
    2 => 1,
  ),
  2 => '(',
  3 => 
  array (
    0 => 'T_STRING',
    1 => 'strict_types',
    2 => 1,
  ),
...



But on PHP 8.1 on Ubuntu, this is how the tokens look like
(https://github.com/phpstan/phpstan-src/runs/4240473383?check_suite_focus=true):

array (
  0 => 
  array (
    0 => 'T_END_HEREDOC',
    1 => '<?php ',
    2 => 1,
  ),
  1 => 
  array (
    0 => 'T_ENUM',
    1 => 'declare',
    2 => 1,
  ),
  2 => '(',
  3 => 
  array (
    0 => 'T_RETURN',
    1 => 'strict_types',
    2 => 1,
  ),
...

It's also possible it's a build issue that should be reported to the setup-php action, but
I decided to start here to track it down. Thank you.



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=81632&edit=1


Thread (9 messages)

« previous php.bugs (#237824) next »