Skip to content
This repository has been archived by the owner on Sep 24, 2020. It is now read-only.

[Bug] False positive list(array.illegal_offset_type/undefined-variable/unused-variable) #298

Closed
algo13 opened this issue Jan 11, 2017 · 7 comments

Comments

@algo13
Copy link
Contributor

algo13 commented Jan 11, 2017

<?php
class C
{
    // Notice:  Illegal array offset type unknown for key $key. [array.illegal_offset_type]
    public function testForeach(array $ary)
    {
        foreach ($ary as $key => $value) {
            $ary[$key] = 1;
        }
    }
    // Notice:  You are trying to use an undefined variable $_SERVER [undefined-variable]
    public function testUndefinedSuperglobals($subject)
    {
        sprintf('%s', implode(' ', $_SERVER['argv']));
    }
    // Warning:  Unused variable $var in method testUnusedInIssetInFetch() [unused-variable]
    public function testUnusedInIssetInFetch(array $ary)
    {
        $var = 0;
        isset($ary[$var]);
    }
    // Warning:  Unused variable $thisClass in method testUnusedInNewOp() [unused-variable]
    public function testUnusedInNewOp($value)
    {
        $thisClass = get_class($this);
        return new $thisClass($value);
    }
}
@ovr
Copy link
Owner

ovr commented Jan 15, 2017

Fixed this issue:

    // Notice:  You are trying to use an undefined variable $_SERVER [undefined-variable]
    public function testUndefinedSuperglobals($subject)
    {
        sprintf('%s', implode(' ', $_SERVER['argv']));
    }

refs 64a2881

ovr added a commit that referenced this issue Jan 15, 2017
@ovr
Copy link
Owner

ovr commented Jan 15, 2017

Fix isssue with the code above:

    public function testUnusedInIssetInFetch(array $ary)
    {
        $var = 0;
        isset($ary[$var]);
    }

refs be44673

ovr added a commit that referenced this issue Jan 15, 2017
@ovr
Copy link
Owner

ovr commented Jan 15, 2017

Fix issue for code

    // Warning:  Unused variable $thisClass in method testUnusedInNewOp() [unused-variable]
    public function testUnusedInNewOp($value)
    {
        $thisClass = get_class($this);
        return new $thisClass($value);
    }

refs 8bad524

@ovr
Copy link
Owner

ovr commented Jan 15, 2017

Fix issue for code:

    // Notice:  Illegal array offset type unknown for key $key. [array.illegal_offset_type]
    public function testForeach(array $ary)
    {
        foreach ($ary as $key => $value) {
            $ary[$key] = 1;
        }
    }

refs 3200a40

@ddmler
Copy link
Collaborator

ddmler commented Jan 21, 2017

@ovr binaryop\coalesce has same error as isset had.

@ovr
Copy link
Owner

ovr commented Jan 24, 2017

@ovr binaryop\coalesce has same error as isset had.

@ddmler can you please provide a PR/fix for it?

Thanks

@algo13 algo13 changed the title [Bug] False positive list [Bug] False positive list(array.illegal_offset_type/undefined-variable/unused-variable) Jan 28, 2017
@algo13
Copy link
Contributor Author

algo13 commented Jan 28, 2017

@ovr Thank you for many fixed !!
@ddmler This issue contained many issues.
To avoid confusion in the history, moved the remaining two issues.(#313, #314)

@algo13 algo13 closed this as completed Jan 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants