method analyze documentation in bbn\Parsers\Php
Function that analyzes the class by returning the non-detailed information
function(string $class, $type = false)
{
$ok = true;
try {
$ref = new \ReflectionClass($class);
}
catch (\Exception $e) {
throw new \Exception($e->getMessage());
}
if ($ok) {
$fs = new System();
$tmp = $ref->getFileName();
$file = $tmp && $fs->isFile($tmp) ? $tmp : null;
$arr = [
'name' => $class,
'file' => $file,
'parents' => [],
'isAnonymous' => $ref->isAnonymous(),
'isCloneable' => $ref->isCloneable(),
'isFinal' => $ref->isFinal(),
'isInstantiable' => $ref->isInstantiable(),
'isInternal' => $ref->isInternal(),
'isIterateable' => $ref->isIterateable(),
'isUserDefined' => $ref->isUserDefined(),
'methods' => $this->addMethods($ref, $type, $file),
'properties' => [],
'traits' => [],
'unused' => []
];
$props = $ref->getProperties();
if (!empty($props)) {
foreach ($props as $prop) {
$type_prop = false;
if ($prop->isPublic()) {
$type_prop = 'public';
}
elseif ($prop->isPrivate()) {
$type_prop = 'private';
}
elseif ($prop->isProtected()) {
$type_prop = 'protected';
}
elseif ($prop->isStatic()) {
$type_prop = 'static';
}
if (!empty($type_prop)) {
$arr['properties'][$type_prop][] = $prop->getName();
}
}
}
//for parents
$parents = $ref->getParentClass();
if (!empty($parents)) {
foreach ($parents as $parent) {
$arr['parents'][$parent] = $this->analyze($parent, 'parent');
foreach ($arr['parents'][$parent]['methods'] as $i => $m) {
if (count($m)) {
$arr['methods'][$i] = array_merge($m, $arr['methods'][$i]);
}
}
}
}
//for traits
$traits = $ref->getTraitNames();
if (!empty($traits)) {
foreach ($traits as $trait) {
$arr['traits'][$trait] = $this->analyze($trait, 'trait');
foreach ($arr['traits'][$trait]['methods'] as $i => $m) {
if (count($m)) {
$arr['methods'][$i] = array_merge($arr['methods'][$i], $m);
}
}
}
}
//for interfaces
if ($interfaces = $ref->getInterfaceNames()) {
foreach ($interfaces as $interface) {
$arr['interfaces'][$interface] = $this->analyze($interface, 'interface');
foreach (array_keys($arr['interfaces'][$interface]['methods']) as $i) {
if (isset($arr['methods'][$i]['interfaces'])) {
$arr['methods'][$i]['interfaces'][] = $interface;
}
else {
$arr['methods'][$i]['interfaces'] = [$interface];
}
}
}
}
if (!empty($arr['methods']['private'])) {
foreach ($arr['methods']['private'] as $name => $priv) {
$str = ($priv['static'] ? '::' : '->') . $name;
if (X::indexOf($fs->getContents($arr['file']), $str) === -1) {
$arr['unused'][] = $arr['name'] . '::' . $priv['name'];
}
}
}
return $arr;
}
return null;
}
Function that analyzes the class by returning the non-detailed information BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way
This website uses cookies to ensure you get the best experience on our website.
© 2011-2025
BBN Solutions