Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions lib/PHPCfg/Printer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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 = '';
Expand Down
26 changes: 26 additions & 0 deletions test/code/include.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
include($foo);
include_once($foo);
require($foo);
require_once($foo);
-----
Block#1
Expr_Include
type: include
expr: Var#1<$foo>
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