Conditions | 9 |
Paths | 18 |
Total Lines | 55 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
70 | private function doesFileRequireParsing(string $filename) : bool |
||
71 | { |
||
72 | if (!isset($this->fileInfos[$filename])) { |
||
73 | throw new InvalidArgumentException( |
||
74 | sprintf('No file info found for "%s" - file does not exist.', $filename) |
||
75 | ); |
||
76 | } |
||
77 | |||
78 | $file = $this->fileInfos[$filename]; |
||
79 | |||
80 | $documentFilename = $this->getFilenameFromFile($file); |
||
81 | $entry = $this->metas->get($documentFilename); |
||
82 | |||
83 | if ($this->hasFileBeenUpdated($filename)) { |
||
84 | // File is new or changed and thus need to be parsed |
||
85 | return true; |
||
86 | } |
||
87 | |||
88 | // Look to the file's dependencies to know if you need to parse it or not |
||
89 | $dependencies = $entry !== null ? $entry->getDepends() : []; |
||
90 | |||
91 | if ($entry !== null && $entry->getParent() !== null) { |
||
92 | $dependencies[] = $entry->getParent(); |
||
93 | } |
||
94 | |||
95 | foreach ($dependencies as $dependency) { |
||
96 | /* |
||
97 | * The dependency check is NOT recursive on purpose. |
||
98 | * If fileA has a link to fileB that uses its "headline", |
||
99 | * for example, then fileA is "dependent" on fileB. If |
||
100 | * fileB changes, it means that its MetaEntry needs to |
||
101 | * be updated. And because fileA gets the headline from |
||
102 | * the MetaEntry, it means that fileA must also be re-parsed. |
||
103 | * However, if fileB depends on fileC and file C only is |
||
104 | * updated, fileB *does* need to be re-parsed, but fileA |
||
105 | * does not, because the MetaEntry for fileB IS still |
||
106 | * "fresh" - fileB did not actually change, so any metadata |
||
107 | * about headlines, etc, is still fresh. Therefore, fileA |
||
108 | * does not need to be parsed. |
||
109 | */ |
||
110 | |||
111 | // dependency no longer exists? We should re-parse this file |
||
112 | if (!isset($this->fileInfos[$dependency])) { |
||
113 | return true; |
||
114 | } |
||
115 | |||
116 | // finally, we need to recursively ask if this file needs parsing |
||
117 | if ($this->hasFileBeenUpdated($dependency)) { |
||
118 | return true; |
||
119 | } |
||
120 | } |
||
121 | |||
122 | // Meta is fresh and no dependencies need parsing |
||
123 | return false; |
||
124 | } |
||
125 | |||
152 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.