Loading src/HoneypotService.php +5 −5 Original line number Diff line number Diff line Loading @@ -136,7 +136,7 @@ class HoneypotService implements HoneypotServiceInterface { /** * {@inheritdoc} */ public function getProtectedForms() { public function getProtectedForms(): array { $forms = &drupal_static(__METHOD__); // If the data isn't already in memory, get from cache or look it up fresh. Loading Loading @@ -167,7 +167,7 @@ class HoneypotService implements HoneypotServiceInterface { /** * {@inheritdoc} */ public function getTimeLimit(array $form_values = []) { public function getTimeLimit(array $form_values = []): int { $honeypot_time_limit = $this->config->get('time_limit'); // Only calculate time limit if honeypot_time_limit has a value > 0. Loading Loading @@ -207,7 +207,7 @@ class HoneypotService implements HoneypotServiceInterface { /** * {@inheritdoc} */ public function addFormProtection(array &$form, FormStateInterface $form_state, array $options = []) { public function addFormProtection(array &$form, FormStateInterface $form_state, array $options = []): void { // Allow other modules to alter the protections applied to this form. $this->moduleHandler->alter('honeypot_form_protections', $options, $form); Loading Loading @@ -354,7 +354,7 @@ class HoneypotService implements HoneypotServiceInterface { * - honeypot: If honeypot field was filled in. * - honeypot_time: If form was completed before the configured time limit. */ protected function log($form_id, $type) { protected function log($form_id, $type): void { $this->logFailure($form_id, $type); if ($this->config->get('log')) { $variables = [ Loading @@ -368,7 +368,7 @@ class HoneypotService implements HoneypotServiceInterface { /** * {@inheritdoc} */ public function logFailure($form_id, $type) { public function logFailure($form_id, $type): void { $uid = $this->account->id(); // Log failed submissions. Loading src/HoneypotServiceInterface.php +4 −4 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ interface HoneypotServiceInterface { * An array whose values are the form_ids of all the protected forms * on the site. */ public function getProtectedForms(); public function getProtectedForms(): array; /** * Looks up the time limit for the current user. Loading @@ -27,7 +27,7 @@ interface HoneypotServiceInterface { * @return int * The time limit in seconds. */ public function getTimeLimit(array $form_values = []); public function getTimeLimit(array $form_values = []): int; /** * Adds honeypot protection to provided form. Loading @@ -40,7 +40,7 @@ interface HoneypotServiceInterface { * (optional) Array of options to be added to form. Currently accepts * 'honeypot' and 'time_restriction'. */ public function addFormProtection(array &$form, FormStateInterface $form_state, array $options = []); public function addFormProtection(array &$form, FormStateInterface $form_state, array $options = []): void; /** * Logs the failed submission with timestamp and hostname. Loading @@ -52,6 +52,6 @@ interface HoneypotServiceInterface { * - honeypot: If honeypot field was filled in. * - honeypot_time: If form was completed before the configured time limit. */ public function logFailure($form_id, $type); public function logFailure($form_id, $type): void; } Loading
src/HoneypotService.php +5 −5 Original line number Diff line number Diff line Loading @@ -136,7 +136,7 @@ class HoneypotService implements HoneypotServiceInterface { /** * {@inheritdoc} */ public function getProtectedForms() { public function getProtectedForms(): array { $forms = &drupal_static(__METHOD__); // If the data isn't already in memory, get from cache or look it up fresh. Loading Loading @@ -167,7 +167,7 @@ class HoneypotService implements HoneypotServiceInterface { /** * {@inheritdoc} */ public function getTimeLimit(array $form_values = []) { public function getTimeLimit(array $form_values = []): int { $honeypot_time_limit = $this->config->get('time_limit'); // Only calculate time limit if honeypot_time_limit has a value > 0. Loading Loading @@ -207,7 +207,7 @@ class HoneypotService implements HoneypotServiceInterface { /** * {@inheritdoc} */ public function addFormProtection(array &$form, FormStateInterface $form_state, array $options = []) { public function addFormProtection(array &$form, FormStateInterface $form_state, array $options = []): void { // Allow other modules to alter the protections applied to this form. $this->moduleHandler->alter('honeypot_form_protections', $options, $form); Loading Loading @@ -354,7 +354,7 @@ class HoneypotService implements HoneypotServiceInterface { * - honeypot: If honeypot field was filled in. * - honeypot_time: If form was completed before the configured time limit. */ protected function log($form_id, $type) { protected function log($form_id, $type): void { $this->logFailure($form_id, $type); if ($this->config->get('log')) { $variables = [ Loading @@ -368,7 +368,7 @@ class HoneypotService implements HoneypotServiceInterface { /** * {@inheritdoc} */ public function logFailure($form_id, $type) { public function logFailure($form_id, $type): void { $uid = $this->account->id(); // Log failed submissions. Loading
src/HoneypotServiceInterface.php +4 −4 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ interface HoneypotServiceInterface { * An array whose values are the form_ids of all the protected forms * on the site. */ public function getProtectedForms(); public function getProtectedForms(): array; /** * Looks up the time limit for the current user. Loading @@ -27,7 +27,7 @@ interface HoneypotServiceInterface { * @return int * The time limit in seconds. */ public function getTimeLimit(array $form_values = []); public function getTimeLimit(array $form_values = []): int; /** * Adds honeypot protection to provided form. Loading @@ -40,7 +40,7 @@ interface HoneypotServiceInterface { * (optional) Array of options to be added to form. Currently accepts * 'honeypot' and 'time_restriction'. */ public function addFormProtection(array &$form, FormStateInterface $form_state, array $options = []); public function addFormProtection(array &$form, FormStateInterface $form_state, array $options = []): void; /** * Logs the failed submission with timestamp and hostname. Loading @@ -52,6 +52,6 @@ interface HoneypotServiceInterface { * - honeypot: If honeypot field was filled in. * - honeypot_time: If form was completed before the configured time limit. */ public function logFailure($form_id, $type); public function logFailure($form_id, $type): void; }