Conditions | 1 |
Paths | 1 |
Total Lines | 160 |
Code Lines | 153 |
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 |
||
64 | public function getConfigTreeBuilder(): TreeBuilder |
||
65 | { |
||
66 | $treeBuilder = new TreeBuilder($this->getAlias()); |
||
67 | $rootNode = $treeBuilder->getRootNode(); |
||
68 | |||
69 | $rootNode |
||
70 | ->children() |
||
71 | ->scalarNode('psr17_factory')->end() |
||
72 | ->arrayNode('caching') |
||
73 | ->canBeEnabled() |
||
74 | ->addDefaultsIfNotSet() |
||
75 | ->children() |
||
76 | ->integerNode('cache_lifetime')->defaultValue(86400 * 30)->end() |
||
77 | ->integerNode('default_ttl')->end() |
||
78 | ->enumNode('hash_algo')->values(\hash_algos())->end() |
||
79 | ->arrayNode('methods') |
||
80 | ->defaultValue(['GET', 'HEAD']) |
||
81 | ->prototype('scalar')->end() |
||
82 | ->end() |
||
83 | ->arrayNode('respect_response_cache_directives') |
||
84 | ->performNoDeepMerging() |
||
85 | ->defaultValue(['no-cache', 'private', 'max-age', 'no-store']) |
||
86 | ->prototype('scalar')->end() |
||
87 | ->end() |
||
88 | ->scalarNode('cache_key_generator')->end() |
||
89 | ->arrayNode('cache_listeners') |
||
90 | ->defaultValue([]) |
||
91 | ->prototype('scalar')->end() |
||
92 | ->end() |
||
93 | ->arrayNode('blacklisted_paths') |
||
94 | ->defaultValue([]) |
||
95 | ->prototype('scalar')->end() |
||
96 | ->end() |
||
97 | ->end() |
||
98 | ->end() |
||
99 | ->arrayNode('policies') |
||
100 | ->canBeEnabled() |
||
101 | ->addDefaultsIfNotSet() |
||
102 | ->children() |
||
103 | ->arrayNode('content_security_policy') |
||
104 | ->defaultValue([]) |
||
105 | ->prototype('scalar')->end() |
||
106 | ->end() |
||
107 | ->arrayNode('csp_report_only') |
||
108 | ->defaultValue([]) |
||
109 | ->prototype('scalar')->end() |
||
110 | ->end() |
||
111 | ->arrayNode('feature_policy') |
||
112 | ->defaultValue([]) |
||
113 | ->prototype('scalar')->end() |
||
114 | ->end() |
||
115 | ->arrayNode('referrer_policy') |
||
116 | ->defaultValue([]) |
||
117 | ->prototype('scalar')->end() |
||
118 | ->end() |
||
119 | ->scalarNode('frame_policy') |
||
120 | ->beforeNormalization() |
||
121 | ->ifTrue(fn ($v) => false === $v) |
||
122 | ->then(fn ($v) => 'DENY') |
||
123 | ->end() |
||
124 | ->defaultValue('SAMEORIGIN') |
||
125 | ->end() |
||
126 | ->booleanNode('expose_csp_nonce')->defaultValue(true)->end() |
||
127 | ->end() |
||
128 | ->end() |
||
129 | ->arrayNode('headers') |
||
130 | ->addDefaultsIfNotSet() |
||
131 | ->children() |
||
132 | ->append(CorsConfiguration::getConfigNode()) |
||
133 | ->arrayNode('request') |
||
134 | ->normalizeKeys(false) |
||
135 | ->useAttributeAsKey('name') |
||
136 | ->prototype('scalar')->end() |
||
137 | ->end() |
||
138 | ->arrayNode('response') |
||
139 | ->normalizeKeys(false) |
||
140 | ->useAttributeAsKey('name') |
||
141 | ->prototype('scalar')->end() |
||
142 | ->end() |
||
143 | ->end() |
||
144 | ->end() |
||
145 | ->arrayNode('cookie') |
||
146 | ->info('cookie configuration') |
||
147 | ->addDefaultsIfNotSet() |
||
148 | ->canBeEnabled() |
||
149 | ->children() |
||
150 | ->scalarNode('prefix_name')->defaultValue('rade_')->end() |
||
151 | ->scalarNode('encrypter')->defaultValue(null)->end() |
||
152 | ->arrayNode('excludes_encryption') |
||
153 | ->prototype('scalar')->defaultValue([])->end() |
||
154 | ->end() |
||
155 | ->arrayNode('cookies') |
||
156 | ->arrayPrototype() |
||
157 | ->addDefaultsIfNotSet() |
||
158 | ->children() |
||
159 | ->scalarNode('name')->end() |
||
160 | ->scalarNode('value')->end() |
||
161 | ->variableNode('expires') |
||
162 | ->beforeNormalization() |
||
163 | ->always() |
||
164 | ->then(fn ($v) => wrap('Nette\Utils\DateTime::from', [$v])) |
||
165 | ->end() |
||
166 | ->end() |
||
167 | ->scalarNode('domain')->end() |
||
168 | ->scalarNode('path')->end() |
||
169 | ->end() |
||
170 | ->end() |
||
171 | ->end() |
||
172 | ->end() |
||
173 | ->end() |
||
174 | ->arrayNode('session') |
||
175 | ->info('session configuration') |
||
176 | ->addDefaultsIfNotSet() |
||
177 | ->canBeEnabled() |
||
178 | ->children() |
||
179 | ->scalarNode('storage_id')->defaultValue('session.storage.native')->end() |
||
180 | ->scalarNode('handler_id')->defaultValue('session.handler.native_file')->end() |
||
181 | ->scalarNode('name') |
||
182 | ->validate() |
||
183 | ->ifTrue(function ($v): bool { |
||
184 | \parse_str($v, $parsed); |
||
185 | |||
186 | return \implode('&', \array_keys($parsed)) !== (string) $v; |
||
187 | }) |
||
188 | ->thenInvalid('Session name %s contains illegal character(s)') |
||
189 | ->end() |
||
190 | ->end() |
||
191 | ->scalarNode('cookie_lifetime')->defaultValue(\ini_get('session.gc_maxlifetime'))->end() |
||
192 | ->scalarNode('cookie_path')->end() |
||
193 | ->scalarNode('cookie_domain')->end() |
||
194 | ->enumNode('cookie_secure')->values([true, false, 'auto'])->end() |
||
195 | ->booleanNode('cookie_httponly')->defaultTrue()->end() |
||
196 | ->enumNode('cookie_samesite') |
||
197 | ->values([null, Cookie::SAME_SITE_LAX, Cookie::SAME_SITE_NONE, Cookie::SAME_SITE_STRICT]) |
||
198 | ->defaultValue(Cookie::SAME_SITE_LAX) |
||
199 | ->end() |
||
200 | ->booleanNode('use_cookies')->end() |
||
201 | ->scalarNode('gc_divisor')->end() |
||
202 | ->scalarNode('gc_probability')->defaultValue(1)->end() |
||
203 | ->scalarNode('gc_maxlifetime')->end() |
||
204 | ->scalarNode('save_path')->defaultValue('sessions')->end() |
||
205 | ->scalarNode('meta_storage_key')->defaultValue('_rade_meta')->end() |
||
206 | ->integerNode('metadata_update_threshold') |
||
207 | ->defaultValue(0) |
||
208 | ->info('seconds to wait between 2 session metadata updates') |
||
209 | ->end() |
||
210 | ->integerNode('sid_length') |
||
211 | ->min(22) |
||
212 | ->max(256) |
||
213 | ->end() |
||
214 | ->integerNode('sid_bits_per_character') |
||
215 | ->min(4) |
||
216 | ->max(6) |
||
217 | ->end() |
||
218 | ->end() |
||
219 | ->end() |
||
220 | ->end() |
||
221 | ; |
||
222 | |||
223 | return $treeBuilder; |
||
224 | } |
||
300 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths