PHP Function List breaks if mismatch curly brace (eg. in a comment)

MrP
2013-10-15
2014-02-01
  • MrP

    MrP - 2013-10-15

    1. The PHP Function List appears empty if there is an opening curly brace inside a class method with no corresponding closing brace. This would ordinarily be invalid PHP, however, the opening curly brace could appear as part of a comment, as in the following example, and this would cause the function list to break.

    class MyClass {
        public function funcA($state) {
            // if (!$state) {
            if ($state) {
                return 'A';
            }
        }
    }
    

    Solution: Either remove the opening curly brace from the comment, or include a matching closing brace.

    It does not appear to be a problem if the curly brace mismatch is inside a global function - the function list is still populated successfully.

    2. PHP Global function definitions are not picked up if there is space between the function name and the opening parenthesis. However, class methods are picked up OK in this instance.

    In the following example, MyClass::funcA is picked up OK, however, the global funcB is ignored.

    class MyClass {
        public function funcA ($state) {
            if ($state) {
                return 'A';
            }
        }
    }
    function funcB ($state) {
        if ($state) {
            return 'B';
        }
    }
    

    Solution: Remove the space before the opening parenthesis in the function definition.

    Using Notepad++ 6.5

     
    Last edit: MrP 2013-10-15
  • MrP

    MrP - 2014-02-01

    The PHP function list also breaks if you have a class definition that implements an interface. None of the methods are picked up in this instance.

    ~~~~~
    class MyClass implements MyBaseClass {
    / Methods are not picked up by Function List /
    }

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks