@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | public function getXmlSignatureNode(): XmlSignatureNode |
| 197 | 197 | { |
| 198 | 198 | $tag = $this->getXmlDocument()->documentElement->tagName; |
| 199 | - $xpath = '/*[local-name()="' . $tag . '"]/*[local-name()="Signature"]'; |
|
| 199 | + $xpath = '/*[local-name()="'.$tag.'"]/*[local-name()="Signature"]'; |
|
| 200 | 200 | $signatureElement = XmlUtils::xpath($this->getXmlDocument(), $xpath)->item(0); |
| 201 | 201 | if ($signatureElement === null) { |
| 202 | 202 | throw new SignatureException('El sobre del envío del XML no se encuentra firmado (no se encontró el nodo "Signature").'); |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | 'xmlns' => 'http://www.sii.cl/SiiDte', |
| 366 | 366 | 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance', |
| 367 | 367 | 'xsi:schemaLocation' => 'http://www.sii.cl/SiiDte ' |
| 368 | - . self::CONFIG[$this->tipo]['schema'] . '.xsd' |
|
| 368 | + . self::CONFIG[$this->tipo]['schema'].'.xsd' |
|
| 369 | 369 | , |
| 370 | 370 | 'version' => '1.0', |
| 371 | 371 | ], |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | * |
| 42 | 42 | * @var int|string |
| 43 | 43 | */ |
| 44 | - private int|string $codigo; |
|
| 44 | + private int | string $codigo; |
|
| 45 | 45 | |
| 46 | 46 | /** |
| 47 | 47 | * Nombre del tipo de documento. |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | * @param DataProviderInterface|null $dataProvider Proveedor de datos. |
| 132 | 132 | */ |
| 133 | 133 | public function __construct( |
| 134 | - int|string $codigo, |
|
| 134 | + int | string $codigo, |
|
| 135 | 135 | ?DataProviderInterface $dataProvider = null |
| 136 | 136 | ) { |
| 137 | 137 | $this->codigo = $codigo; |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | * |
| 156 | 156 | * @return int|string |
| 157 | 157 | */ |
| 158 | - public function getCodigo(): int|string |
|
| 158 | + public function getCodigo(): int | string |
|
| 159 | 159 | { |
| 160 | 160 | return $this->codigo; |
| 161 | 161 | } |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | * |
| 253 | 253 | * @return integer|false |
| 254 | 254 | */ |
| 255 | - public function getDefaultIndServicio(): int|false |
|
| 255 | + public function getDefaultIndServicio(): int | false |
|
| 256 | 256 | { |
| 257 | 257 | return $this->esBoleta() ? 3 : false; |
| 258 | 258 | } |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | * |
| 266 | 266 | * @return float|false |
| 267 | 267 | */ |
| 268 | - public function getDefaultTasaIVA(): float|false |
|
| 268 | + public function getDefaultTasaIVA(): float | false |
|
| 269 | 269 | { |
| 270 | 270 | $TasaIVA = 19; |
| 271 | 271 | return !in_array($this->codigo, [41, 110, 111, 112]) ? $TasaIVA : false; |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | public function setReference(?string $reference = null): self |
| 189 | 189 | { |
| 190 | 190 | // Asignar URI de la referencia (o vacia si se firma todo el XML). |
| 191 | - $uri = $reference ? ('#' . ltrim($reference, '#')) : ''; |
|
| 191 | + $uri = $reference ? ('#'.ltrim($reference, '#')) : ''; |
|
| 192 | 192 | $this->data['Signature']['SignedInfo']['Reference']['@attributes']['URI'] = $uri; |
| 193 | 193 | |
| 194 | 194 | // Asignar algoritmo de transformación al momento de obtener el C14N. |
@@ -367,7 +367,7 @@ discard block |
||
| 367 | 367 | * @return void |
| 368 | 368 | * @throws SignatureException En caso de error de DigestValue o firma. |
| 369 | 369 | */ |
| 370 | - public function validate(XmlDocument|string $xml): void |
|
| 370 | + public function validate(XmlDocument | string $xml): void |
|
| 371 | 371 | { |
| 372 | 372 | $this->validateDigestValue($xml); |
| 373 | 373 | $this->validateSignatureValue(); |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | * @return void |
| 381 | 381 | * @throws SignatureException Si el DigestValue no es válido. |
| 382 | 382 | */ |
| 383 | - public function validateDigestValue(XmlDocument|string $xml): void |
|
| 383 | + public function validateDigestValue(XmlDocument | string $xml): void |
|
| 384 | 384 | { |
| 385 | 385 | // Si se pasó un objeto XmlDocument se convierte a string. |
| 386 | 386 | if (!is_string($xml)) { |
@@ -220,11 +220,11 @@ discard block |
||
| 220 | 220 | |
| 221 | 221 | // Crear certificado autofirmado para el emisor. |
| 222 | 222 | $issuerCert = openssl_csr_sign( |
| 223 | - $issuerCsr, // CSR del emisor. |
|
| 224 | - null, // Certificado emisor (null indica que es autofirmado). |
|
| 225 | - $issuerPrivateKey, // Clave privada del emisor. |
|
| 226 | - $days, // Número de días de validez (misma sujeto). |
|
| 227 | - [], // Opciones adicionales. |
|
| 223 | + $issuerCsr, // CSR del emisor. |
|
| 224 | + null, // Certificado emisor (null indica que es autofirmado). |
|
| 225 | + $issuerPrivateKey, // Clave privada del emisor. |
|
| 226 | + $days, // Número de días de validez (misma sujeto). |
|
| 227 | + [], // Opciones adicionales. |
|
| 228 | 228 | 666 // Número de serie del certificado. |
| 229 | 229 | ); |
| 230 | 230 | |
@@ -234,11 +234,11 @@ discard block |
||
| 234 | 234 | |
| 235 | 235 | // Usar el certificado del emisor para firmar el CSR del sujeto. |
| 236 | 236 | $subjectCert = openssl_csr_sign( |
| 237 | - $subjectCsr, // La solicitud de firma del certificado (CSR). |
|
| 238 | - $issuerCert, // Certificado emisor. |
|
| 239 | - $issuerPrivateKey, // Clave privada del emisor. |
|
| 240 | - $days, // Número de días de validez. |
|
| 241 | - [], // Opciones adicionales. |
|
| 237 | + $subjectCsr, // La solicitud de firma del certificado (CSR). |
|
| 238 | + $issuerCert, // Certificado emisor. |
|
| 239 | + $issuerPrivateKey, // Clave privada del emisor. |
|
| 240 | + $days, // Número de días de validez. |
|
| 241 | + [], // Opciones adicionales. |
|
| 242 | 242 | 69 // Número de serie del certificado. |
| 243 | 243 | ); |
| 244 | 244 | |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | public static function sign( |
| 46 | 46 | string $data, |
| 47 | 47 | string $privateKey, |
| 48 | - string|int $signatureAlgorithm = OPENSSL_ALGO_SHA1 |
|
| 48 | + string | int $signatureAlgorithm = OPENSSL_ALGO_SHA1 |
|
| 49 | 49 | ): string { |
| 50 | 50 | // Firmar los datos. |
| 51 | 51 | $signature = null; |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | * @throws SignatureException Si ocurre algún problema al firmar. |
| 78 | 78 | */ |
| 79 | 79 | public static function signXML( |
| 80 | - XmlDocument|string $xml, |
|
| 80 | + XmlDocument | string $xml, |
|
| 81 | 81 | Certificate $certificate, |
| 82 | 82 | ?string $reference = null |
| 83 | 83 | ): string { |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | ): string { |
| 136 | 136 | // Se hará la digestión de una referencia (ID) específico en el XML. |
| 137 | 137 | if (!empty($reference)) { |
| 138 | - $xpath = '//*[@ID="' . ltrim($reference, '#') . '"]'; |
|
| 138 | + $xpath = '//*[@ID="'.ltrim($reference, '#').'"]'; |
|
| 139 | 139 | $dataToDigest = $doc->C14NWithIsoEncoding($xpath); |
| 140 | 140 | } |
| 141 | 141 | // Cuando no hay referencia, el digest es sobre todo el documento XML. |
@@ -51,9 +51,9 @@ discard block |
||
| 51 | 51 | ): string { |
| 52 | 52 | if (!str_contains($publicKey, '-----BEGIN CERTIFICATE-----')) { |
| 53 | 53 | $body = trim($publicKey); |
| 54 | - $publicKey = '-----BEGIN CERTIFICATE-----' . "\n"; |
|
| 55 | - $publicKey .= self::wordwrap($body, $wordwrap) . "\n"; |
|
| 56 | - $publicKey .= '-----END CERTIFICATE-----' . "\n"; |
|
| 54 | + $publicKey = '-----BEGIN CERTIFICATE-----'."\n"; |
|
| 55 | + $publicKey .= self::wordwrap($body, $wordwrap)."\n"; |
|
| 56 | + $publicKey .= '-----END CERTIFICATE-----'."\n"; |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | return $publicKey; |
@@ -72,9 +72,9 @@ discard block |
||
| 72 | 72 | ): string { |
| 73 | 73 | if (!str_contains($privateKey, '-----BEGIN PRIVATE KEY-----')) { |
| 74 | 74 | $body = trim($privateKey); |
| 75 | - $privateKey = '-----BEGIN PRIVATE KEY-----' . "\n"; |
|
| 76 | - $privateKey .= self::wordwrap($body, $wordwrap) . "\n"; |
|
| 77 | - $privateKey .= '-----END PRIVATE KEY-----' . "\n"; |
|
| 75 | + $privateKey = '-----BEGIN PRIVATE KEY-----'."\n"; |
|
| 76 | + $privateKey .= self::wordwrap($body, $wordwrap)."\n"; |
|
| 77 | + $privateKey .= '-----END PRIVATE KEY-----'."\n"; |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | return $privateKey; |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | string $data, |
| 47 | 47 | string $signature, |
| 48 | 48 | string $publicKey, |
| 49 | - string|int $signatureAlgorithm = OPENSSL_ALGO_SHA1 |
|
| 49 | + string | int $signatureAlgorithm = OPENSSL_ALGO_SHA1 |
|
| 50 | 50 | ): bool { |
| 51 | 51 | $publicKey = CertificateUtils::normalizePublicKey($publicKey); |
| 52 | 52 | |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | * @return void |
| 74 | 74 | * @throws SignatureException Si hubo un error al hacer la verificación. |
| 75 | 75 | */ |
| 76 | - public static function validateXml(XmlDocument|string $xml): void |
|
| 76 | + public static function validateXml(XmlDocument | string $xml): void |
|
| 77 | 77 | { |
| 78 | 78 | // Si se pasó un objeto XmlDocument se convierte a string. |
| 79 | 79 | if (!is_string($xml)) { |