Skip to content

Conversation

@juan-morales
Copy link
Contributor

@juan-morales juan-morales commented Dec 2, 2025

This PR pretends to add the location where the error occurs when processing a json string (json_validate()or json_decode()). As the message suggests, is the "nearby location", like MySQL does it when there is an error with a SQL string.

I tried to achieve this many times in the past, but failed, my previous approaches were .... terrible and error-prone.

Now I used a different approach suggested by @bukka . I hope I get closer to a descent implementation. Did my best on this one.

I tested with JSON string with 1GB long, and values were calculated correctly for rows and columns.

Thanks for reviewing and I hope this helps.

Credits:
Besides some reading about bison, etc. ... @bukka pointed to https://github.com/libjso/jso which basically exposed me how to port its code to the PHP parser.

@juan-morales juan-morales marked this pull request as ready for review December 2, 2025 15:51
@juan-morales juan-morales requested a review from mvorisek December 2, 2025 15:51
@juan-morales juan-morales changed the title WIP - Json last error msg/error message with location error Json last error msg/error message with location error Dec 2, 2025
Copy link
Member

@bukka bukka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks mostly good (nicely taken from jso :) ). Just some minor things.

Other than that I like the new format not exposing the content and just showing the location which I think is acceptable without RFC. Previously I was the only one suggesting a new function but I no longer think it's necessary.

@juan-morales juan-morales requested review from Girgias and bukka December 9, 2025 20:08
Copy link
Member

@bukka bukka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good.

@bukka bukka merged commit b80ffc5 into php:master Jan 3, 2026
10 checks passed
@bukka
Copy link
Member

bukka commented Jan 3, 2026

NEWS and UPGRADING updated in 8422224

@juan-morales
Copy link
Contributor Author

I Am so happy

sebastianbergmann added a commit to sebastianbergmann/phpunit that referenced this pull request Jan 4, 2026
sebastianbergmann added a commit to sebastianbergmann/phpunit that referenced this pull request Jan 4, 2026
* 10.5:
  Update test expectation after php/php-src#20629
  Update tools
sebastianbergmann added a commit to sebastianbergmann/phpunit that referenced this pull request Jan 4, 2026
* 11.5:
  Update test expectation after php/php-src#20629
  Update tools
sebastianbergmann added a commit to sebastianbergmann/phpunit that referenced this pull request Jan 4, 2026
* 12.5:
  Update test expectation after php/php-src#20629
  Update tools
nicolas-grekas added a commit to symfony/symfony that referenced this pull request Jan 5, 2026
…ages in PHP 8.6 (xabbuh)

This PR was merged into the 6.4 branch.

Discussion
----------

[HttpClient] fix assertion for updated syntax error messages in PHP 8.6

| Q             | A
| ------------- | ---
| Branch?       |  6.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Issues        |
| License       | MIT

see php/php-src#20629

Commits
-------

192e32c fix assertion for updated syntax error messages in PHP 8.6
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.

4 participants