Skip to content

Conversation

andrewnicols
Copy link

@andrewnicols andrewnicols commented Sep 10, 2025

Description

Fixes #1215 / #1216

Suggested changelog entry

Ignore skipped tokens in tokenizer.

Related issues/external references

Fixes #1215 / #1216

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
    • This change is only breaking for integrators, not for external standards or end-users.
  • Documentation improvement

PR checklist

  • I have checked there is no other PR open for the same change.
  • I have read the Contribution Guidelines.
  • I grant the project the right to include and distribute the code under the BSD-3-Clause license (and I have the right to grant these rights).
  • I have added tests to cover my changes. (N/A)
  • I have verified that the code complies with the projects coding standards.
  • [Required for new sniffs] I have added XML documentation for the sniff.
  • I have opened a sister-PR in the documentation repository to update the Wiki.

If a comment is on its own line, the new line token is merged into the comment token, and the new line is skipped by setting it to `null`.

Where the next line contains incomplete, or invalid, code which ends in an nullsafe operator (for example `$obj?`), the tokenizer will step backwards until it finds the next non-empty line.
The skipped new line token should be skipped during this parsing.
This can only occur during live coding or when a file has a parse error, but PHPCS should handle that situation gracefully.

Fixed now.

Fixes PHPCSStandards#1216.

This change is already covered via the existing tests.

Ref: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_using_values_null_as_an_array_offset_and_when_calling_array_key_exists
…n array offset" deprecation"

This reverts commit 6b82a86 / PR 1215 as it is no longer needed.
@andrewnicols andrewnicols changed the title Php85 nullable tokens Ignore skipped tokens when tokenizing ternaries Sep 10, 2025
@jrfnl
Copy link
Member

jrfnl commented Sep 10, 2025

I've left feedback about this PR in the underlying ticket: #1216 (comment)

@jrfnl jrfnl added this to the 3.13.5 milestone Sep 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants