Conditions | 12 |
Paths | 17 |
Total Lines | 66 |
Code Lines | 45 |
Lines | 0 |
Ratio | 0 % |
Changes | 4 | ||
Bugs | 1 | Features | 2 |
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 |
||
85 | public function findExecutorGlobals( |
||
86 | ProcessSpecifier $process_specifier, |
||
87 | TargetPhpSettings $target_php_settings |
||
88 | ): int { |
||
89 | $tsrm_ls_cache = $this->findTsrmLsCache($process_specifier, $target_php_settings); |
||
90 | if (isset($tsrm_ls_cache)) { |
||
91 | switch ($target_php_settings->php_version) { |
||
92 | case ZendTypeReader::V70: |
||
93 | case ZendTypeReader::V71: |
||
94 | case ZendTypeReader::V72: |
||
95 | case ZendTypeReader::V73: |
||
96 | $executor_globals_id_cdata = $this->getSymbolReader($process_specifier, $target_php_settings) |
||
97 | ->read('executor_globals_id'); |
||
98 | if (is_null($executor_globals_id_cdata)) { |
||
99 | throw new RuntimeException('executor_globals_id not found'); |
||
100 | } |
||
101 | $tsrm_ls_cache_dereferenced = $this->integer_reader->read64( |
||
102 | new CDataByteReader( |
||
103 | $this->memory_reader->read( |
||
104 | $process_specifier->pid, |
||
105 | $tsrm_ls_cache, |
||
106 | 8 |
||
107 | ) |
||
108 | ), |
||
109 | 0 |
||
110 | )->toInt(); |
||
111 | $executor_globals_id = $this->integer_reader->read32( |
||
112 | new CDataByteReader($executor_globals_id_cdata), |
||
113 | 0 |
||
114 | ); |
||
115 | return $this->integer_reader->read64( |
||
116 | new CDataByteReader( |
||
117 | $this->memory_reader->read( |
||
118 | $process_specifier->pid, |
||
119 | $tsrm_ls_cache_dereferenced + ($executor_globals_id - 1) * 8, |
||
120 | 8 |
||
121 | ) |
||
122 | ), |
||
123 | 0 |
||
124 | )->toInt(); |
||
125 | |||
126 | case ZendTypeReader::V74: |
||
127 | case ZendTypeReader::V80: |
||
128 | case ZendTypeReader::V81: |
||
129 | $executor_globals_offset_cdata = $this->getSymbolReader( |
||
130 | $process_specifier, |
||
131 | $target_php_settings |
||
132 | )->read('executor_globals_offset'); |
||
133 | if (is_null($executor_globals_offset_cdata)) { |
||
134 | throw new RuntimeException('executor_globals_offset not found'); |
||
135 | } |
||
136 | $executor_globals_offset = $this->integer_reader->read64( |
||
137 | new CDataByteReader($executor_globals_offset_cdata), |
||
138 | 0 |
||
139 | )->toInt(); |
||
140 | return $tsrm_ls_cache + $executor_globals_offset; |
||
141 | default: |
||
142 | throw new \LogicException('this should never happen'); |
||
143 | } |
||
144 | } |
||
145 | $executor_globals_address = $this->getSymbolReader($process_specifier, $target_php_settings) |
||
146 | ->resolveAddress('executor_globals'); |
||
147 | if (is_null($executor_globals_address)) { |
||
148 | throw new RuntimeException('executor globals not found'); |
||
149 | } |
||
150 | return $executor_globals_address; |
||
151 | } |
||
165 |