| Total Lines | 54 |
| Code Lines | 24 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 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 |
||
| 43 | protected function setUp(): void |
||
| 44 | { |
||
| 45 | parent::setUp(); |
||
| 46 | |||
| 47 | $this->config = Configuration::loadFromArray( |
||
| 48 | [ |
||
| 49 | 'module.enable' => ['memcookie' => true], |
||
| 50 | ], |
||
| 51 | '[ARRAY]', |
||
| 52 | 'simplesaml', |
||
| 53 | ); |
||
| 54 | |||
| 55 | $session = $this->createMock(Session::class); |
||
| 56 | $session->method('getData')->willReturn(['default-sp' => []]); |
||
| 57 | $this->session = $session; |
||
|
|
|||
| 58 | |||
| 59 | |||
| 60 | $this->authsources = Configuration::loadFromArray( |
||
| 61 | [ |
||
| 62 | 'default-sp' => ['saml:SP'], |
||
| 63 | ], |
||
| 64 | '[ARRAY]', |
||
| 65 | 'simplesaml', |
||
| 66 | ); |
||
| 67 | Configuration::setPreLoadedConfig($this->authsources, 'authsources.php', 'simplesaml'); |
||
| 68 | |||
| 69 | $this->http_utils = new class () extends Utils\HTTP { |
||
| 70 | /** @param array<mixed> $params */ |
||
| 71 | public function setCookie(string $name, ?string $value, ?array $params = null, bool $throw = true): void |
||
| 72 | { |
||
| 73 | // stub |
||
| 74 | } |
||
| 75 | |||
| 76 | |||
| 77 | /** @param array<mixed> $parameters */ |
||
| 78 | public function redirectTrustedURL(string $url, array $parameters = []): void |
||
| 79 | { |
||
| 80 | // stub |
||
| 81 | } |
||
| 82 | }; |
||
| 83 | |||
| 84 | $this->module_config = Configuration::loadFromArray( |
||
| 85 | [ |
||
| 86 | 'authsource' => 'default-sp', |
||
| 87 | 'cookiename' => 'AuthMemCookie', |
||
| 88 | 'username' => 'uid', |
||
| 89 | 'groups' => null, |
||
| 90 | 'memcache.host' => '127.0.0.1', |
||
| 91 | 'memcache.port' => 11211, |
||
| 92 | ], |
||
| 93 | '[ARRAY]', |
||
| 94 | 'simplesaml', |
||
| 95 | ); |
||
| 96 | Configuration::setPreLoadedConfig($this->module_config, 'module_authmemcookie.php', 'simplesaml'); |
||
| 97 | } |
||
| 146 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..