16 $phpCode=\file_get_contents($filePathName);
17 return self::getClassNamespaceFromPhpCode($phpCode) .
'\\' . self::getClassNameFromPhpCode($phpCode);
21 return \str_replace(
"\\",
"\\\\", $classname);
31 if(!\is_array($parts)){
34 foreach ($parts as $part){
35 $resultArray=\array_merge($resultArray,\explode(
"\\", $part));
37 $resultArray=\array_diff($resultArray, [
""]);
38 return \implode(
"\\", $resultArray);
49 $classString=self::getClassFullNameFromFile($filePathName);
50 $object=
new $classString();
62 $phpCode=\file_get_contents($filePathName);
63 return self::getClassNamespaceFromPhpCode($phpCode);
67 $tokens=token_get_all($phpCode);
68 $count=\count($tokens);
72 while ( $i < $count ) {
74 if (\is_array($token) && $token[0] === T_NAMESPACE) {
76 while ( ++$i < $count ) {
77 if ($tokens[$i] ===
';') {
79 $namespace=\trim($namespace);
82 $namespace.=\is_array($tokens[$i]) ? $tokens[$i][1] : $tokens[$i];
103 $phpCode=\file_get_contents($filePathName);
104 return self::getClassNameFromPhpCode($phpCode);
109 $tokens=\token_get_all($phpCode);
110 $count=count($tokens);
111 for($i=2; $i < $count; $i++) {
112 if ($tokens[$i - 2][0] == T_CLASS && $tokens[$i - 1][0] == T_WHITESPACE && $tokens[$i][0] == T_STRING) {
113 $class_name=$tokens[$i][1];
114 $classes[]=$class_name;
117 if(isset($classes[0]))
123 if(\strpos($name,
"\\")===
false){
124 $name=$defaultNS.
"\\".$name;
130 return substr($classnameWithNamespace, strrpos($classnameWithNamespace,
'\\')+1);
static getClassFullNameFromFile($filePathName)
get the full name (name \ namespace) of a class from its file path result example: (string) "I\Am\The...
static getClassNameFromFile($filePathName)
get the class name form file path using token
static getClassNamespaceFromFile($filePathName)
get the class namespace form file path using token
static getNamespaceFromParts($parts)
Returns a cleanly namespace.
static getClassNameWithNS($defaultNS, $name)
static getClassNamespaceFromPhpCode($phpCode)
static cleanClassname($classname)
static getClassObjectFromFile($filePathName)
build and return an object of a class from its file path
static getClassNameFromPhpCode($phpCode)
static getClassSimpleName($classnameWithNamespace)