From 3a452b9c0b8e8a7f30807abeaa2dee24dafd89cd Mon Sep 17 00:00:00 2001 From: Esteban De La Fuente Rubio Date: Thu, 5 Dec 2024 12:56:57 -0300 Subject: [PATCH] =?UTF-8?q?Se=20agrega=20user-agent=20seg=C3=BAn=20est?= =?UTF-8?q?=C3=A1ndar.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 3 +-- src/Sii/HttpClient/SiiClient.php | 5 ----- src/Sii/HttpClient/WebService/DocumentUploader.php | 3 +-- src/Sii/HttpClient/WsdlConsumer.php | 6 +++--- src/Xml/XmlEncoder.php | 6 +++++- 5 files changed, 10 insertions(+), 13 deletions(-) diff --git a/composer.json b/composer.json index e39cf23d..2df09007 100644 --- a/composer.json +++ b/composer.json @@ -41,8 +41,7 @@ "symfony/cache": "^7.1", "symfony/filesystem": "^7.1", "symfony/mime": "^7.1", - "symfony/yaml": "^7.1", - "tecnickcom/tcpdf": "^6.7" + "symfony/yaml": "^7.1" }, "require-dev": { "ext-xdebug": "*", diff --git a/src/Sii/HttpClient/SiiClient.php b/src/Sii/HttpClient/SiiClient.php index a486690d..7cabd0b6 100644 --- a/src/Sii/HttpClient/SiiClient.php +++ b/src/Sii/HttpClient/SiiClient.php @@ -167,11 +167,6 @@ public function getDocumentValidator(): DocumentValidator * Entrega una instancia con la implementación de una caché para ser * utilizada en la biblioteca. * - * NOTE: Este método a propósito tiene las clases con su FQCN y no utiliza - * los use. Esto es para que PHP no cargue las clases automáticamente a - * menos que realmente se vayan a utilizar. Pues en una situación normal, - * la caché debería ser inyectada y no usarse las opciones por defecto. - * * @return CacheInterface Implementación de caché PSR-16. */ private function getCache(): CacheInterface diff --git a/src/Sii/HttpClient/WebService/DocumentUploader.php b/src/Sii/HttpClient/WebService/DocumentUploader.php index e1dff516..eaa54c36 100755 --- a/src/Sii/HttpClient/WebService/DocumentUploader.php +++ b/src/Sii/HttpClient/WebService/DocumentUploader.php @@ -249,8 +249,7 @@ private function uploadXml(array $data, int $retry): XmlDocument // Cabeceras HTTP de la solicitud que se hará al SII. $headers = [ - 'User-Agent: Mozilla/4.0 (compatible; PROG 1.0; LibreDTE)', - 'Referer: https://www.libredte.cl', + 'User-Agent: Mozilla/5.0 (compatible; PROG 1.0; +https://www.libredte.cl)', 'Cookie: TOKEN=' . $token, ]; diff --git a/src/Sii/HttpClient/WsdlConsumer.php b/src/Sii/HttpClient/WsdlConsumer.php index 84d87c2c..adcbe2a4 100644 --- a/src/Sii/HttpClient/WsdlConsumer.php +++ b/src/Sii/HttpClient/WsdlConsumer.php @@ -226,8 +226,9 @@ public function sendRequest( ?int $retry = null ): XmlDocument { // Revisar si se pasó en $args el valor de $retry. + // @scrutinizer ignore-type-check if (is_int($args)) { - $retry = (int) $args; + $retry = $args; $args = []; } @@ -383,8 +384,7 @@ private function createSoapClientOptions(): array 'stream_context' => [ 'http' => [ 'header' => [ - 'User-Agent: Mozilla/4.0 (compatible; PROG 1.0; LibreDTE)', - 'Referer: https://www.libredte.cl', + 'User-Agent: Mozilla/5.0 (compatible; PROG 1.0; +https://www.libredte.cl)', ], ], ], diff --git a/src/Xml/XmlEncoder.php b/src/Xml/XmlEncoder.php index c8a7adaa..5825ca10 100644 --- a/src/Xml/XmlEncoder.php +++ b/src/Xml/XmlEncoder.php @@ -88,7 +88,11 @@ public static function encode( if ($key === '@attributes') { // Solo se agregan atributos si el valor es un arreglo. if (is_array($value)) { - self::nodeAddAttributes($parent, $value); + // En la primera iteración de recursividad se debe revisar + // que $parent sea DOMElement. Y solo en ese caso seguir. + if ($parent instanceof DOMElement) { + self::nodeAddAttributes($parent, $value); + } } }