John Chandler avatar John Chandler committed a78ab6d

Fixed bug recognising include/require call with brackets

Comments (0)

Files changed (3)

qadpid/hierarchy.py

             dependencies = []
             for dep_type, dep_filepath in self.parser.parse( self.reader(filepath) ):
                 dependencies.append( ( dep_type, os.path.normpath( os.path.join(dirpath, dep_filepath) ) ) )
-                
             self.hierarchy[ filepath ] = dependencies
 """
 import re
 
-INCLUDE_RE = re.compile( '''(include|require)(?:_once)? ["']([^"']+)["']''' )
+INCLUDE_RE = re.compile( r'''(include|require)(?:_once)?[ (]["']([^"']+)["']''' )
 
 class PHPFileParser( object ):
     """ PHP File Parser """

tests/test_parser.py

         """ Test for presence of one require_once statement """
         self.assertEquals( self.parser.parse('require_once "foo.php"'), [ ("require", "foo.php")] )
 
+    def test_parse_include_brackets( self ):
+        """ Test for presence of include with brackets """
+        self.assertEquals( self.parser.parse("include_once('includes/foo.php');"), [ ("include", "includes/foo.php") ] )
+
+    def test_parse_require_brackets( self ):
+        """ Test for presence of require with brackets """
+        self.assertEquals( self.parser.parse("require_once('includes/foo.php');"), [ ("require", "includes/foo.php") ] )
+
     def test_parse_multiple_includes( self ):
         """ Test for presence of multiple include statements """
         php_code = '''
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.