Skip to content

Commit a980ee9

Browse files
committed
Added reduction of class names to a single form, without a backslash at the beginning of the line.
Improvement has been made that does not allow adding a class dependency on itself.
1 parent 346aee5 commit a980ee9

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/Model/UnitOfCode.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ private function __construct(string $name, Type $type, ?string $path = null, ?Co
6363
*/
6464
public static function create(string $fullName, ?Component $component = null, ?string $path = null): self
6565
{
66+
//Приведение названий к единому виду, без обратного слэша в начале
67+
$fullName = trim($fullName, '\\');
68+
6669
$unitOfCode = self::$instances[$fullName] ?? null;
6770
if (!$unitOfCode) {
6871
$getElementPath = static function (string $fullName): ?string {
@@ -230,10 +233,15 @@ public function inputDependencies(?Component $component = null): array
230233
*/
231234
public function addInputDependency(self $unitOfCode): self
232235
{
236+
if ($unitOfCode === $this) {
237+
return $this;
238+
}
239+
233240
$this->inputDependencies[] = $unitOfCode;
234241
if (!in_array($this, $unitOfCode->outputDependencies(), true)) {
235242
$unitOfCode->addOutputDependency($this);
236243
}
244+
237245
return $this;
238246
}
239247

@@ -264,10 +272,15 @@ public function outputDependencies(?Component $component = null): array
264272
*/
265273
public function addOutputDependency(self $unitOfCode): self
266274
{
275+
if ($unitOfCode === $this) {
276+
return $this;
277+
}
278+
267279
$this->outputDependencies[] = $unitOfCode;
268280
if (!in_array($this, $unitOfCode->inputDependencies(), true)) {
269281
$unitOfCode->addInputDependency($this);
270282
}
283+
271284
return $this;
272285
}
273286

0 commit comments

Comments
 (0)