Skip to content

Avoid ord deprecation notice in PHP 8.5#4724

Merged
fabpot merged 1 commit into
twigphp:3.xfrom
iquito:patch-1
Dec 14, 2025
Merged

Avoid ord deprecation notice in PHP 8.5#4724
fabpot merged 1 commit into
twigphp:3.xfrom
iquito:patch-1

Conversation

@iquito

@iquito iquito commented Dec 14, 2025

Copy link
Copy Markdown
Contributor

Change the one usage of ord() in Twig where a multibyte character can trigger the new deprecation in PHP 8.5, which is in the html_attr escape functionality in EscaperRuntime, currently leading to:

ord(): Providing a string that is not one byte long is deprecated. Use ord($str[0]) instead"

This small change fixes it. There are no other usages of ord() in Twig which lead to this deprecation notice.

Change the one usage of ord() in Twig where a multibyte character can trigger the new deprecation in PHP 8.5, which is in the `html_attr` escape functionality, previously leading to:

ord(): Providing a string that is not one byte long is deprecated. Use ord($str[0]) instead"
@iquito iquito changed the title Avoid ord deprecation in PHP 8.5 Avoid ord deprecation notice in PHP 8.5 Dec 14, 2025

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses a PHP 8.5 deprecation warning by updating the ord() function call in the html_attr escaping strategy to explicitly access the first byte of the string using array notation.

  • Fixes PHP 8.5 deprecation warning when ord() receives multibyte characters
  • Changes \ord($chr) to \ord($chr[0]) in the html_attr escaper callback
  • Maintains backward compatibility while preparing for PHP 8.5+

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@fabpot

fabpot commented Dec 14, 2025

Copy link
Copy Markdown
Contributor

Thank you @iquito.

@fabpot
fabpot merged commit cf87925 into twigphp:3.x Dec 14, 2025
43 of 47 checks passed
@iquito

iquito commented Dec 15, 2025

Copy link
Copy Markdown
Contributor Author

@fabpot I saw you released a new version, but only twig/extra-bundle is available as a new version on packagist. Maybe because some of the Github workflows didn't succeed?

@iquito
iquito deleted the patch-1 branch December 15, 2025 08:51
@stof

stof commented Dec 15, 2025

Copy link
Copy Markdown
Member

@iquito for patch releases, the splitter creates tags only for subtree repos that have changed since the previous release. That's expected.

@xabbuh

xabbuh commented Dec 15, 2025

Copy link
Copy Markdown
Contributor

@stof The issue is that this PR touched a file from the twig/twig package, the tag was also created (see https://github.com/twigphp/Twig/releases/tag/v3.22.2) but it is not listed on Packagist: https://packagist.org/packages/twig/twig

@iquito

iquito commented Dec 15, 2025

Copy link
Copy Markdown
Contributor Author

It might also be a Packagist issue, I am not sure, but I thought it might be worth it to find out why there is no new release.

@stof

stof commented Dec 15, 2025

Copy link
Copy Markdown
Member

@fabpot could you check the github webhook setup ?

packagist.org was showing the last update date of twig/twig on November 30th until I clicked the "Update now" button (which made the 3.22.2 tag appear)

@fabpot

fabpot commented Dec 15, 2025

Copy link
Copy Markdown
Contributor

Fixed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

5 participants