Conditions | 1 |
Paths | 1 |
Total Lines | 114 |
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 |
||
35 | protected function configure(): void |
||
36 | { |
||
37 | $this |
||
38 | ->setName('phpmnd') |
||
39 | ->setDefinition( |
||
40 | [ |
||
41 | new InputArgument( |
||
42 | 'directories', |
||
43 | InputArgument::REQUIRED + InputArgument::IS_ARRAY, |
||
44 | 'One or more files and/or directories to analyze' |
||
45 | ), |
||
46 | ] |
||
47 | ) |
||
48 | ->addOption( |
||
49 | 'extensions', |
||
50 | null, |
||
51 | InputOption::VALUE_REQUIRED, |
||
52 | 'A comma-separated list of extensions' |
||
53 | ) |
||
54 | ->addOption( |
||
55 | 'ignore-numbers', |
||
56 | null, |
||
57 | InputOption::VALUE_REQUIRED, |
||
58 | 'A comma-separated list of numbers to ignore', |
||
59 | '0, 1' |
||
60 | ) |
||
61 | ->addOption( |
||
62 | 'ignore-funcs', |
||
63 | null, |
||
64 | InputOption::VALUE_REQUIRED, |
||
65 | 'A comma-separated list of functions to ignore when using "argument" extension' |
||
66 | ) |
||
67 | ->addOption( |
||
68 | 'exclude', |
||
69 | null, |
||
70 | InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, |
||
71 | 'Exclude a directory from code analysis (must be relative to source)' |
||
72 | ) |
||
73 | ->addOption( |
||
74 | 'exclude-path', |
||
75 | null, |
||
76 | InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, |
||
77 | 'Exclude a path from code analysis (must be relative to source)' |
||
78 | ) |
||
79 | ->addOption( |
||
80 | 'exclude-file', |
||
81 | null, |
||
82 | InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, |
||
83 | 'Exclude a file from code analysis (must be relative to source)' |
||
84 | ) |
||
85 | ->addOption( |
||
86 | 'suffixes', |
||
87 | null, |
||
88 | InputOption::VALUE_REQUIRED, |
||
89 | 'Comma-separated string of valid source code filename extensions', |
||
90 | 'php' |
||
91 | ) |
||
92 | ->addOption( |
||
93 | 'progress', |
||
94 | null, |
||
95 | InputOption::VALUE_NONE, |
||
96 | 'Show progress bar' |
||
97 | ) |
||
98 | ->addOption( |
||
99 | 'hint', |
||
100 | null, |
||
101 | InputOption::VALUE_NONE, |
||
102 | 'Suggest replacements for magic numbers' |
||
103 | ) |
||
104 | ->addOption( |
||
105 | 'non-zero-exit-on-violation', |
||
106 | null, |
||
107 | InputOption::VALUE_NONE, |
||
108 | 'Return a non zero exit code when there are magic numbers' |
||
109 | ) |
||
110 | ->addOption( |
||
111 | 'strings', |
||
112 | null, |
||
113 | InputOption::VALUE_NONE, |
||
114 | 'Include strings literal search in code analysis' |
||
115 | ) |
||
116 | ->addOption( |
||
117 | 'ignore-strings', |
||
118 | null, |
||
119 | InputOption::VALUE_REQUIRED, |
||
120 | 'A comma-separated list of strings to ignore when using "strings" option' |
||
121 | ) |
||
122 | ->addOption( |
||
123 | 'include-numeric-string', |
||
124 | null, |
||
125 | InputOption::VALUE_NONE, |
||
126 | 'Include strings which are numeric' |
||
127 | ) |
||
128 | ->addOption( |
||
129 | 'allow-array-mapping', |
||
130 | null, |
||
131 | InputOption::VALUE_NONE, |
||
132 | 'Allow array mapping (key as strings) when using "array" extension.' |
||
133 | ) |
||
134 | ->addOption( |
||
135 | 'xml-output', |
||
136 | null, |
||
137 | InputOption::VALUE_REQUIRED, |
||
138 | 'Generate an XML output to the specified path' |
||
139 | ) |
||
140 | ->addOption( |
||
141 | 'whitelist', |
||
142 | null, |
||
143 | InputOption::VALUE_REQUIRED, |
||
144 | 'Link to a file containing filenames to search', |
||
145 | '' |
||
146 | ) |
||
147 | ; |
||
148 | } |
||
149 | |||
308 |
This check looks at variables that are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.