diff --git a/lib/PHPCfg/Printer.php b/lib/PHPCfg/Printer.php index fcd4fe7..100c743 100755 --- a/lib/PHPCfg/Printer.php +++ b/lib/PHPCfg/Printer.php @@ -129,6 +129,9 @@ protected function renderOp(Op $op) if ($op instanceof Op\Expr\Param) { $result .= "\n declaredType: " . $this->indent($this->renderType($op->declaredType)); } + if ($op instanceof Op\Expr\Include_) { + $result .= "\n type: " . $this->indent($this->renderIncludeType($op->type)); + } foreach ($op->getVariableNames() as $varName) { $vars = $op->{$varName}; @@ -291,6 +294,22 @@ protected function renderType(?Op\Type $type): string throw new \LogicException("Unknown type rendering: " . get_class($type)); } + protected function renderIncludeType(int $type): string + { + switch($type) { + case 1: + return "include"; + case 2: + return "include_once"; + case 3: + return "require"; + case 4: + return "require_once"; + default: + throw new \LogicException("Unknown include type rendering: " .$type); + } + } + protected function renderFlags(Op\Stmt $stmt): string { $result = ''; diff --git a/test/code/include.test b/test/code/include.test new file mode 100755 index 0000000..99b13f6 --- /dev/null +++ b/test/code/include.test @@ -0,0 +1,26 @@ + + result: Var#2 + Expr_Include + type: include_once + expr: Var#1<$foo> + result: Var#3 + Expr_Include + type: require + expr: Var#1<$foo> + result: Var#4 + Expr_Include + type: require_once + expr: Var#1<$foo> + result: Var#5 + Terminal_Return + +