Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Commit

Permalink
More initial work
Browse files Browse the repository at this point in the history
  • Loading branch information
ircmaxell committed Oct 22, 2014
1 parent c2db7b8 commit 7544100
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
10 changes: 9 additions & 1 deletion lib/ReckiCT/Class_.php → lib/ReckiCT/Graph/Class_.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
<?php

namespace ReckiCT;
namespace ReckiCT\Graph;

use ReckiCT\Graph\Vertex\Method;

class Class_ {

protected $name;
protected $extends;
protected $implements = [];
protected $methods = [];
protected $properties = [];

public function __construct($name, $extends, array $implements) {
$this->name = $name;
Expand All @@ -26,4 +30,8 @@ public function getImplements() {
return $this->implements;
}

public function addMethod(Method $method) {
$this->methods[] = $method;
}

}
23 changes: 22 additions & 1 deletion lib/ReckiCT/Parser/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

namespace ReckiCT\Parser;

use ReckiCT\Graph\Class_;
use ReckiCT\Graph\Vertex;
use ReckiCT\Graph\Variable as JitVariable;
use ReckiCT\Graph\Constant as JitConstant;
Expand All @@ -32,6 +33,7 @@
use PhpParser\Node\Scalar;
use PhpParser\Node\Expr\Variable as AstVariable;
use PhpParser\Node\Stmt\Class_ as AstClass;
use PhpParser\Node\Stmt\ClassMethod as AstClassMethod;
use PhpParser\Node\Stmt\Function_ as AstFunction;
use Gliph\Graph\DirectedAdjacencyList;

Expand All @@ -46,7 +48,26 @@ public function addRule(Rule $rule)

public function parseClass(AstClass $ast)
{
throw new \BadMethodCallException("Not implemented yet");
var_dump($ast);
$implements = [];
foreach ($ast->implements as $interface) {
$implements[] = $interface->toString();
}
$class = new Class_(
$ast->namespacedName->toString(),
$ast->extends ? $ast->extends->toString() : null,
$implements
);

foreach ($ast->stmts as $stmt) {
switch (get_class($stmt)) {
case AstClassMethod::class:
break;
default:
throw new \LogicException("Unexpected child type found: " . get_class($stmt));
}
}
return $class;
}

public function parseFunction(AstFunction $ast)
Expand Down

0 comments on commit 7544100

Please sign in to comment.