improve code style

This commit is contained in:
Daniel Seifert 2024-01-31 21:17:51 +01:00
parent 8345a843c3
commit b58f1b4156
Signed by: DanielS
GPG Key ID: 8A7C4C6ED1915C6F
6 changed files with 35 additions and 25 deletions

View File

@ -27,7 +27,8 @@
},
"require-dev": {
"d3/testingtools": "^1.0",
"phpunit/phpunit": "^9.6"
"phpunit/phpunit": "^9.6",
"friendsofphp/php-cs-fixer": "~3.13.0"
},
"autoload": {
"psr-4": {
@ -38,6 +39,8 @@
]
},
"scripts": {
"php-cs-fixer": "./vendor/bin/php-cs-fixer fix --config=vendor/d3/oxid-dic-handler/.php-cs-fixer.php",
"phpunit": "XDEBUG_MODE=coverage ./vendor/bin/phpunit --bootstrap=source/bootstrap.php --config=vendor/d3/oxid-dic-handler/tests/"
}
}

View File

@ -31,7 +31,7 @@ class d3DicHandler implements d3DicHandlerInterface
protected static Container|null $_instance = null;
public static array $circularReferenceMethodNames = [
'getViewConfig'
'getViewConfig',
];
/**
@ -46,8 +46,7 @@ class d3DicHandler implements d3DicHandlerInterface
$caller = $trace[1];
$functionName = $caller['function'];
if (in_array(strtolower($functionName), array_map('strtolower', self::$circularReferenceMethodNames)))
{
if (in_array(strtolower($functionName), array_map('strtolower', self::$circularReferenceMethodNames))) {
throw oxNew(Exception::class, 'method '.$functionName." can't use DIC due the danger of circular reference");
}
@ -71,8 +70,7 @@ class d3DicHandler implements d3DicHandlerInterface
$caller = $trace[1];
$functionName = $caller['function'];
if (in_array(strtolower($functionName), array_map('strtolower', self::$circularReferenceMethodNames)))
{
if (in_array(strtolower($functionName), array_map('strtolower', self::$circularReferenceMethodNames))) {
throw oxNew(Exception::class, 'method '.$functionName." can't use DIC due the danger of circular reference");
}
@ -117,7 +115,8 @@ class d3DicHandler implements d3DicHandlerInterface
public function d3GetFileLoader(ContainerBuilder $container): YamlFileLoader
{
/** @var YamlFileLoader $fileLoader */
$fileLoader = oxNew(YamlFileLoader::class,
$fileLoader = oxNew(
YamlFileLoader::class,
$container,
oxNew(FileLocator::class, d3DicUtilities::getVendorDir())
);
@ -167,7 +166,9 @@ class d3DicHandler implements d3DicHandlerInterface
*/
public function buildContainer(bool $compileAndDump = true): Container
{
if ((bool) Registry::get( ConfigFile::class)->getVar( 'iDebug')) startProfile(__METHOD__);
if ((bool) Registry::get(ConfigFile::class)->getVar('iDebug')) {
startProfile(__METHOD__);
}
$config = $this->d3GetConfig();
@ -186,12 +187,14 @@ class d3DicHandler implements d3DicHandlerInterface
if ($this->isNotInTest()) {
$dumper = new PhpDumper($container);
file_put_contents($this->d3GetCacheFilePath(), $dumper->dump(array('class' => 'd3DIContainerCache')));
file_put_contents($this->d3GetCacheFilePath(), $dumper->dump(['class' => 'd3DIContainerCache']));
}
}
}
if ((bool) Registry::get( ConfigFile::class)->getVar( 'iDebug')) stopProfile(__METHOD__);
if ((bool) Registry::get(ConfigFile::class)->getVar('iDebug')) {
stopProfile(__METHOD__);
}
return $container;
}
@ -204,10 +207,14 @@ class d3DicHandler implements d3DicHandlerInterface
/**
* clone
*/
public function __clone() {}
public function __clone()
{
}
/**
* constructor
*/
public function __construct() {}
public function __construct()
{
}
}

View File

@ -23,11 +23,11 @@ class definitionFileContainer
public const TYPE_YAML = 'yml';
protected array $definitionFiles = [
self::TYPE_YAML => []
self::TYPE_YAML => [],
];
protected array $allowedTypes = [
self::TYPE_YAML
self::TYPE_YAML,
];
public function __construct()