Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
[ci skip] [skip ci]
  • Loading branch information
luceos authored and StyleCIBot committed May 28, 2020
1 parent f19bbd6 commit 4cda9bb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
5 changes: 3 additions & 2 deletions src/Extension/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,10 @@ public function getIcon()
}

/**
* Get the list of flarum extensions that this extension depends on
* Get the list of flarum extensions that this extension depends on.
*/
public function getFlarumExtensionDependencies() {
public function getFlarumExtensionDependencies()
{
return Arr::get($this->composerJson, 'extra.flarum-extension.dependencies.extensions', []);
}

Expand Down
15 changes: 7 additions & 8 deletions src/Extension/ExtensionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,12 @@ public function enable($name)
$missingDependencies = [];
$enabled = $this->getEnabled();
foreach ($extension->getFlarumExtensionDependencies() as $dependency) {
if (!in_array($dependency, $enabled)) {
if (! in_array($dependency, $enabled)) {
$missingDependencies[] = $dependency;
}
}

if (!empty($missingDependencies)) {
if (! empty($missingDependencies)) {
throw new Exception\MissingDependenciesException($extension, $missingDependencies);
}

Expand Down Expand Up @@ -190,7 +190,7 @@ public function disable($name)
}
}

if (!empty($dependentExtensions)) {
if (! empty($dependentExtensions)) {
throw new DependentExtensionsException($extension, $dependentExtensions);
}

Expand Down Expand Up @@ -391,7 +391,6 @@ public static function resolveExtensionOrder($extensionList)
$pendingQueue = [];
$inDegreeCount = []; // How many extensions are dependent on a given extension?

foreach ($extensionList as $extension) {
$extensionIdMapping[$extension->getId()] = $extension;
$extensionGraph[$extension->getId()] = $extension->getFlarumExtensionDependencies();
Expand All @@ -402,7 +401,7 @@ public static function resolveExtensionOrder($extensionList)
}

foreach ($extensionList as $extension) {
if (!array_key_exists($extension->getId(), $inDegreeCount)) {
if (! array_key_exists($extension->getId(), $inDegreeCount)) {
$inDegreeCount[$extension->getId()] = 0;
$pendingQueue[] = $extension->getId();
}
Expand All @@ -416,7 +415,7 @@ public static function resolveExtensionOrder($extensionList)
$inDegreeCount[$dependency] -= 1;

if ($inDegreeCount[$dependency] === 0) {
if (!array_key_exists($dependency, $extensionGraph)) {
if (! array_key_exists($dependency, $extensionGraph)) {
// Missing Dependency
$missingDependencies[$activeNode] = array_merge(
Arr::get($missingDependencies, $activeNode, []),
Expand All @@ -430,10 +429,10 @@ public static function resolveExtensionOrder($extensionList)
}

$validOutput = array_filter($output, function ($extension) use ($missingDependencies) {
return !array_key_exists($extension, $missingDependencies);
return ! array_key_exists($extension, $missingDependencies);
});

$validExtensions = array_reverse(array_map(function($extensionId) use ($extensionIdMapping) {
$validExtensions = array_reverse(array_map(function ($extensionId) use ($extensionIdMapping) {
return $extensionIdMapping[$extensionId];
}, $validOutput)); // Reversed as required by Kahn's algorithm.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public function setUp()
$this->circular2 = new FakeExtension('circular2', ['circular1']);
}


/** @test */
public function works_with_empty_set()
{
Expand Down

0 comments on commit 4cda9bb

Please sign in to comment.