Complex classes like Crud often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Crud, and based on these observations, apply Extract Interface, too.
| 1 | <?php namespace Limoncello\Flute\Api; |
||
| 53 | class Crud implements CrudInterface |
||
| 54 | { |
||
| 55 | use HasContainerTrait; |
||
| 56 | |||
| 57 | /** Internal constant. Path constant. */ |
||
| 58 | protected const ROOT_PATH = ''; |
||
| 59 | |||
| 60 | /** Internal constant. Path constant. */ |
||
| 61 | protected const PATH_SEPARATOR = DocumentInterface::PATH_SEPARATOR; |
||
| 62 | |||
| 63 | /** |
||
| 64 | * @var FactoryInterface |
||
| 65 | */ |
||
| 66 | private $factory; |
||
| 67 | |||
| 68 | /** |
||
| 69 | * @var string |
||
| 70 | */ |
||
| 71 | private $modelClass; |
||
| 72 | |||
| 73 | /** |
||
| 74 | * @var ModelSchemeInfoInterface |
||
| 75 | */ |
||
| 76 | private $modelSchemes; |
||
| 77 | |||
| 78 | /** |
||
| 79 | * @var PaginationStrategyInterface |
||
| 80 | */ |
||
| 81 | private $paginationStrategy; |
||
| 82 | |||
| 83 | /** |
||
| 84 | * @var Connection |
||
| 85 | */ |
||
| 86 | private $connection; |
||
| 87 | |||
| 88 | /** |
||
| 89 | * @var iterable|null |
||
| 90 | */ |
||
| 91 | private $filterParameters = null; |
||
| 92 | |||
| 93 | /** |
||
| 94 | * @var bool |
||
| 95 | */ |
||
| 96 | private $areFiltersWithAnd = true; |
||
| 97 | |||
| 98 | /** |
||
| 99 | * @var iterable|null |
||
| 100 | */ |
||
| 101 | private $sortingParameters = null; |
||
| 102 | |||
| 103 | /** |
||
| 104 | * @var array |
||
| 105 | */ |
||
| 106 | private $relFiltersAndSorts = []; |
||
| 107 | |||
| 108 | /** |
||
| 109 | * @var iterable|null |
||
| 110 | */ |
||
| 111 | private $includePaths = null; |
||
| 112 | |||
| 113 | /** |
||
| 114 | * @var int|null |
||
| 115 | */ |
||
| 116 | private $pagingOffset = null; |
||
| 117 | |||
| 118 | /** |
||
| 119 | * @var Closure|null |
||
| 120 | */ |
||
| 121 | private $columnMapper = null; |
||
| 122 | |||
| 123 | /** |
||
| 124 | * @var bool |
||
| 125 | */ |
||
| 126 | private $isFetchTyped; |
||
| 127 | |||
| 128 | /** |
||
| 129 | * @var int|null |
||
| 130 | */ |
||
| 131 | private $pagingLimit = null; |
||
| 132 | |||
| 133 | /** internal constant */ |
||
| 134 | private const REL_FILTERS_AND_SORTS__FILTERS = 0; |
||
| 135 | |||
| 136 | /** internal constant */ |
||
| 137 | private const REL_FILTERS_AND_SORTS__SORTS = 1; |
||
| 138 | |||
| 139 | /** |
||
| 140 | * @param ContainerInterface $container |
||
| 141 | * @param string $modelClass |
||
| 142 | */ |
||
| 143 | 53 | public function __construct(ContainerInterface $container, string $modelClass) |
|
| 155 | |||
| 156 | /** |
||
| 157 | * @param Closure $mapper |
||
| 158 | * |
||
| 159 | * @return self |
||
| 160 | */ |
||
| 161 | 1 | public function withColumnMapper(Closure $mapper): self |
|
| 167 | |||
| 168 | /** |
||
| 169 | * @inheritdoc |
||
| 170 | */ |
||
| 171 | 43 | public function withFilters(iterable $filterParameters): CrudInterface |
|
| 177 | |||
| 178 | /** |
||
| 179 | * @inheritdoc |
||
| 180 | */ |
||
| 181 | 23 | public function withIndexFilter($index): CrudInterface |
|
| 196 | |||
| 197 | /** |
||
| 198 | * @inheritdoc |
||
| 199 | */ |
||
| 200 | 4 | public function withRelationshipFilters(string $name, iterable $filters): CrudInterface |
|
| 206 | |||
| 207 | /** |
||
| 208 | * @inheritdoc |
||
| 209 | */ |
||
| 210 | 1 | public function withRelationshipSorts(string $name, iterable $sorts): CrudInterface |
|
| 216 | |||
| 217 | /** |
||
| 218 | * @inheritdoc |
||
| 219 | */ |
||
| 220 | 15 | public function combineWithAnd(): CrudInterface |
|
| 226 | |||
| 227 | /** |
||
| 228 | * @inheritdoc |
||
| 229 | */ |
||
| 230 | 2 | public function combineWithOr(): CrudInterface |
|
| 236 | |||
| 237 | /** |
||
| 238 | * @return bool |
||
| 239 | */ |
||
| 240 | 32 | private function hasColumnMapper(): bool |
|
| 244 | |||
| 245 | /** |
||
| 246 | * @return Closure |
||
| 247 | */ |
||
| 248 | 1 | private function getColumnMapper(): Closure |
|
| 252 | |||
| 253 | /** |
||
| 254 | * @return bool |
||
| 255 | */ |
||
| 256 | 44 | private function hasFilters(): bool |
|
| 260 | |||
| 261 | /** |
||
| 262 | * @return iterable |
||
| 263 | */ |
||
| 264 | 35 | private function getFilters(): iterable |
|
| 268 | |||
| 269 | /** |
||
| 270 | * @return bool |
||
| 271 | */ |
||
| 272 | 35 | private function areFiltersWithAnd(): bool |
|
| 276 | |||
| 277 | /** |
||
| 278 | * @inheritdoc |
||
| 279 | */ |
||
| 280 | 18 | public function withSorts(iterable $sortingParameters): CrudInterface |
|
| 286 | |||
| 287 | /** |
||
| 288 | * @return bool |
||
| 289 | */ |
||
| 290 | 32 | private function hasSorts(): bool |
|
| 294 | |||
| 295 | /** |
||
| 296 | * @return iterable |
||
| 297 | */ |
||
| 298 | 14 | private function getSorts(): ?iterable |
|
| 302 | |||
| 303 | /** |
||
| 304 | * @inheritdoc |
||
| 305 | */ |
||
| 306 | 21 | public function withIncludes(iterable $includePaths): CrudInterface |
|
| 312 | |||
| 313 | /** |
||
| 314 | * @return bool |
||
| 315 | */ |
||
| 316 | 36 | private function hasIncludes(): bool |
|
| 320 | |||
| 321 | /** |
||
| 322 | * @return iterable |
||
| 323 | */ |
||
| 324 | 21 | private function getIncludes(): iterable |
|
| 328 | |||
| 329 | /** |
||
| 330 | * @inheritdoc |
||
| 331 | */ |
||
| 332 | 19 | public function withPaging(int $offset, int $limit): CrudInterface |
|
| 339 | |||
| 340 | /** |
||
| 341 | * @return self |
||
| 342 | */ |
||
| 343 | 53 | public function shouldBeTyped(): self |
|
| 349 | |||
| 350 | /** |
||
| 351 | * @return self |
||
| 352 | */ |
||
| 353 | 4 | public function shouldBeUntyped(): self |
|
| 359 | |||
| 360 | /** |
||
| 361 | * @return bool |
||
| 362 | */ |
||
| 363 | 41 | private function hasPaging(): bool |
|
| 367 | |||
| 368 | /** |
||
| 369 | * @return int |
||
| 370 | */ |
||
| 371 | 19 | private function getPagingOffset(): int |
|
| 375 | |||
| 376 | /** |
||
| 377 | * @return int |
||
| 378 | */ |
||
| 379 | 19 | private function getPagingLimit(): int |
|
| 383 | |||
| 384 | /** |
||
| 385 | * @return bool |
||
| 386 | */ |
||
| 387 | 41 | private function isFetchTyped(): bool |
|
| 391 | |||
| 392 | /** |
||
| 393 | * @return Connection |
||
| 394 | */ |
||
| 395 | 45 | protected function getConnection(): Connection |
|
| 399 | |||
| 400 | /** |
||
| 401 | * @param string $modelClass |
||
| 402 | * |
||
| 403 | * @return ModelQueryBuilder |
||
| 404 | */ |
||
| 405 | 45 | protected function createBuilder(string $modelClass): ModelQueryBuilder |
|
| 409 | |||
| 410 | /** |
||
| 411 | * @param Connection $connection |
||
| 412 | * @param string $modelClass |
||
| 413 | * |
||
| 414 | * @return ModelQueryBuilder |
||
| 415 | */ |
||
| 416 | 45 | private function createBuilderFromConnection(Connection $connection, string $modelClass): ModelQueryBuilder |
|
| 420 | |||
| 421 | /** |
||
| 422 | * @param ModelQueryBuilder $builder |
||
| 423 | * |
||
| 424 | * @return Crud |
||
| 425 | */ |
||
| 426 | 32 | protected function applyColumnMapper(ModelQueryBuilder $builder): self |
|
| 434 | |||
| 435 | /** |
||
| 436 | * @param ModelQueryBuilder $builder |
||
| 437 | * |
||
| 438 | * @return Crud |
||
| 439 | */ |
||
| 440 | 33 | protected function applyAliasFilters(ModelQueryBuilder $builder): self |
|
| 450 | |||
| 451 | /** |
||
| 452 | * @param ModelQueryBuilder $builder |
||
| 453 | * |
||
| 454 | * @return self |
||
| 455 | */ |
||
| 456 | 5 | protected function applyTableFilters(ModelQueryBuilder $builder): self |
|
| 466 | |||
| 467 | /** |
||
| 468 | * @param ModelQueryBuilder $builder |
||
| 469 | * |
||
| 470 | * @return self |
||
| 471 | */ |
||
| 472 | 32 | protected function applyRelationshipFiltersAndSorts(ModelQueryBuilder $builder): self |
|
| 493 | |||
| 494 | /** |
||
| 495 | * @param ModelQueryBuilder $builder |
||
| 496 | * |
||
| 497 | * @return self |
||
| 498 | */ |
||
| 499 | 32 | protected function applySorts(ModelQueryBuilder $builder): self |
|
| 507 | |||
| 508 | /** |
||
| 509 | * @param ModelQueryBuilder $builder |
||
| 510 | * |
||
| 511 | * @return self |
||
| 512 | */ |
||
| 513 | 41 | protected function applyPaging(ModelQueryBuilder $builder): self |
|
| 522 | |||
| 523 | /** |
||
| 524 | * @return self |
||
| 525 | */ |
||
| 526 | 53 | protected function clearBuilderParameters(): self |
|
| 538 | |||
| 539 | /** |
||
| 540 | * @return self |
||
| 541 | */ |
||
| 542 | 53 | private function clearFetchParameters(): self |
|
| 549 | |||
| 550 | /** |
||
| 551 | * @param ModelQueryBuilder $builder |
||
| 552 | * |
||
| 553 | * @return ModelQueryBuilder |
||
| 554 | */ |
||
| 555 | 1 | protected function builderOnCount(ModelQueryBuilder $builder): ModelQueryBuilder |
|
| 559 | |||
| 560 | /** |
||
| 561 | * @param ModelQueryBuilder $builder |
||
| 562 | * |
||
| 563 | * @return ModelQueryBuilder |
||
| 564 | */ |
||
| 565 | 32 | protected function builderOnIndex(ModelQueryBuilder $builder): ModelQueryBuilder |
|
| 569 | |||
| 570 | /** |
||
| 571 | * @param ModelQueryBuilder $builder |
||
| 572 | * |
||
| 573 | * @return ModelQueryBuilder |
||
| 574 | */ |
||
| 575 | 10 | protected function builderOnReadRelationship(ModelQueryBuilder $builder): ModelQueryBuilder |
|
| 579 | |||
| 580 | /** |
||
| 581 | * @param ModelQueryBuilder $builder |
||
| 582 | * |
||
| 583 | * @return ModelQueryBuilder |
||
| 584 | */ |
||
| 585 | 4 | protected function builderSaveResourceOnCreate(ModelQueryBuilder $builder): ModelQueryBuilder |
|
| 589 | |||
| 590 | /** |
||
| 591 | * @param ModelQueryBuilder $builder |
||
| 592 | * |
||
| 593 | * @return ModelQueryBuilder |
||
| 594 | */ |
||
| 595 | 4 | protected function builderSaveResourceOnUpdate(ModelQueryBuilder $builder): ModelQueryBuilder |
|
| 599 | |||
| 600 | /** |
||
| 601 | * @param string $relationshipName |
||
| 602 | * @param ModelQueryBuilder $builder |
||
| 603 | * |
||
| 604 | * @return ModelQueryBuilder |
||
| 605 | * |
||
| 606 | * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
||
| 607 | */ |
||
| 608 | 2 | protected function builderSaveRelationshipOnCreate(/** @noinspection PhpUnusedParameterInspection */ |
|
| 614 | |||
| 615 | /** |
||
| 616 | * @param string $relationshipName |
||
| 617 | * @param ModelQueryBuilder $builder |
||
| 618 | * |
||
| 619 | * @return ModelQueryBuilder |
||
| 620 | * |
||
| 621 | * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
||
| 622 | */ |
||
| 623 | 2 | protected function builderSaveRelationshipOnUpdate(/** @noinspection PhpUnusedParameterInspection */ |
|
| 629 | |||
| 630 | /** |
||
| 631 | * @param string $relationshipName |
||
| 632 | * @param ModelQueryBuilder $builder |
||
| 633 | * |
||
| 634 | * @return ModelQueryBuilder |
||
| 635 | * |
||
| 636 | * @SuppressWarnings(PHPMD.UnusedFormalParameter) |
||
| 637 | */ |
||
| 638 | 2 | protected function builderCleanRelationshipOnUpdate(/** @noinspection PhpUnusedParameterInspection */ |
|
| 644 | |||
| 645 | /** |
||
| 646 | * @param ModelQueryBuilder $builder |
||
| 647 | * |
||
| 648 | * @return ModelQueryBuilder |
||
| 649 | */ |
||
| 650 | 5 | protected function builderOnDelete(ModelQueryBuilder $builder): ModelQueryBuilder |
|
| 654 | |||
| 655 | /** |
||
| 656 | * @param PaginatedDataInterface|mixed|null $data |
||
| 657 | * |
||
| 658 | * @return void |
||
| 659 | * |
||
| 660 | * @SuppressWarnings(PHPMD.ElseExpression) |
||
| 661 | */ |
||
| 662 | 21 | private function loadRelationships($data): void |
|
| 703 | |||
| 704 | /** |
||
| 705 | * @param iterable $paths (string[]) |
||
| 706 | * |
||
| 707 | * @return iterable |
||
| 708 | */ |
||
| 709 | 21 | private static function getPaths(iterable $paths): iterable |
|
| 746 | |||
| 747 | /** |
||
| 748 | * @inheritdoc |
||
| 749 | */ |
||
| 750 | 2 | public function createIndexBuilder(iterable $columns = null): QueryBuilder |
|
| 754 | |||
| 755 | /** |
||
| 756 | * @inheritdoc |
||
| 757 | */ |
||
| 758 | 5 | public function createDeleteBuilder(): QueryBuilder |
|
| 759 | { |
||
| 760 | 5 | return $this->createDeleteModelBuilder(); |
|
| 761 | } |
||
| 762 | |||
| 763 | /** |
||
| 764 | * @param iterable|null $columns |
||
| 765 | * |
||
| 766 | * @return ModelQueryBuilder |
||
| 767 | */ |
||
| 768 | 32 | protected function createIndexModelBuilder(iterable $columns = null): ModelQueryBuilder |
|
| 791 | |||
| 792 | /** |
||
| 793 | * @return ModelQueryBuilder |
||
| 794 | */ |
||
| 795 | 5 | protected function createDeleteModelBuilder(): ModelQueryBuilder |
|
| 809 | |||
| 810 | /** |
||
| 811 | * @inheritdoc |
||
| 812 | */ |
||
| 813 | 16 | public function index(): PaginatedDataInterface |
|
| 820 | |||
| 821 | /** |
||
| 822 | * @inheritdoc |
||
| 823 | */ |
||
| 824 | 2 | public function indexIdentities(): array |
|
| 834 | |||
| 835 | /** |
||
| 836 | * @inheritdoc |
||
| 837 | */ |
||
| 838 | 14 | public function read($index) |
|
| 847 | |||
| 848 | /** |
||
| 849 | * @inheritdoc |
||
| 850 | */ |
||
| 851 | 1 | public function count(): ?int |
|
| 866 | |||
| 867 | /** |
||
| 868 | * @param string $relationshipName |
||
| 869 | * @param iterable|null $relationshipFilters |
||
| 870 | * @param iterable|null $relationshipSorts |
||
| 871 | * @param iterable|null $columns |
||
| 872 | * |
||
| 873 | * @return ModelQueryBuilder |
||
| 874 | */ |
||
| 875 | 10 | public function createReadRelationshipBuilder( |
|
| 876 | string $relationshipName, |
||
| 877 | iterable $relationshipFilters = null, |
||
| 878 | iterable $relationshipSorts = null, |
||
| 879 | iterable $columns = null |
||
| 880 | ): ModelQueryBuilder { |
||
| 881 | // as we read data from a relationship our main table and model would be the table/model in the relationship |
||
| 882 | // so 'root' model(s) will be located in the reverse relationship. |
||
| 883 | |||
| 884 | list ($targetModelClass, $reverseRelName) = |
||
| 885 | 10 | $this->getModelSchemes()->getReverseRelationship($this->getModelClass(), $relationshipName); |
|
| 886 | |||
| 887 | $builder = $this |
||
| 888 | 10 | ->createBuilder($targetModelClass) |
|
| 889 | 10 | ->selectModelColumns($columns) |
|
| 890 | 10 | ->fromModelTable(); |
|
| 891 | |||
| 892 | // 'root' filters would be applied to the data in the reverse relationship ... |
||
| 893 | 10 | if ($this->hasFilters() === true) { |
|
| 894 | 10 | $filters = $this->getFilters(); |
|
| 895 | 10 | $sorts = $this->getSorts(); |
|
| 896 | 10 | $this->areFiltersWithAnd() ? |
|
| 897 | 9 | $builder->addRelationshipFiltersAndSortsWithAnd($reverseRelName, $filters, $sorts) : |
|
| 898 | 1 | $builder->addRelationshipFiltersAndSortsWithOr($reverseRelName, $filters, $sorts); |
|
| 899 | } |
||
| 900 | // ... and the input filters to actual data we select |
||
| 901 | 10 | if ($relationshipFilters !== null) { |
|
| 902 | 7 | $builder->addFiltersWithAndToAlias($relationshipFilters); |
|
| 903 | } |
||
| 904 | 10 | if ($relationshipSorts !== null) { |
|
| 905 | 3 | $builder->addSorts($relationshipSorts); |
|
| 906 | } |
||
| 907 | |||
| 908 | 10 | $this->applyPaging($builder); |
|
| 909 | |||
| 910 | // While joining tables we select distinct rows. |
||
| 911 | 10 | $builder->distinct(); |
|
| 912 | |||
| 913 | 10 | return $this->builderOnReadRelationship($builder); |
|
| 914 | } |
||
| 915 | |||
| 916 | /** |
||
| 917 | * @inheritdoc |
||
| 918 | */ |
||
| 919 | 9 | public function indexRelationship( |
|
| 937 | |||
| 938 | /** |
||
| 939 | * @inheritdoc |
||
| 940 | */ |
||
| 941 | 2 | public function indexRelationshipIdentities( |
|
| 942 | string $name, |
||
| 943 | iterable $relationshipFilters = null, |
||
| 944 | iterable $relationshipSorts = null |
||
| 945 | ): array { |
||
| 946 | // depending on the relationship type we expect the result to be either single resource or a collection |
||
| 947 | 2 | $relationshipType = $this->getModelSchemes()->getRelationshipType($this->getModelClass(), $name); |
|
| 948 | 2 | $isExpectMany = $relationshipType === RelationshipTypes::HAS_MANY || |
|
| 949 | 2 | $relationshipType === RelationshipTypes::BELONGS_TO_MANY; |
|
| 950 | 2 | if ($isExpectMany === false) { |
|
| 951 | 1 | throw new InvalidArgumentException($this->getMessage(Messages::MSG_ERR_INVALID_ARGUMENT)); |
|
| 952 | } |
||
| 953 | |||
| 954 | 1 | list ($targetModelClass) = $this->getModelSchemes()->getReverseRelationship($this->getModelClass(), $name); |
|
| 955 | 1 | $targetPk = $this->getModelSchemes()->getPrimaryKey($targetModelClass); |
|
| 956 | |||
| 957 | 1 | $builder = $this->createReadRelationshipBuilder($name, $relationshipFilters, $relationshipSorts, [$targetPk]); |
|
| 958 | |||
| 959 | 1 | $modelClass = $builder->getModelClass(); |
|
| 960 | /** @var Generator $data */ |
||
| 961 | 1 | $data = $this->fetchColumn($builder, $modelClass, $targetPk); |
|
| 962 | 1 | $result = iterator_to_array($data); |
|
| 963 | |||
| 964 | 1 | return $result; |
|
| 965 | } |
||
| 966 | |||
| 967 | /** |
||
| 968 | * @inheritdoc |
||
| 969 | */ |
||
| 970 | 3 | public function readRelationship( |
|
| 978 | |||
| 979 | /** |
||
| 980 | * @inheritdoc |
||
| 981 | */ |
||
| 982 | 6 | public function hasInRelationship($parentId, string $name, $childId): bool |
|
| 1007 | |||
| 1008 | /** |
||
| 1009 | * @inheritdoc |
||
| 1010 | */ |
||
| 1011 | 5 | public function delete(): int |
|
| 1019 | |||
| 1020 | /** |
||
| 1021 | * @inheritdoc |
||
| 1022 | */ |
||
| 1023 | 6 | public function remove($index): bool |
|
| 1027 | |||
| 1028 | /** |
||
| 1029 | * @inheritdoc |
||
| 1030 | */ |
||
| 1031 | 5 | public function create($index, iterable $attributes, iterable $toMany): string |
|
| 1069 | |||
| 1070 | /** |
||
| 1071 | * @inheritdoc |
||
| 1072 | */ |
||
| 1073 | 5 | public function update($index, iterable $attributes, iterable $toMany): int |
|
| 1123 | |||
| 1124 | /** |
||
| 1125 | * @return FactoryInterface |
||
| 1126 | */ |
||
| 1127 | 45 | protected function getFactory(): FactoryInterface |
|
| 1131 | |||
| 1132 | /** |
||
| 1133 | * @return string |
||
| 1134 | */ |
||
| 1135 | 46 | protected function getModelClass(): string |
|
| 1139 | |||
| 1140 | /** |
||
| 1141 | * @return ModelSchemeInfoInterface |
||
| 1142 | */ |
||
| 1143 | 46 | protected function getModelSchemes(): ModelSchemeInfoInterface |
|
| 1147 | |||
| 1148 | /** |
||
| 1149 | * @return PaginationStrategyInterface |
||
| 1150 | */ |
||
| 1151 | 7 | protected function getPaginationStrategy(): PaginationStrategyInterface |
|
| 1155 | |||
| 1156 | /** |
||
| 1157 | * @param Closure $closure |
||
| 1158 | * |
||
| 1159 | * @return void |
||
| 1160 | */ |
||
| 1161 | 8 | public function inTransaction(Closure $closure): void |
|
| 1171 | |||
| 1172 | /** |
||
| 1173 | * @inheritdoc |
||
| 1174 | */ |
||
| 1175 | 24 | public function fetchResources(QueryBuilder $builder, string $modelClass): PaginatedDataInterface |
|
| 1186 | |||
| 1187 | /** |
||
| 1188 | * @inheritdoc |
||
| 1189 | */ |
||
| 1190 | 13 | public function fetchResource(QueryBuilder $builder, string $modelClass) |
|
| 1201 | |||
| 1202 | /** |
||
| 1203 | * @inheritdoc |
||
| 1204 | */ |
||
| 1205 | 2 | public function fetchRow(QueryBuilder $builder, string $modelClass): ?array |
|
| 1226 | |||
| 1227 | /** |
||
| 1228 | * @inheritdoc |
||
| 1229 | */ |
||
| 1230 | 3 | public function fetchColumn(QueryBuilder $builder, string $modelClass, string $columnName): iterable |
|
| 1255 | |||
| 1256 | /** |
||
| 1257 | * @param QueryBuilder $builder |
||
| 1258 | * @param string $modelClass |
||
| 1259 | * |
||
| 1260 | * @return mixed|null |
||
| 1261 | */ |
||
| 1262 | 16 | private function fetchResourceWithoutRelationships(QueryBuilder $builder, string $modelClass) |
|
| 1283 | |||
| 1284 | /** |
||
| 1285 | * @param QueryBuilder $builder |
||
| 1286 | * @param string $modelClass |
||
| 1287 | * |
||
| 1288 | * @return PaginatedDataInterface |
||
| 1289 | */ |
||
| 1290 | 28 | private function fetchPaginatedResourcesWithoutRelationships( |
|
| 1306 | |||
| 1307 | /** |
||
| 1308 | * @param QueryBuilder $builder |
||
| 1309 | * @param string $modelClass |
||
| 1310 | * |
||
| 1311 | * @return array |
||
| 1312 | */ |
||
| 1313 | 28 | private function fetchResourceCollection(QueryBuilder $builder, string $modelClass): array |
|
| 1348 | |||
| 1349 | /** |
||
| 1350 | * @param null|string $index |
||
| 1351 | * @param iterable $attributes |
||
| 1352 | * |
||
| 1353 | * @return iterable |
||
| 1354 | */ |
||
| 1355 | 4 | protected function filterAttributesOnCreate(?string $index, iterable $attributes): iterable |
|
| 1369 | |||
| 1370 | /** |
||
| 1371 | * @param iterable $attributes |
||
| 1372 | * |
||
| 1373 | * @return iterable |
||
| 1374 | */ |
||
| 1375 | 4 | protected function filterAttributesOnUpdate(iterable $attributes): iterable |
|
| 1384 | |||
| 1385 | /** |
||
| 1386 | * @param TagStorageInterface $modelsAtPath |
||
| 1387 | * @param ArrayObject $classAtPath |
||
| 1388 | * @param ModelStorageInterface $deDup |
||
| 1389 | * @param string $parentsPath |
||
| 1390 | * @param array $childRelationships |
||
| 1391 | * |
||
| 1392 | * @return void |
||
| 1393 | * |
||
| 1394 | * @SuppressWarnings(PHPMD.CyclomaticComplexity) |
||
| 1395 | */ |
||
| 1396 | 9 | private function loadRelationshipsLayer( |
|
| 1484 | |||
| 1485 | /** |
||
| 1486 | * @param string $message |
||
| 1487 | * |
||
| 1488 | * @return string |
||
| 1489 | */ |
||
| 1490 | 8 | private function getMessage(string $message): string |
|
| 1499 | |||
| 1500 | /** |
||
| 1501 | * @param string $class |
||
| 1502 | * @param array $attributes |
||
| 1503 | * @param Type[] $typeNames |
||
| 1504 | * @param AbstractPlatform $platform |
||
| 1505 | * |
||
| 1506 | * @return mixed |
||
| 1507 | * |
||
| 1508 | * @SuppressWarnings(PHPMD.StaticAccess) |
||
| 1509 | */ |
||
| 1510 | 33 | private function readResourceFromAssoc( |
|
| 1523 | |||
| 1524 | /** |
||
| 1525 | * @param array $attributes |
||
| 1526 | * @param Type[] $typeNames |
||
| 1527 | * @param AbstractPlatform $platform |
||
| 1528 | * |
||
| 1529 | * @return array |
||
| 1530 | * |
||
| 1531 | * @SuppressWarnings(PHPMD.StaticAccess) |
||
| 1532 | */ |
||
| 1533 | 1 | private function readRowFromAssoc(array $attributes, array $typeNames, AbstractPlatform $platform): array |
|
| 1542 | |||
| 1543 | /** |
||
| 1544 | * @param iterable $attributes |
||
| 1545 | * @param array $typeNames |
||
| 1546 | * @param AbstractPlatform $platform |
||
| 1547 | * |
||
| 1548 | * @return iterable |
||
| 1549 | */ |
||
| 1550 | 34 | private function readTypedAttributes(iterable $attributes, array $typeNames, AbstractPlatform $platform): iterable |
|
| 1557 | } |
||
| 1558 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..