Skip to content

Commit

Permalink
Merge pull request #349 from dereuromark/remove-lying-alias
Browse files Browse the repository at this point in the history
Remove lying through annotation.
  • Loading branch information
dereuromark committed Mar 15, 2024
2 parents 37887de + 6189f40 commit 141f290
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 27 deletions.
23 changes: 0 additions & 23 deletions src/Annotator/ModelAnnotator.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Cake\Datasource\EntityInterface;
use Cake\Datasource\ResultSetInterface;
use Cake\ORM\Association\BelongsToMany;
use Cake\ORM\Association\HasMany;
use Cake\ORM\AssociationCollection;
use Cake\ORM\Table;
use Cake\ORM\TableRegistry;
Expand Down Expand Up @@ -278,28 +277,6 @@ protected function getAssociations(AssociationCollection $tableAssociations): ar
$className = App::className($table, 'Model/Table', 'Table') ?: static::CLASS_TABLE;

$associations[$type][$name] = $className;

if ($type !== BelongsToMany::class) {
continue;
}

/** @var \Cake\ORM\Association\BelongsToMany<\Cake\ORM\Table> $association */
$through = $this->throughAlias($association);
if (!$through) {
continue;
}

$className = App::className($through, 'Model/Table', 'Table') ?: static::CLASS_TABLE;
[, $throughName] = pluginSplit($through);
if (strpos($throughName, '\\') !== false) {
$throughName = substr($throughName, strrpos($throughName, '\\') + 1, -5);
}
$type = HasMany::class;
if (isset($associations[$type][$throughName])) {
continue;
}

$associations[$type][$throughName] = $className;
}

return $associations;
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/Annotator/ModelAnnotatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function testAnnotate() {

$output = $this->out->output();

$this->assertTextContains(' -> 18 annotations added', $output);
$this->assertTextContains(' -> 17 annotations added', $output);
}

/**
Expand Down Expand Up @@ -275,7 +275,7 @@ public function testAnnotateProtectedParent() {
$annotator->annotate($path);

$output = $this->out->output();
$this->assertTextContains(' -> 18 annotations added', $output);
$this->assertTextContains(' -> 17 annotations added', $output);
}

}
1 change: 0 additions & 1 deletion tests/test_files/Model/Table/BarBarsAbstractTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
/**
* @property \Cake\ORM\Association\BelongsTo<\TestApp\Model\Table\FoosTable> $Foos
* @property \Cake\ORM\Association\BelongsToMany<\Awesome\Model\Table\HousesTable> $Houses
* @property \Cake\ORM\Association\HasMany<\Awesome\Model\Table\WindowsTable> $Windows
*
* @method \TestApp\Model\Entity\BarBarsAbstract newEmptyEntity()
* @method \TestApp\Model\Entity\BarBarsAbstract newEntity(array $data, array $options = [])
Expand Down
1 change: 0 additions & 1 deletion tests/test_files/Model/Table/BarBarsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
/**
* @property \Cake\ORM\Association\BelongsTo<\TestApp\Model\Table\FoosTable> $Foos
* @property \Cake\ORM\Association\BelongsToMany<\Awesome\Model\Table\HousesTable> $Houses
* @property \Cake\ORM\Association\HasMany<\Awesome\Model\Table\WindowsTable> $Windows
*
* @method \TestApp\Model\Entity\BarBar newEmptyEntity()
* @method \TestApp\Model\Entity\BarBar newEntity(array $data, array $options = [])
Expand Down

0 comments on commit 141f290

Please sign in to comment.