Skip to content

Commit

Permalink
Fix CS
Browse files Browse the repository at this point in the history
  • Loading branch information
jderusse committed Mar 17, 2019
1 parent 8c9d313 commit 2071f9d
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 39 deletions.
1 change: 1 addition & 0 deletions .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ $config = PhpCsFixer\Config::create()
'header_comment' => ['header' => $header],
'linebreak_after_opening_tag' => true,
'modernize_types_casting' => true,
'native_function_invocation' => ['include' => ['@compiler_optimized'], 'scope' => 'namespaced'],
'no_superfluous_elseif' => true,
'no_useless_else' => true,
'phpdoc_order' => true,
Expand Down
4 changes: 2 additions & 2 deletions src/Cli/Command/AbstractCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ abstract class AbstractCommand extends Command implements LoggerInterface
protected $output;

/**
* @var null|array
* @var array|null
*/
private $configuration;

/**
* @var null|ContainerBuilder
* @var ContainerBuilder|null
*/
private $container;

Expand Down
4 changes: 2 additions & 2 deletions src/Cli/Command/Helper/KeyOptionCommandTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ trait KeyOptionCommandTrait
{
private function createKeyOption($keyType)
{
switch (\strtoupper($keyType)) {
switch (strtoupper($keyType)) {
case 'RSA':
return new RsaKeyOption();
case 'EC':
return new EcKeyOption();
default:
throw new \InvalidArgumentException(sprintf('The keyType "%s" is not valid. Supported types are: RSA, EC', \strtoupper($keyType)));
throw new \InvalidArgumentException(sprintf('The keyType "%s" is not valid. Supported types are: RSA, EC', strtoupper($keyType)));
}
}
}
4 changes: 2 additions & 2 deletions src/Cli/Configuration/AcmeConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class AcmeConfiguration implements ConfigurationInterface
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder('acmephp');
if (\method_exists(TreeBuilder::class, 'getRootNode')) {
if (method_exists(TreeBuilder::class, 'getRootNode')) {
$rootNode = $treeBuilder->getRootNode();
} else {
$rootNode = $treeBuilder->root('acmephp');
Expand Down Expand Up @@ -60,7 +60,7 @@ protected function createRootNode(ArrayNodeDefinition $rootNode)
->cannotBeEmpty()
->validate()
->ifTrue(function ($action) {
return !array_key_exists('action', $action);
return !\array_key_exists('action', $action);
})
->thenInvalid('The "action" configuration key is required.')
->end()
Expand Down
12 changes: 6 additions & 6 deletions src/Cli/Configuration/DomainConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class DomainConfiguration implements ConfigurationInterface
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder('acmephp');
if (\method_exists(TreeBuilder::class, 'getRootNode')) {
if (method_exists(TreeBuilder::class, 'getRootNode')) {
$rootNode = $treeBuilder->getRootNode();
} else {
$rootNode = $treeBuilder->root('acmephp');
Expand Down Expand Up @@ -62,7 +62,7 @@ public function getConfigTreeBuilder()
->beforeNormalization()
->ifString()
->then(function ($conf) {
return \strtoupper($conf);
return strtoupper($conf);
})
->end()
->validate()
Expand All @@ -81,7 +81,7 @@ public function getConfigTreeBuilder()

private function createDefaultsSection()
{
if (\method_exists(TreeBuilder::class, 'getRootNode')) {
if (method_exists(TreeBuilder::class, 'getRootNode')) {
$rootNode = (new TreeBuilder('defaults'))->getRootNode();
} else {
$rootNode = (new TreeBuilder())->root('defaults');
Expand All @@ -108,7 +108,7 @@ private function createDefaultsSection()

private function createSolverSection()
{
if (\method_exists(TreeBuilder::class, 'getRootNode')) {
if (method_exists(TreeBuilder::class, 'getRootNode')) {
$rootNode = (new TreeBuilder('solver'))->getRootNode();
} else {
$rootNode = (new TreeBuilder())->root('solver');
Expand All @@ -128,7 +128,7 @@ private function createSolverSection()

private function createDistinguishedNameSection()
{
if (\method_exists(TreeBuilder::class, 'getRootNode')) {
if (method_exists(TreeBuilder::class, 'getRootNode')) {
$rootNode = (new TreeBuilder('distinguished_name'))->getRootNode();
} else {
$rootNode = (new TreeBuilder())->root('distinguished_name');
Expand Down Expand Up @@ -179,7 +179,7 @@ private function createDistinguishedNameSection()

private function createCertificatesSection()
{
if (\method_exists(TreeBuilder::class, 'getRootNode')) {
if (method_exists(TreeBuilder::class, 'getRootNode')) {
$rootNode = (new TreeBuilder('certificates'))->getRootNode();
} else {
$rootNode = (new TreeBuilder())->root('certificates');
Expand Down
4 changes: 2 additions & 2 deletions src/Core/Challenge/Dns/LibDnsResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static function isSupported()
*/
public function getTxtEntries($domain)
{
$domain = \rtrim($domain, '.');
$domain = rtrim($domain, '.');
$nameServers = $this->getNameServers($domain);
$this->logger->debug('Fetched TXT records for domain', ['nsDomain' => $domain, 'servers' => $nameServers]);
$identicalEntries = [];
Expand Down Expand Up @@ -158,7 +158,7 @@ private function getNameServers($domain)
}
}
}
$itemNameServers = \array_unique($itemNameServers);
$itemNameServers = array_unique($itemNameServers);
if (empty($itemNameServers)) {
return $parentNameServers;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Core/Challenge/Dns/Route53Solver.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ function ($recordSet) use ($recordName) {
$recordIndex = [];
foreach ($recordSets as $previousRecordSet) {
$previousTxt = array_map(function ($resourceRecord) {
return \stripslashes(trim($resourceRecord['Value'], '"'));
return stripslashes(trim($resourceRecord['Value'], '"'));
}, $previousRecordSet['ResourceRecords']);
// Search the special Index
foreach ($previousTxt as $index => $recordValue) {
Expand Down Expand Up @@ -211,7 +211,7 @@ private function getSaveRecordQuery($recordName, array $recordIndex)
}
}

$recordValues = \array_keys($recordIndex);
$recordValues = array_keys($recordIndex);
$recordValues[] = json_encode($recordIndex);

return [
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Http/SecureHttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ private function getAlg()

private function extractSignOptionFromJWSAlg($alg)
{
if (!\preg_match('/^([A-Z]+)(\d+)$/', $alg, $match)) {
if (!preg_match('/^([A-Z]+)(\d+)$/', $alg, $match)) {
throw new AcmeCoreClientException(sprintf('The given "%s" algorithm is not supported', $alg));
}

Expand Down
2 changes: 1 addition & 1 deletion src/Core/Util/JsonDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class JsonDecoder
*/
public static function decode($json, $assoc = false, $depth = 512, $options = 0)
{
$data = \json_decode($json, $assoc, $depth, $options);
$data = json_decode($json, $assoc, $depth, $options);

if (JSON_ERROR_NONE !== json_last_error()) {
throw new \InvalidArgumentException('json_decode error: '.json_last_error_msg());
Expand Down
40 changes: 20 additions & 20 deletions src/Ssl/Signer/DataSigner.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,32 +72,32 @@ public function signData($data, PrivateKey $privateKey, $algorithm = OPENSSL_ALG
*/
private function DERtoECDSA($der, $partLength)
{
$hex = \unpack('H*', $der)[1];
if ('30' !== \mb_substr($hex, 0, 2, '8bit')) { // SEQUENCE
$hex = unpack('H*', $der)[1];
if ('30' !== mb_substr($hex, 0, 2, '8bit')) { // SEQUENCE
throw new DataSigningException('Invalid signature provided');
}
if ('81' === \mb_substr($hex, 2, 2, '8bit')) { // LENGTH > 128
$hex = \mb_substr($hex, 6, null, '8bit');
if ('81' === mb_substr($hex, 2, 2, '8bit')) { // LENGTH > 128
$hex = mb_substr($hex, 6, null, '8bit');
} else {
$hex = \mb_substr($hex, 4, null, '8bit');
$hex = mb_substr($hex, 4, null, '8bit');
}
if ('02' !== \mb_substr($hex, 0, 2, '8bit')) { // INTEGER
if ('02' !== mb_substr($hex, 0, 2, '8bit')) { // INTEGER
throw new DataSigningException('Invalid signature provided');
}

$Rl = \hexdec(\mb_substr($hex, 2, 2, '8bit'));
$R = $this->retrievePositiveInteger(\mb_substr($hex, 4, $Rl * 2, '8bit'));
$R = \str_pad($R, $partLength, '0', STR_PAD_LEFT);
$Rl = hexdec(mb_substr($hex, 2, 2, '8bit'));
$R = $this->retrievePositiveInteger(mb_substr($hex, 4, $Rl * 2, '8bit'));
$R = str_pad($R, $partLength, '0', STR_PAD_LEFT);

$hex = \mb_substr($hex, 4 + $Rl * 2, null, '8bit');
if ('02' !== \mb_substr($hex, 0, 2, '8bit')) { // INTEGER
$hex = mb_substr($hex, 4 + $Rl * 2, null, '8bit');
if ('02' !== mb_substr($hex, 0, 2, '8bit')) { // INTEGER
throw new DataSigningException('Invalid signature provided');
}
$Sl = \hexdec(\mb_substr($hex, 2, 2, '8bit'));
$S = $this->retrievePositiveInteger(\mb_substr($hex, 4, $Sl * 2, '8bit'));
$S = \str_pad($S, $partLength, '0', STR_PAD_LEFT);
$Sl = hexdec(mb_substr($hex, 2, 2, '8bit'));
$S = $this->retrievePositiveInteger(mb_substr($hex, 4, $Sl * 2, '8bit'));
$S = str_pad($S, $partLength, '0', STR_PAD_LEFT);

return \pack('H*', $R.$S);
return pack('H*', $R.$S);
}

/**
Expand All @@ -107,11 +107,11 @@ private function DERtoECDSA($der, $partLength)
*/
private function preparePositiveInteger($data)
{
if (\mb_substr($data, 0, 2, '8bit') > '7f') {
if (mb_substr($data, 0, 2, '8bit') > '7f') {
return '00'.$data;
}
while ('00' === \mb_substr($data, 0, 2, '8bit') && \mb_substr($data, 2, 2, '8bit') <= '7f') {
$data = \mb_substr($data, 2, null, '8bit');
while ('00' === mb_substr($data, 0, 2, '8bit') && mb_substr($data, 2, 2, '8bit') <= '7f') {
$data = mb_substr($data, 2, null, '8bit');
}

return $data;
Expand All @@ -124,8 +124,8 @@ private function preparePositiveInteger($data)
*/
private function retrievePositiveInteger($data)
{
while ('00' === \mb_substr($data, 0, 2, '8bit') && \mb_substr($data, 2, 2, '8bit') > '7f') {
$data = \mb_substr($data, 2, null, '8bit');
while ('00' === mb_substr($data, 0, 2, '8bit') && mb_substr($data, 2, 2, '8bit') > '7f') {
$data = mb_substr($data, 2, null, '8bit');
}

return $data;
Expand Down
2 changes: 1 addition & 1 deletion tests/Core/AbstractFunctionnalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected function createServerProcess($token, $payload)
'"'.$documentRoot.'"',
]);

if (\method_exists(Process::class, 'fromShellCommandline')) {
if (method_exists(Process::class, 'fromShellCommandline')) {
return Process::fromShellCommandline('exec '.$script, $documentRoot, null, null, null);
}

Expand Down

0 comments on commit 2071f9d

Please sign in to comment.