phan / phan/phan

PhanRedefineFunctionInternal while testing with `function_exists`

Open
#4,039 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
PHP
Stars
5.6k
Forks
365
Avg merge
1h 25m
Merged PRs (30d)
6

Description

Phan 3.0.3

PhanRedefineFunctionInternal Function curl_file_create defined at tests/testfunctionexists.txt:3 was previously defined internally

The test !function_exists(...) should avoid this warning.

if (!function_exists('curl_file_create')) {
    function curl_file_create($filename, $mimetype = '', $postname = '') {
        return "@$filename;filename="
        . ($postname ?: basename($filename))
        . ($mimetype ? ";type=$mimetype" : '');
    }
}

https://github.com/phan/phan/blob/f638db25e0c0830f7f93e9ed538a30030c7332ec/src/Phan/Plugin/Internal/CallableParamPlugin.php#L176 seems to handle a similar exception

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 with the reproduction in tests/testfunctionexists.txt and inspect the similar exception handling at src/Phan/Plugin/Internal/CallableParamPlugin.php:176. Reproduce the function_exists guard, then trace the internal-function redefinition warning and confirm that the warning is no longer reported for this pattern.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.