* [misc] Move the open curly brace to the beginning of next line.

This commit is contained in:
liugang
2025-11-18 14:38:18 +08:00
parent 48de97b681
commit 2c66a07457
3 changed files with 35 additions and 16 deletions
+24 -12
View File
@@ -49,7 +49,8 @@ class baseDelegate
public function __get($name)
{
// 如果有实例,尝试从实例中获取属性
if (!is_null($this->instance) && property_exists($this->instance, $name)) {
if(!is_null($this->instance) && property_exists($this->instance, $name))
{
return $this->instance->$name;
}
@@ -70,7 +71,8 @@ class baseDelegate
public function __set($name, $value)
{
// 如果有实例,尝试写入实例属性
if (!is_null($this->instance) && property_exists($this->instance, $name)) {
if(!is_null($this->instance) && property_exists($this->instance, $name))
{
$this->instance->$name = $value;
return;
}
@@ -91,11 +93,13 @@ class baseDelegate
*/
public function __call(string $name, array $arguments)
{
if (is_null($this->instance)) {
if(is_null($this->instance))
{
throw new BadMethodCallException('The instance is not initialized.');
}
if (is_callable([$this->instance, $name])) {
if(is_callable([$this->instance, $name]))
{
return call_user_func_array([$this->instance, $name], $arguments);
}
@@ -115,42 +119,50 @@ class baseDelegate
public static function __callStatic(string $name, array $arguments)
{
$calledClass = get_called_class();
if (!property_exists($calledClass, 'className')) {
if(!property_exists($calledClass, 'className'))
{
throw new BadMethodCallException("The static property className does not exist in the class {$calledClass}.");
}
$className = $calledClass::$className;
if (empty($className)) {
if(empty($className))
{
throw new BadMethodCallException("The static property className is not set in the class {$calledClass}.");
}
if (!class_exists($className)) {
if(!class_exists($className))
{
throw new BadMethodCallException("The class {$className} does not exist.");
}
if (is_callable([$className, $name])) {
if(is_callable([$className, $name]))
{
return call_user_func_array([$className, $name], $arguments);
}
if (property_exists($className, $name) && count($arguments) === 1) {
if(property_exists($className, $name) && count($arguments) === 1)
{
// 支持静态属性的直接赋值
$className::$$name = $arguments[0];
return;
}
if (property_exists($className, $name) && count($arguments) === 0) {
if(property_exists($className, $name) && count($arguments) === 0)
{
// 支持静态属性的直接读取
return $className::$$name;
}
if (strpos($name, 'set') === 0 && property_exists($className, lcfirst(substr($name, 3))) && count($arguments) === 1) {
if(strpos($name, 'set') === 0 && property_exists($className, lcfirst(substr($name, 3))) && count($arguments) === 1)
{
// 支持静态属性的 set 方法
$property = lcfirst(substr($name, 3));
$className::$$property = $arguments[0];
return;
}
if (strpos($name, 'get') === 0 && property_exists($className, lcfirst(substr($name, 3))) && count($arguments) === 0) {
if(strpos($name, 'get') === 0 && property_exists($className, lcfirst(substr($name, 3))) && count($arguments) === 0)
{
// 支持静态属性的 get 方法
$property = lcfirst(substr($name, 3));
return $className::$$property;
+9 -3
View File
@@ -36,7 +36,9 @@ class phpExcel extends baseDelegate
try
{
return IOFactory::createReader($type);
} catch (ReaderException $e) {
}
catch (ReaderException $e)
{
throw $e;
}
}
@@ -46,7 +48,9 @@ class phpExcel extends baseDelegate
try
{
return IOFactory::createWriter($this->instance, ucfirst($type));
} catch (WriterException $e) {
}
catch (WriterException $e)
{
throw $e;
}
}
@@ -58,7 +62,9 @@ class phpExcel extends baseDelegate
$fileType = IOFactory::identify($file);
$reader = IOFactory::createReader($fileType);
return $fileType == 'Xls' || $fileType == 'Xlsx';
} catch (ReaderException $e) {
}
catch (ReaderException $e)
{
return false;
}
}
+2 -1
View File
@@ -23,7 +23,8 @@ class purifier extends baseDelegate
{
if(empty($config)) $config = $this->config;
$purifierConfig = HTMLPurifier_Config::createDefault();
foreach ($config as $key => $value) {
foreach($config as $key => $value)
{
$purifierConfig->set($key, $value);
}
$this->instance = new static::$className($purifierConfig);