Skip to content

assert() failure errors do not correctly handle ASTs with strings containing NUL #22290

Closed

Description

@TimWolla

Description

The following code:

<?php

try {
	$string = "Foo\x00bar";
	assert(!str_contains($string, "\x00"));
} catch (Error $e) {
	echo $e->getMessage(), PHP_EOL;
}

Resulted in this output:

assert(!str_contains($string, '

But I expected this output instead: The closing ')); should not be cut off. Ideally the NUL byte would be output in escaped form.

PHP Version

PHP 8.6.0-dev (cli) (built: Jun 13 2026 14:01:23) (NTS DEBUG)
Copyright © The PHP Group and Contributors
Zend Engine v4.6.0-dev, Copyright © Zend by Perforce
    with Zend OPcache v8.6.0-dev, Copyright ©, by Zend by Perforce

Operating System

No response

Activity

  1. self-assigned this
    on Jun 16, 2026
  2. added a commit that references this issue on Jun 17, 2026
    f3cf2f4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions