Skip to content

Commit

Permalink
Updates to work with PHP >= 7
Browse files Browse the repository at this point in the history
  • Loading branch information
stavarengo committed Aug 30, 2017
1 parent a1293aa commit 10f6484
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 956 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ tmp/
vendor/
/.idea
/nbproject/private/
nbproject/
nbproject/
composer.phar
composer.lock
9 changes: 7 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
"type": "library",
"description": "Integração com Web Service do Correios. Gera etiquetas, consulta preços e prazos, imprime etiquetas e PLP, etc.",
"keywords": ["correios", "sigep"],
"minimum-stability": "stable",
"prefer-stable": true,
"config": {
"sort-packages": true
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev",
Expand All @@ -12,6 +17,7 @@
},
"require": {
"php": ">=5.4",
"ext-soap": "*",
"stavarengo/php-sigep-fpdf": "dev-master"
},
"autoload": {
Expand All @@ -25,6 +31,5 @@
"name": "Rafael Stavarengo",
"email": "[email protected]"
}
],
"minimum-stability": "stable"
]
}
105 changes: 0 additions & 105 deletions composer.lock

This file was deleted.

Binary file removed composer.phar
Binary file not shown.
Binary file removed exemplos/etiquetas.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion exemplos/geraChancelas.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@
$pac = new \PhpSigep\Pdf\Chancela\Pac(50, 100, 'Layout antigo', $accessData);
$pac->draw($pdf);

$pdf->Output('chancelas.pdf', 'F');
$pdf->Output();
2 changes: 1 addition & 1 deletion exemplos/imprimirEtiquetas.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
$layoutChancela = array(\PhpSigep\Pdf\CartaoDePostagem::TYPE_CHANCELA_CARTA);

$pdf = new \PhpSigep\Pdf\CartaoDePostagem($params, time(), $logoFile, $layoutChancela);
$pdf->render('F', 'etiquetas.pdf');
$pdf->render();
2 changes: 1 addition & 1 deletion exemplos/imprimirEtiquetas2016.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
$layoutChancela = array(); //array(\PhpSigep\Pdf\CartaoDePostagem2016::TYPE_CHANCELA_SEDEX_2016);

$pdf = new \PhpSigep\Pdf\CartaoDePostagem2016($params, time(), $logoFile, $layoutChancela);
$pdf->render('F', 'etiquetas.pdf');
$pdf->render();
2 changes: 1 addition & 1 deletion exemplos/imprimirEtiquetasA4.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

$pdf = new \PhpSigep\Pdf\CartaoDePostagem2016($params, time(), $logoFile, $layoutChancela);

$fileName = 'etiquetas.pdf';
$fileName = tempnam(sys_get_temp_dir(), 'phpsigep') . '.pdf';
$pdf->render('F',$fileName);

unset($pdf);
Expand Down
10 changes: 10 additions & 0 deletions src/PhpSigep/Pdf/Semacode.php
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,8 @@ function ecc200encode(&$t, &$tl, $s, $sl, $e) {
$v = 0;
$w = 0;

$oldErrorReporting = error_reporting(0);

//does not work, but is said to be optional, doesn't work in the JS code either because of a typo
// if ($e['encodingLength'] < $sl)
// {
Expand Down Expand Up @@ -604,6 +606,9 @@ function ecc200encode(&$t, &$tl, $s, $sl, $e) {
$v -= 254;
$t[$tp++] = $v;
}

error_reporting($oldErrorReporting);

if ($tp > $tl || $sp < $sl) // did not fit
return 0;
// OK
Expand All @@ -629,6 +634,9 @@ function encodingList($l, $s, $exact) {
// not valid
return null;

// Turn off all error reporting
$oldErrorReporting = error_reporting(0);

//$this->debug("l: " . $l);
//$this->debug("s: " . $s);
$enc = array_fill(0, $this->MAXBARCODE, 0);
Expand Down Expand Up @@ -951,6 +959,8 @@ function encodingList($l, $s, $exact) {
$encoding[$p] = 0;
$encoder['encoding'] = $encoding;

error_reporting($oldErrorReporting);

return $encoder;
}

Expand Down
13 changes: 13 additions & 0 deletions src/PhpSigep/Services/Real/Exception/SoapExtensionNotInstalled.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
/**
* php-sigep Project ${PROJECT_URL}
*
* @link ${GITHUB_URL} Source code
*/

namespace PhpSigep\Services\Real\Exception;

class SoapExtensionNotInstalled extends \Exception
{

}
5 changes: 5 additions & 0 deletions src/PhpSigep/Services/Real/SoapClientFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

use PhpSigep\Bootstrap;
use PhpSigep\Config;
use PhpSigep\Services\Real\Exception\SoapExtensionNotInstalled;

class SoapClientFactory
{
Expand All @@ -31,6 +32,10 @@ class SoapClientFactory
public static function getSoapClient()
{
if (!self::$_soapClient) {
if (!extension_loaded('soap')) {
throw new SoapExtensionNotInstalled('The "soap" module must be enabled in your PHP installation. The "soap" module is required in order to PHPSigep to make requests to the Correios WebService.');
}

$wsdl = Bootstrap::getConfig()->getWsdlAtendeCliente();

$opts = array(
Expand Down
Loading

0 comments on commit 10f6484

Please sign in to comment.