Skip to content

Commit

Permalink
Shorthand arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed May 11, 2020
1 parent c51dc5b commit 10338ad
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
8 changes: 4 additions & 4 deletions src/XMLSecEnc.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class XMLSecEnc
public $encKey = null;

/** @var array */
private $references = array();
private $references = [];


public function __construct()
Expand Down Expand Up @@ -122,7 +122,7 @@ public function addReference(string $name, DOMNode $node, string $type): void
$refuri = XMLSecurityDSig::generateGUID();
$element = $encdoc->documentElement;
$element->setAttribute("Id", $refuri);
$this->references[$name] = array("node" => $node, "type" => $type, "encnode" => $encdoc, "refuri" => $refuri);
$this->references[$name] = ["node" => $node, "type" => $type, "encnode" => $encdoc, "refuri" => $refuri];
}


Expand Down Expand Up @@ -440,7 +440,7 @@ public function locateKey(DOMNode $node = null): ?XMLSecurityKey
$attrAlgorithm = $encmeth->getAttribute("Algorithm");

try {
$objKey = new XMLSecurityKey($attrAlgorithm, array('type' => 'private'));
$objKey = new XMLSecurityKey($attrAlgorithm, ['type' => 'private']);
} catch (Exception $e) {
return null;
}
Expand Down Expand Up @@ -538,7 +538,7 @@ public static function staticLocateKeyInfo(XMLSecurityKey $objBaseKey = null, DO
if ($x509certNodes = $child->getElementsByTagName('X509Certificate')) {
if ($x509certNodes->length > 0) {
$x509cert = $x509certNodes->item(0)->textContent;
$x509cert = str_replace(array("\r", "\n", " "), "", $x509cert);
$x509cert = str_replace(["\r", "\n", " "], "", $x509cert);
$x509cert = "-----BEGIN CERTIFICATE-----\n"
. chunk_split($x509cert, 64, "\n") . "-----END CERTIFICATE-----\n";
$objBaseKey->loadKey($x509cert, false, true);
Expand Down
34 changes: 17 additions & 17 deletions src/XMLSecurityDSig.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ class XMLSecurityDSig
public $sigNode = null;

/** @var array */
public $idKeys = array();
public $idKeys = [];

/** @var array */
public $idNS = array();
public $idNS = [];

/** @var string|null */
private $signedInfo = null;
Expand Down Expand Up @@ -128,8 +128,8 @@ public function __construct(?string $prefix = 'ds')

if (!empty($prefix)) {
$this->prefix = $prefix . ':';
$search = array("<S", "</S", "xmlns=");
$replace = array("<$prefix:S", "</$prefix:S", "xmlns:$prefix=");
$search = ["<S", "</S", "xmlns="];
$replace = ["<$prefix:S", "</$prefix:S", "xmlns:$prefix="];
$template = str_replace($search, $replace, $template);
}

Expand Down Expand Up @@ -354,7 +354,7 @@ public function canonicalizeSignedInfo()
if ($pfx = $node->getAttribute('PrefixList')) {
$arpfx = array_filter(explode(' ', $pfx));
if (count($arpfx) > 0) {
$prefixList = array_merge($prefixList ? $prefixList : array(), $arpfx);
$prefixList = array_merge($prefixList ? $prefixList : [], $arpfx);
}
}
}
Expand Down Expand Up @@ -464,7 +464,7 @@ public function processTransforms(DOMNode $refNode, DOMNode $objData, bool $incl
while ($node) {
if ($node->localName == 'InclusiveNamespaces') {
if ($pfx = $node->getAttribute('PrefixList')) {
$arpfx = array();
$arpfx = [];
$pfxlist = explode(" ", $pfx);
foreach ($pfxlist as $pfx) {
$val = trim($pfx);
Expand Down Expand Up @@ -497,9 +497,9 @@ public function processTransforms(DOMNode $refNode, DOMNode $objData, bool $incl
$node = $transform->firstChild;
while ($node) {
if ($node->localName == 'XPath') {
$arXPath = array();
$arXPath = [];
$arXPath['query'] = '(.//. | .//@* | .//namespace::*)[' . $node->nodeValue . ']';
$arXPath['namespaces'] = array();
$arXPath['namespaces'] = [];
$nslist = $xpath->query('./namespace::*', $node);
foreach ($nslist as $nsnode) {
if ($nsnode->localName != "xml") {
Expand Down Expand Up @@ -619,7 +619,7 @@ public function getRefNodeID(DOMNode $refNode): ?string
*/
public function getRefIDs(): array
{
$refids = array();
$refids = [];

$xpath = $this->getXPathObj();
$query = "./secdsig:SignedInfo[1]/secdsig:Reference";
Expand Down Expand Up @@ -660,7 +660,7 @@ public function validateReference(): bool
}

/* Initialize/reset the list of validated nodes. */
$this->validatedNodes = array();
$this->validatedNodes = [];

foreach ($nodeset as $refNode) {
if (!$this->processRefNode($refNode)) {
Expand Down Expand Up @@ -873,7 +873,7 @@ public function locateKey(DOMNode $node = null): ?XMLSecurityKey

if ($algorithm) {
try {
$objKey = new XMLSecurityKey($algorithm, array('type' => 'public'));
$objKey = new XMLSecurityKey($algorithm, ['type' => 'public']);
} catch (Exception $e) {
return null;
}
Expand Down Expand Up @@ -1047,7 +1047,7 @@ public static function staticGet509XCerts(string $certs, bool $isPEMFormat = tru
{
if ($isPEMFormat) {
$data = '';
$certlist = array();
$certlist = [];
$arCert = explode("\n", $certs);
$inData = false;

Expand All @@ -1069,7 +1069,7 @@ public static function staticGet509XCerts(string $certs, bool $isPEMFormat = tru

return $certlist;
} else {
return array($certs);
return [$certs];
}
}

Expand Down Expand Up @@ -1150,11 +1150,11 @@ public static function staticAdd509Cert(
$issuerSerial = false;
$subjectName = false;
if (is_array($options)) {
if (! empty($options['issuerSerial'])) {
if (!empty($options['issuerSerial'])) {
$issuerSerial = true;
}

if (! empty($options['subjectName'])) {
if (!empty($options['subjectName'])) {
$subjectName = true;
}
}
Expand All @@ -1169,7 +1169,7 @@ public static function staticAdd509Cert(
if ($certData) {
if ($subjectName && !empty($certData['subject'])) {
if (is_array($certData['subject'])) {
$parts = array();
$parts = [];
foreach ($certData['subject'] as $key => $value) {
if (is_array($value)) {
foreach ($value as $valueElement) {
Expand All @@ -1192,7 +1192,7 @@ public static function staticAdd509Cert(
}
if ($issuerSerial && !empty($certData['issuer']) && !empty($certData['serialNumber'])) {
if (is_array($certData['issuer'])) {
$parts = array();
$parts = [];
foreach ($certData['issuer'] as $key => $value) {
array_unshift($parts, "$key=$value");
}
Expand Down
2 changes: 1 addition & 1 deletion src/XMLSecurityKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class XMLSecurityKey
public const AUTHTAG_LENGTH = 16;

/** @var array */
private $cryptParams = array();
private $cryptParams = [];

/** @var int|string */
public $type = 0;
Expand Down

0 comments on commit 10338ad

Please sign in to comment.