php / php/php-src

Inconsistent use of E_WARNING and E_COMPILE_WARNING in zend_compile.c

Open
#18,510 2 comments 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 following code:

<?php

set_error_handler(function (int $errno, string $errstr) {
	var_dump($errno, $errstr);
}, E_ALL);

include('test7.php');

and

<?php

use Foo;

function foo(integer $foo) {
	
}

Resulted in this output:

int(2)
string(60) "The use statement with non-compound name 'Foo' has no effect"

Warning: "integer" will be interpreted as a class name. Did you mean "int"? Write "\integer" to suppress this warning in php-src/test7.php on line 5

But I expected this output instead:

Warning: The use statement with non-compound name 'Foo' has no effect in php-src/test7.php on line 3

Warning: "integer" will be interpreted as a class name. Did you mean "int"? Write "\integer" to suppress this warning in php-src/test7.php on line 5

or

int(2)
string(60) "The use statement with non-compound name 'Foo' has no effect"
int(2)
string(108) ""integer" will be interpreted as a class name. Did you mean "int"? Write "\integer" to suppress this warning"

The same applies to other warnings emitted during compilation.

PHP Version
git master
Operating System

No response

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

Reproduce the two warning examples using test7.php, then inspect the warning-emission paths in zend_compile.c. Compare how the non-compound use warning and the integer type warning are reported, and verify that compilation warnings consistently use the intended error-handler behavior.

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.