MilkCore

FileAnalyzer
in package

Analyzes individual PHP files to extract classes with correct namespace

Table of Contents

Methods

analyze_file()  : array<string|int, mixed>
Analyzes a PHP file and returns all necessary information
extract_file_info()  : array<string|int, mixed>
Extracts complete information from the file (namespace, use statements, classes)
find_class_in_file()  : array<string|int, mixed>|null
Finds a specific class in a file
to_absolute_path()  : string
Converts a relative path to an absolute path with respect to MILK_DIR
to_relative_path()  : string
Converts an absolute path to a relative path with respect to MILK_DIR

Methods

analyze_file()

Analyzes a PHP file and returns all necessary information

public analyze_file(string $file_path) : array<string|int, mixed>
Parameters
$file_path : string

Absolute path of the file

Return values
array<string|int, mixed>

Array with namespace, use_statements and found classes

extract_file_info()

Extracts complete information from the file (namespace, use statements, classes)

public extract_file_info(string $content, string $file_path) : array<string|int, mixed>
Parameters
$content : string

File content

$file_path : string

File path

Return values
array<string|int, mixed>

Extracted information

find_class_in_file()

Finds a specific class in a file

public find_class_in_file(string $file_path, string $class_name) : array<string|int, mixed>|null
Parameters
$file_path : string

Path of the file

$class_name : string

Name of the class to search for (with or without namespace)

Return values
array<string|int, mixed>|null

Class information if found, null otherwise

to_absolute_path()

Converts a relative path to an absolute path with respect to MILK_DIR

public to_absolute_path(string $relative_path) : string
Parameters
$relative_path : string

Relative path

Return values
string

Absolute path

to_relative_path()

Converts an absolute path to a relative path with respect to MILK_DIR

public to_relative_path(string $absolute_path) : string
Parameters
$absolute_path : string

Absolute path

Return values
string

Relative path


        
On this page

Search results