php / php/php-src

do_operation ZEND_BOOL_NOT not invoked

Open
#13,867 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Status: Needs Triage
Dominant language
C
Stars
40.4k
Forks
8.1k
Avg merge
2d 13h
Merged PRs (30d)
96

Description

Description

The object handler do_operation is not invoked for the opcode ZEND_BOOL_NOT.

With the supporting code for PHP 8.2 ext/zend_test https://github.com/ranvis/php-src/commit/2c542eef94de90b20b6e8d86ebeafee5408b12c9,
the following code:

<?php
$a = new DoOperationNoCast(5);
var_dump(!$a);

Resulted in this output:

bool(false)

But I expected this output instead:

object(DoOperationNoCast)#2 (1) {
  ["val":"DoOperationNoCast":private]=>
  int(0)
}

The code !$obj is evaluated as !(bool)$obj instead.
This appears to have been introduced on PHP 7.0, the commit https://github.com/php/php-src/commit/e6180ebb640408c7ded804f5f65282122a059ddb.

PHP Version

dev-PHP-8.2

Operating System

irrelevant

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the PHP interpreter's handling of the ZEND_BOOL_NOT opcode and the object handler do_operation, using the ext/zend_test supporting code and the linked PHP 7.0 change as context. Run the provided DoOperationNoCast example on PHP 8.2 and verify that the handler is invoked and the result matches the expected object output.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, php
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.