code-format

pull/1/head
韩天峰 8 months ago
parent a085c33208
commit 3c89f98296
  1. 2
      src/Php/ArgInfo.php
  2. 2
      src/Php/Extractor.php
  3. 14
      src/Php/FileScanner.php
  4. 2
      src/Php/FileSorter.php
  5. 2
      src/Php/FunctionDef.php
  6. 3
      src/Php/RedoException.php
  7. 9
      src/Php/Reflection.php
  8. 3
      src/Php/Unsupported.php

@ -7,4 +7,4 @@ class ArgInfo
public string $name; public string $name;
public string $type; public string $type;
public string $default = ''; public string $default = '';
} }

@ -611,4 +611,4 @@ class Extractor
return $md; return $md;
} }
} }

@ -9,15 +9,15 @@ class FileScanner
private string $directory; private string $directory;
private array $excludePatterns; private array $excludePatterns;
const array PHP_EXT = ['php']; public const array PHP_EXT = ['php'];
const array CPP_EXT = ['cpp', 'cxx', 'cc']; public const array CPP_EXT = ['cpp', 'cxx', 'cc'];
public function __construct(string $directory) public function __construct(string $directory)
{ {
if (!is_dir($directory)) { if (!is_dir($directory)) {
throw new \InvalidArgumentException("Directory does not exist: $directory"); throw new \InvalidArgumentException("Directory does not exist: $directory");
} }
$this->directory = rtrim($directory, DIRECTORY_SEPARATOR); $this->directory = rtrim($directory, DIRECTORY_SEPARATOR);
$this->excludePatterns = []; $this->excludePatterns = [];
} }
@ -32,12 +32,12 @@ class FileScanner
return pathinfo($path, PATHINFO_EXTENSION); return pathinfo($path, PATHINFO_EXTENSION);
} }
static function isPhpFile(string $file): bool public static function isPhpFile(string $file): bool
{ {
return in_array(self::getFileExt($file), self::PHP_EXT); return in_array(self::getFileExt($file), self::PHP_EXT);
} }
static function isCppFile(string $file): bool public static function isCppFile(string $file): bool
{ {
return in_array(self::getFileExt($file), self::CPP_EXT); return in_array(self::getFileExt($file), self::CPP_EXT);
} }
@ -77,7 +77,7 @@ class FileScanner
$iterator = new \RecursiveIteratorIterator( $iterator = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator($this->directory, FilesystemIterator::SKIP_DOTS) new \RecursiveDirectoryIterator($this->directory, FilesystemIterator::SKIP_DOTS)
); );
foreach ($iterator as $file) { foreach ($iterator as $file) {
if ($file->isFile()) { if ($file->isFile()) {
if (self::isPhpFile($file)) { if (self::isPhpFile($file)) {
@ -99,4 +99,4 @@ class FileScanner
{ {
return fnmatch($pattern, $path, FNM_PATHNAME); return fnmatch($pattern, $path, FNM_PATHNAME);
} }
} }

@ -91,4 +91,4 @@ class FileSorter
return array_unique($files); return array_unique($files);
} }
} }

@ -9,4 +9,4 @@ class FunctionDef
public string $params; public string $params;
public string $returnType; public string $returnType;
public int $argCountRequired = 0; public int $argCountRequired = 0;
} }

@ -4,5 +4,4 @@ namespace PhpAot\Php;
class RedoException extends \RuntimeException class RedoException extends \RuntimeException
{ {
}
}

@ -10,11 +10,12 @@ class Reflection
{ {
private static array $functions = []; private static array $functions = [];
static function getFunction(string $fn) public static function getFunction(string $fn)
{ {
if (!isset(self::$functions[$fn])) { if (!isset(self::$functions[$fn])) {
try { try {
$ref = new ReflectionFunction($fn);; $ref = new ReflectionFunction($fn);
;
} catch (\ReflectionException $e) { } catch (\ReflectionException $e) {
return null; return null;
} }
@ -23,7 +24,7 @@ class Reflection
return self::$functions[$fn]; return self::$functions[$fn];
} }
static function getFunctionReturnType(string $fn): ?string public static function getFunctionReturnType(string $fn): ?string
{ {
$func = self::getFunction($fn); $func = self::getFunction($fn);
if (!$func) { if (!$func) {
@ -51,4 +52,4 @@ class Reflection
} }
return $args[$index]; return $args[$index];
} }
} }

@ -4,5 +4,4 @@ namespace PhpAot\Php;
class Unsupported extends \RuntimeException class Unsupported extends \RuntimeException
{ {
}
}

Loading…
Cancel
Save