Skip to content

Commit

Permalink
PHP: report class inheritance
Browse files Browse the repository at this point in the history
  • Loading branch information
b4n committed Apr 12, 2013
1 parent 853593a commit a51f1a4
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions php.c
Expand Up @@ -292,7 +292,7 @@ static void makeSimplePhpTag (tokenInfo *const token, phpKind kind, accessType a
}
}

static void makeClassTag (tokenInfo *const token, implType impl)
static void makeClassTag (tokenInfo *const token, vString *const inheritance, implType impl)
{
if (PhpKinds[K_CLASS].enabled)
{
Expand All @@ -302,6 +302,8 @@ static void makeClassTag (tokenInfo *const token, implType impl)

if (impl != IMPL_UNDEFINED)
e.extensionFields.implementation = implToString (impl);
if (vStringLength (inheritance) > 0)
e.extensionFields.inheritance = vStringValue (inheritance);

makeTagEntry (&e);
}
Expand Down Expand Up @@ -683,29 +685,41 @@ static boolean parseClass (tokenInfo *const token)
boolean readNext = TRUE;
implType impl = CurrentStatement.impl;
tokenInfo *name;
vString *inheritance = NULL;

readToken (token);
if (token->type != TOKEN_IDENTIFIER)
return FALSE;

name = newToken ();
copyToken (name, token, TRUE);
makeClassTag (name, impl);

/* skip over possible "extends FOO, BAR" */
inheritance = vStringNew ();
/* skip until the open bracket and assume every identifier (not keyword)
* is an inheritance (like in "class Foo extends Bar implements iA, iB") */
do
{
readToken (token);

if (token->type == TOKEN_IDENTIFIER)
{
if (vStringLength (inheritance) > 0)
vStringPut (inheritance, ',');
vStringCat (inheritance, token->string);
}
}
while (token->type != TOKEN_EOF &&
token->type != TOKEN_OPEN_CURLY);

makeClassTag (name, inheritance, impl);

if (token->type == TOKEN_OPEN_CURLY)
enterScope (token, name->string, K_CLASS);
else
readNext = FALSE;

deleteToken (name);
vStringDelete (inheritance);

return readNext;
}
Expand Down

0 comments on commit a51f1a4

Please sign in to comment.