Complex classes like AbstractNode 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 AbstractNode, and based on these observations, apply Extract Interface, too.
| 1 | <?php | ||
| 29 | abstract class AbstractNode implements NodeInterface | ||
| 30 | { | ||
| 31 | /** | ||
| 32 | * name max lenght. | ||
| 33 | */ | ||
| 34 | const MAX_NAME_LENGTH = 255; | ||
| 35 | |||
| 36 | /** | ||
| 37 | * Unique id. | ||
| 38 | * | ||
| 39 | * @var ObjectId | ||
| 40 | */ | ||
| 41 | protected $_id; | ||
| 42 | |||
| 43 | /** | ||
| 44 | * Node name. | ||
| 45 | * | ||
| 46 | * @var string | ||
| 47 | */ | ||
| 48 | protected $name = ''; | ||
| 49 | |||
| 50 | /** | ||
| 51 | * Owner. | ||
| 52 | * | ||
| 53 | * @var ObjectId | ||
| 54 | */ | ||
| 55 | protected $owner; | ||
| 56 | |||
| 57 | /** | ||
| 58 | * Mime. | ||
| 59 | * | ||
| 60 | * @var string | ||
| 61 | */ | ||
| 62 | protected $mime; | ||
| 63 | |||
| 64 | /** | ||
| 65 | * Meta attributes. | ||
| 66 | * | ||
| 67 | * @var array | ||
| 68 | */ | ||
| 69 | protected $meta = []; | ||
| 70 | |||
| 71 | /** | ||
| 72 | * Parent collection. | ||
| 73 | * | ||
| 74 | * @var ObjectId | ||
| 75 | */ | ||
| 76 | protected $parent; | ||
| 77 | |||
| 78 | /** | ||
| 79 | * Is file deleted. | ||
| 80 | * | ||
| 81 | * @var bool|UTCDateTime | ||
| 82 | */ | ||
| 83 | protected $deleted = false; | ||
| 84 | |||
| 85 | /** | ||
| 86 | * Is shared? | ||
| 87 | * | ||
| 88 | * @var bool | ||
| 89 | */ | ||
| 90 | protected $shared = false; | ||
| 91 | |||
| 92 | /** | ||
| 93 | * Destory at a certain time. | ||
| 94 | * | ||
| 95 | * @var UTCDateTime | ||
| 96 | */ | ||
| 97 | protected $destroy; | ||
| 98 | |||
| 99 | /** | ||
| 100 | * Changed timestamp. | ||
| 101 | * | ||
| 102 | * @var UTCDateTime | ||
| 103 | */ | ||
| 104 | protected $changed; | ||
| 105 | |||
| 106 | /** | ||
| 107 | * Created timestamp. | ||
| 108 | * | ||
| 109 | * @var UTCDateTime | ||
| 110 | */ | ||
| 111 | protected $created; | ||
| 112 | |||
| 113 | /** | ||
| 114 | * Point to antother node (Means this node is reference to $reference). | ||
| 115 | * | ||
| 116 | * @var ObjectId | ||
| 117 | */ | ||
| 118 | protected $reference; | ||
| 119 | |||
| 120 | /** | ||
| 121 | * Raw attributes before any processing or modifications. | ||
| 122 | * | ||
| 123 | * @var array | ||
| 124 | */ | ||
| 125 | protected $raw_attributes; | ||
| 126 | |||
| 127 | /** | ||
| 128 | * Readonly flag. | ||
| 129 | * | ||
| 130 | * @var bool | ||
| 131 | */ | ||
| 132 | protected $readonly = false; | ||
| 133 | |||
| 134 | /** | ||
| 135 | * App attributes. | ||
| 136 | * | ||
| 137 | * @var array | ||
| 138 | */ | ||
| 139 | protected $app = []; | ||
| 140 | |||
| 141 | /** | ||
| 142 | * Filesystem. | ||
| 143 | * | ||
| 144 | * @var Filesystem | ||
| 145 | */ | ||
| 146 | protected $_fs; | ||
| 147 | |||
| 148 | /** | ||
| 149 | * Database. | ||
| 150 | * | ||
| 151 | * @var Database | ||
| 152 | */ | ||
| 153 | protected $_db; | ||
| 154 | |||
| 155 | /** | ||
| 156 | * User. | ||
| 157 | * | ||
| 158 | * @var User | ||
| 159 | */ | ||
| 160 | protected $_user; | ||
| 161 | |||
| 162 | /** | ||
| 163 | * Logger. | ||
| 164 | * | ||
| 165 | * @var LoggerInterface | ||
| 166 | */ | ||
| 167 | protected $_logger; | ||
| 168 | |||
| 169 | /** | ||
| 170 | * Server. | ||
| 171 | * | ||
| 172 | * @var Server | ||
| 173 | */ | ||
| 174 | protected $_server; | ||
| 175 | |||
| 176 | /** | ||
| 177 | * Hook. | ||
| 178 | * | ||
| 179 | * @var Hook | ||
| 180 | */ | ||
| 181 | protected $_hook; | ||
| 182 | |||
| 183 | /** | ||
| 184 | * Acl. | ||
| 185 | * | ||
| 186 | * @var Acl | ||
| 187 | */ | ||
| 188 | protected $_acl; | ||
| 189 | |||
| 190 | /** | ||
| 191 | * Storage adapter. | ||
| 192 | * | ||
| 193 | * @var string | ||
| 194 | */ | ||
| 195 | protected $storage_adapter; | ||
| 196 | |||
| 197 | /** | ||
| 198 | * Acl. | ||
| 199 | * | ||
| 200 | * @var array | ||
| 201 | */ | ||
| 202 | protected $acl = []; | ||
| 203 | |||
| 204 | /** | ||
| 205 | * Storage. | ||
| 206 | * | ||
| 207 | * @var Storage | ||
| 208 | */ | ||
| 209 | protected $_storage; | ||
| 210 | |||
| 211 | /** | ||
| 212 | * Convert to filename. | ||
| 213 | * | ||
| 214 | * @return string | ||
| 215 | */ | ||
| 216 | public function __toString() | ||
| 220 | |||
| 221 | /** | ||
| 222 | * Get owner. | ||
| 223 | */ | ||
| 224 | public function getOwner(): ObjectId | ||
| 228 | |||
| 229 | /** | ||
| 230 | * Set filesystem. | ||
| 231 | */ | ||
| 232 | public function setFilesystem(Filesystem $fs): NodeInterface | ||
| 239 | |||
| 240 | /** | ||
| 241 | * Get filesystem. | ||
| 242 | */ | ||
| 243 | public function getFilesystem(): Filesystem | ||
| 247 | |||
| 248 | /** | ||
| 249 | * temporary session. | ||
| 250 | */ | ||
| 251 | public function temporarySession($stream, ObjectId $session = null): ObjectId | ||
| 255 | |||
| 256 | /** | ||
| 257 | * Check if $node is a sub node of any parent nodes of this node. | ||
| 258 | */ | ||
| 259 | public function isSubNode(NodeInterface $node): bool | ||
| 277 | |||
| 278 | /** | ||
| 279 | * Move node. | ||
| 280 | */ | ||
| 281 | public function setParent(Collection $parent, int $conflict = NodeInterface::CONFLICT_NOACTION): NodeInterface | ||
| 359 | |||
| 360 | /** | ||
| 361 | * Set node acl. | ||
| 362 | */ | ||
| 363 | public function setAcl(array $acl): NodeInterface | ||
| 382 | |||
| 383 | /** | ||
| 384 | * Get ACL. | ||
| 385 | */ | ||
| 386 | public function getAcl(): array | ||
| 396 | |||
| 397 | /** | ||
| 398 | * Get share id. | ||
| 399 | */ | ||
| 400 | public function getShareId(bool $reference = false): ?ObjectId | ||
| 420 | |||
| 421 | /** | ||
| 422 | * Get share node. | ||
| 423 | * | ||
| 424 | * @return Collection | ||
| 425 | */ | ||
| 426 | public function getShareNode(): ?Collection | ||
| 438 | |||
| 439 | /** | ||
| 440 | * Is node marked as readonly? | ||
| 441 | */ | ||
| 442 | public function isReadonly(): bool | ||
| 446 | |||
| 447 | /** | ||
| 448 | * Request is from node owner? | ||
| 449 | */ | ||
| 450 | public function isOwnerRequest(): bool | ||
| 454 | |||
| 455 | /** | ||
| 456 | * Check if node is kind of special. | ||
| 457 | */ | ||
| 458 | public function isSpecial(): bool | ||
| 472 | |||
| 473 | /** | ||
| 474 | * Check if node is a sub node of a share. | ||
| 475 | */ | ||
| 476 | public function isShareMember(): bool | ||
| 480 | |||
| 481 | /** | ||
| 482 | * Is share. | ||
| 483 | */ | ||
| 484 | public function isShare(): bool | ||
| 488 | |||
| 489 | /** | ||
| 490 | * Is share (Reference or master share). | ||
| 491 | */ | ||
| 492 | public function isShared(): bool | ||
| 500 | |||
| 501 | /** | ||
| 502 | * Set the name. | ||
| 503 | * | ||
| 504 | * @param string $name | ||
| 505 | */ | ||
| 506 | public function setName($name): bool | ||
| 526 | |||
| 527 | /** | ||
| 528 | * Check name. | ||
| 529 | */ | ||
| 530 | public function checkName(string $name): string | ||
| 545 | |||
| 546 | /** | ||
| 547 | * Get the name. | ||
| 548 | */ | ||
| 549 | public function getName(): string | ||
| 553 | |||
| 554 | /** | ||
| 555 | * Undelete. | ||
| 556 | * | ||
| 557 | * @param string $recursion | ||
| 558 | */ | ||
| 559 | public function undelete(int $conflict = NodeInterface::CONFLICT_NOACTION, ?string $recursion = null, bool $recursion_first = true): bool | ||
| 642 | |||
| 643 | /** | ||
| 644 | * Is node deleted? | ||
| 645 | */ | ||
| 646 | public function isDeleted(): bool | ||
| 650 | |||
| 651 | /** | ||
| 652 | * Get last modified timestamp. | ||
| 653 | */ | ||
| 654 | public function getLastModified(): int | ||
| 662 | |||
| 663 | /** | ||
| 664 | * Get unique id. | ||
| 665 | * | ||
| 666 | * @return ObjectId | ||
| 667 | */ | ||
| 668 | 1 | public function getId(): ?ObjectId | |
| 672 | |||
| 673 | /** | ||
| 674 | * Get parent. | ||
| 675 | * | ||
| 676 | * @return Collection | ||
| 677 | */ | ||
| 678 | public function getParent(): ?Collection | ||
| 708 | |||
| 709 | /** | ||
| 710 | * Get parents. | ||
| 711 | */ | ||
| 712 | public function getParents(?NodeInterface $node = null, array $parents = []): array | ||
| 726 | |||
| 727 | /** | ||
| 728 | * Get as zip. | ||
| 729 | */ | ||
| 730 | public function getZip(): void | ||
| 736 | |||
| 737 | /** | ||
| 738 | * Create zip. | ||
| 739 | * | ||
| 740 | * @param bool $self true means that the zip represents the collection itself instead a child of the zip | ||
| 741 | * @param NodeInterface $parent | ||
| 742 | */ | ||
| 743 | public function zip(ZipStream $archive, bool $self = true, ?NodeInterface $parent = null, string $path = '', int $depth = 0): bool | ||
| 788 | |||
| 789 | /** | ||
| 790 | * Get mime type. | ||
| 791 | */ | ||
| 792 | 1 | public function getContentType(): string | |
| 796 | |||
| 797 | /** | ||
| 798 | * Is reference. | ||
| 799 | */ | ||
| 800 | public function isReference(): bool | ||
| 804 | |||
| 805 | /** | ||
| 806 | * Set app attributes. | ||
| 807 | */ | ||
| 808 | public function setAppAttributes(string $namespace, array $attributes): NodeInterface | ||
| 815 | |||
| 816 | /** | ||
| 817 | * Set app attribute. | ||
| 818 | */ | ||
| 819 | public function setAppAttribute(string $namespace, string $attribute, $value): NodeInterface | ||
| 830 | |||
| 831 | /** | ||
| 832 | * Remove app attribute. | ||
| 833 | */ | ||
| 834 | public function unsetAppAttributes(string $namespace): NodeInterface | ||
| 843 | |||
| 844 | /** | ||
| 845 | * Remove app attribute. | ||
| 846 | */ | ||
| 847 | public function unsetAppAttribute(string $namespace, string $attribute): NodeInterface | ||
| 856 | |||
| 857 | /** | ||
| 858 | * Get app attribute. | ||
| 859 | */ | ||
| 860 | public function getAppAttribute(string $namespace, string $attribute) | ||
| 868 | |||
| 869 | /** | ||
| 870 | * Get app attributes. | ||
| 871 | */ | ||
| 872 | public function getAppAttributes(string $namespace): array | ||
| 880 | |||
| 881 | /** | ||
| 882 | * Set meta attributes. | ||
| 883 | */ | ||
| 884 | public function setMetaAttributes(array $attributes): NodeInterface | ||
| 899 | |||
| 900 | /** | ||
| 901 | * Get meta attributes as array. | ||
| 902 | */ | ||
| 903 | public function getMetaAttributes(array $attributes = []): array | ||
| 912 | |||
| 913 | /** | ||
| 914 | * Mark node as readonly. | ||
| 915 | */ | ||
| 916 | public function setReadonly(bool $readonly = true): bool | ||
| 922 | |||
| 923 | /** | ||
| 924 | * Mark node as self-destroyable. | ||
| 925 | * | ||
| 926 | * @param UTCDateTime $ts | ||
| 927 | */ | ||
| 928 | public function setDestroyable(?UTCDateTime $ts): bool | ||
| 938 | |||
| 939 | /** | ||
| 940 | * Get original raw attributes before any processing. | ||
| 941 | */ | ||
| 942 | public function getRawAttributes(): array | ||
| 946 | |||
| 947 | /** | ||
| 948 | * Check if node is in root. | ||
| 949 | */ | ||
| 950 | public function isInRoot(): bool | ||
| 954 | |||
| 955 | /** | ||
| 956 | * Check if node is an instance of the actual root collection. | ||
| 957 | */ | ||
| 958 | public function isRoot(): bool | ||
| 962 | |||
| 963 | /** | ||
| 964 | * Resolve node path. | ||
| 965 | */ | ||
| 966 | public function getPath(): string | ||
| 977 | |||
| 978 | /** | ||
| 979 | * Save node attributes. | ||
| 980 | * | ||
| 981 | * @param array|string $attributes | ||
| 982 | * @param array|string $remove | ||
| 983 | * @param string $recursion | ||
| 984 | */ | ||
| 985 | public function save($attributes = [], $remove = [], ?string $recursion = null, bool $recursion_first = true): bool | ||
| 1049 | |||
| 1050 | /** | ||
| 1051 | * Get array value via string path. | ||
| 1052 | */ | ||
| 1053 | protected function getArrayValue(Iterable $array, string $path, string $separator = '.') | ||
| 1070 | |||
| 1071 | /** | ||
| 1072 | * Validate meta attributes. | ||
| 1073 | */ | ||
| 1074 | protected function validateMetaAttributes(array $attributes): array | ||
| 1093 | |||
| 1094 | /** | ||
| 1095 | * Duplicate name with a uniqid within name. | ||
| 1096 | */ | ||
| 1097 | protected function getDuplicateName(?string $name = null, ?string $class = null): string | ||
| 1120 | |||
| 1121 | /** | ||
| 1122 | * Completly remove node. | ||
| 1123 | */ | ||
| 1124 | abstract protected function _forceDelete(): bool; | ||
| 1125 | } | ||
| 1126 | 
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.