Skip to content

Commit

Permalink
update service load order (#1444)
Browse files Browse the repository at this point in the history
- update service load order
- and add static analyse label
  • Loading branch information
gennadigennadigennadi authored Nov 21, 2024
1 parent 45019af commit 72d9868
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 19 deletions.
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"name": "qossmic/deptrac",
"description": "Deptrac is a static code analysis tool that helps to enforce rules for dependencies between software layers.",
"keywords": [
"static analysis"
],
"license": "MIT",
"require": {
"php": "^8.1",
Expand Down
Binary file modified deptrac.phar
Binary file not shown.
22 changes: 11 additions & 11 deletions deptrac.phar.asc
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
-----BEGIN PGP SIGNATURE-----

iQGzBAABCAAdFiEEl06QM0FNfyvJ/h5q1PBultG9A3sFAmcd+R4ACgkQ1PBultG9
A3s3PAv5AZN4ttFoX9Jmxae+M+dNZMFXXAwXrOIKaD5dWjaFBlTxJDxStmTMfajU
Dfbc9kJ+0O9KEB7fWWTUy+3hBYuF/pnSY2XM/tDEBwl/jgdIcYLiuxhyTbD8BX74
TIEk3Si7XiXFwK8R21IakzhMxvboy6JnTOqSd9v7ms2+CwsJX3wzTd+m9QUG1U2V
lDwHinNcuM2WCfv65SbvPgs7ZPteJl8oEyn5OzDrAW3HGzgA4OWN+dJbOZCO1gJ8
RgO3DiTA3bUUbxLG+sQj9bbWYMejuYXkzINB87NcF4hVz+cJjWq4C5I+Nwd7cVHa
4z1UdCG4F6g0GrWpIzLSYZajLPuy4Ihzj+M/qOx1niB151R72rOhswgpwGFgpfQe
NgThneleCDbmjOs93vzrJknbU4SHksvV3lQaADM6uft5behWxI1tEVJm2uWN4h/L
mhr71elV/vszQ7WSh2NK3KtbFyqsggmDeTEQmOSiQcMZqgbukB9LSoN6WqQZOls0
wrOKTdTl
=iiMr
iQGzBAABCAAdFiEEl06QM0FNfyvJ/h5q1PBultG9A3sFAmc/lPAACgkQ1PBultG9
A3uSGwwAimApAUZuIR4Jpo6usGhOBLrYgBG6JQUc08VasMFjbuUHSvACAZpAHruw
nN3qNSpCA8h4shie0tYzEzbRDkwUe/SjTIm7mdC3jsFgHvnuUfZNNTWPf47fIQ16
zflsqnfJjz8PioH8llzBc6wcxHLi52ECNZj1y5Oer1EB1/5QhIW7DAAyKn/3JOVd
K42DtQmvpHdbFDdphTycy/nQhIsKdgrwtZWBhpeLdAjyDGbu6cuWz1/0/ZdGcWaR
3Qa12llxl6Q4PCftTqkY9eABYcU4IO+Zm4AImVaY+aadXqDKef5P7D0KlKIxsHt5
pONc4EL0M4iTS8KsyLC177zL5KZSieVB5Kd+DDeieOmvvhIGEHYQENWy2cDlf0Zn
1EPHytMuwAkYeU3CeZ7Klr94a2a8pfS8enfwMHHphuGf6SX4MlU4SD8j46GqsoAg
gLg2yAMfyb2SANip7Hf17HCoGAKCW+EeIo/Rz3+0AHSX2g3RR9QNPFhO7JcxjXbZ
T9AEEsX4
=sYs9
-----END PGP SIGNATURE-----
22 changes: 15 additions & 7 deletions src/Supportive/DependencyInjection/ServiceContainerBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ final class ServiceContainerBuilder
{
private ?SplFileInfo $configFile = null;
private ?SplFileInfo $cacheFile = null;
private const DEPTRAC_INTERNAL_CONFIG_PATH = __DIR__ . '/../../../config';
public function __construct(private readonly string $workingDirectory)
{
}
Expand Down Expand Up @@ -64,6 +65,7 @@ public function build(string|false|null $cacheOverride, bool $clearCache) : Cont
self::registerCompilerPasses($container);
$container->registerExtension(new \Qossmic\Deptrac\Supportive\DependencyInjection\DeptracExtension());
$container->setParameter('projectDirectory', $this->workingDirectory);
self::loadServices($container);
if (null !== $this->configFile) {
self::loadConfiguration($container, $this->configFile);
}
Expand All @@ -80,7 +82,9 @@ public function build(string|false|null $cacheOverride, bool $clearCache) : Cont
}
$this->withCache($cache);
}
self::loadServices($container, $this->cacheFile);
if (null !== $this->cacheFile) {
self::loadCache($container, $this->cacheFile);
}
$container->compile(\true);
return $container;
}
Expand All @@ -90,20 +94,24 @@ private static function registerCompilerPasses(ContainerBuilder $container) : vo
$container->addCompilerPass(new RegisterListenersPass());
}
/**
* @throws CacheFileException
* @throws CannotLoadConfiguration
*/
private static function loadServices(ContainerBuilder $container, ?SplFileInfo $cacheFile) : void
private static function loadServices(ContainerBuilder $container) : void
{
$loader = new PhpFileLoader($container, new FileLocator([__DIR__ . '/../../../config']));
$loader = new PhpFileLoader($container, new FileLocator([self::DEPTRAC_INTERNAL_CONFIG_PATH]));
try {
$loader->load('services.php');
} catch (Exception $exception) {
throw CannotLoadConfiguration::fromServices('services.php', $exception->getMessage());
}
if (!$cacheFile instanceof SplFileInfo) {
return;
}
}
/**
* @throws CacheFileException
* @throws CannotLoadConfiguration
*/
private static function loadCache(ContainerBuilder $container, SplFileInfo $cacheFile) : void
{
$loader = new PhpFileLoader($container, new FileLocator([self::DEPTRAC_INTERNAL_CONFIG_PATH]));
if (!\file_exists($cacheFile->getPathname())) {
$dirname = $cacheFile->getPath() ?: '.';
if (!\is_dir($dirname) && \mkdir($dirname . '/', 0777, \true) && !\is_dir($dirname)) {
Expand Down
Loading

0 comments on commit 72d9868

Please sign in to comment.