-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
186 additions
and
290 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,16 @@ | ||
# EditorConfig is awesome: http://EditorConfig.org | ||
|
||
# Top-most EditorConfig file | ||
root = true | ||
|
||
# Unix-style newlines with a newline ending every file | ||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
|
||
# JS / PHP | ||
[*.{js,php,phpt}] | ||
charset = utf-8 | ||
indent_style = tab | ||
indent_size = 4 | ||
|
||
# NEON | ||
[*.neon] | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
indent_style = tab | ||
indent_size = 4 | ||
indent_size = tab | ||
tab_width = 4 | ||
|
||
# Composer, NPM, Travis, BitbucketPipelines | ||
[{composer.json,package.json,.travis.yml,bitbucket-pipelines.yml}] | ||
[{*.json,*.yml,*.md}] | ||
indent_style = space | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,5 @@ | |
/composer.lock | ||
|
||
# Tests | ||
/tests/*.log | ||
/tests/tmp | ||
/tests/coverage.html | ||
/temp | ||
/coverage.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
includes: | ||
- temp/phpstan/vendor/phpstan/phpstan-deprecation-rules/rules.neon | ||
- temp/phpstan/vendor/phpstan/phpstan-nette/extension.neon | ||
- temp/phpstan/vendor/phpstan/phpstan-nette/rules.neon | ||
- temp/phpstan/vendor/phpstan/phpstan-strict-rules/rules.neon | ||
|
||
parameters: | ||
ignoreErrors: | ||
# false positive | ||
- '#^Cannot call method getHttpData\(\) on Nette\\Forms\\Form\|null\.$#' | ||
# datasource is too much difficult to predict | ||
- '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?php | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Contributte\ReCaptcha\DI; | ||
|
||
|
@@ -9,24 +9,19 @@ | |
use Nette\PhpGenerator\ClassType; | ||
use Nette\Utils\Validators; | ||
|
||
/** | ||
* @author Milan Felix Sulc <[email protected]> | ||
*/ | ||
final class ReCaptchaExtension extends CompilerExtension | ||
{ | ||
|
||
/** @var array */ | ||
/** @var mixed[] */ | ||
private $defaults = [ | ||
'siteKey' => NULL, | ||
'secretKey' => NULL, | ||
'siteKey' => null, | ||
'secretKey' => null, | ||
]; | ||
|
||
/** | ||
* Register services | ||
* | ||
* @return void | ||
*/ | ||
public function loadConfiguration() | ||
public function loadConfiguration(): void | ||
{ | ||
$config = $this->validateConfig($this->defaults); | ||
$builder = $this->getContainerBuilder(); | ||
|
@@ -40,11 +35,8 @@ public function loadConfiguration() | |
|
||
/** | ||
* Decorate initialize method | ||
* | ||
* @param ClassType $class | ||
* @return void | ||
*/ | ||
public function afterCompile(ClassType $class) | ||
public function afterCompile(ClassType $class): void | ||
{ | ||
$method = $class->getMethod('initialize'); | ||
$method->addBody(sprintf('%s::bind($this->getService(?));', ReCaptchaBinding::class), [$this->prefix('provider')]); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,22 @@ | ||
<?php | ||
<?php declare(strict_types = 1); | ||
|
||
namespace Contributte\ReCaptcha\Forms; | ||
|
||
use Contributte\ReCaptcha\ReCaptchaProvider; | ||
use Nette\Forms\Container; | ||
|
||
/** | ||
* @author Milan Felix Sulc <[email protected]> | Jan Galek <[email protected]> | ||
*/ | ||
final class InvisibleReCaptchaBinding | ||
{ | ||
|
||
/** | ||
* @param ReCaptchaProvider $provider | ||
* @param string $name | ||
* @return void | ||
*/ | ||
public static function bind(ReCaptchaProvider $provider, $name = 'addInvisibleReCaptcha') | ||
public static function bind(ReCaptchaProvider $provider, string $name = 'addInvisibleReCaptcha'): void | ||
{ | ||
// Bind to form container | ||
|
||
Container::extensionMethod($name, function ($container, $name = 'recaptcha', $required = TRUE) use ($provider) { | ||
Container::extensionMethod($name, function (Container $container, string $name = 'recaptcha', bool $required = true) use ($provider): InvisibleReCaptchaField { | ||
$field = new InvisibleReCaptchaField($provider); | ||
$field->setRequired($required); | ||
$container[$name] = $field; | ||
|
||
return $container[$name]; | ||
return $field; | ||
}); | ||
} | ||
|
||
|
Oops, something went wrong.