1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Exemplo de uso |
4
|
|
|
* |
5
|
|
|
* Leitura do arquivo de lote |
6
|
|
|
* |
7
|
|
|
* @author Thiago Paes <[email protected]> |
8
|
|
|
*/ |
9
|
|
|
use MrPrompt\ShipmentCommon\Base\Sequence; |
10
|
|
|
use MrPrompt\Centercob\Shipment\File; |
11
|
|
|
use MrPrompt\Centercob\Factory; |
12
|
|
|
|
13
|
|
|
require __DIR__ . '/bootstrap.php'; |
14
|
|
|
|
15
|
|
|
/* @var $lista array */ |
16
|
|
|
$lista = require __DIR__ . '/cart.php'; |
17
|
|
|
|
18
|
|
|
try { |
19
|
|
|
/* @var $date \DateTime */ |
20
|
|
|
$date = new DateTime('2015-05-27'); |
21
|
|
|
|
22
|
|
|
/* @var $sequence \MrPrompt\ShipmentCommon\Base\Sequence */ |
23
|
|
|
$sequence = new Sequence(6); |
24
|
|
|
|
25
|
|
|
/* @var $customer \MrPrompt\ShipmentCommon\Base\Customer */ |
26
|
|
|
$customer = Factory::createCustomerFromArray(array_shift($lista)); |
27
|
|
|
|
28
|
|
|
/* @var $importer \MrPrompt\Centercob\Shipment\File */ |
29
|
|
|
$importer = new File($customer, $sequence, $date, __DIR__ . '/enviados', File::TEMPLATE_PROCESSED); |
|
|
|
|
30
|
|
|
|
31
|
|
|
// importing file data |
32
|
|
|
$result = $importer->read(); |
33
|
|
|
|
34
|
|
|
/* @var \MrPrompt\ShipmentCommon\Base\Cart */ |
35
|
|
|
$cart = $importer->getCart(); |
36
|
|
|
|
37
|
|
|
/* @var $lista array */ |
38
|
|
|
$lista = []; |
39
|
|
|
|
40
|
|
|
/* @var $item \MrPrompt\Centercob\Shipment\Partial\Detail */ |
41
|
|
|
foreach ($cart as $item) { |
42
|
|
|
/* @var $detail array */ |
43
|
|
|
$detail = Factory::createArrayFromDetail($item);; |
44
|
|
|
|
45
|
|
|
$lista[] = $detail; |
46
|
|
|
|
47
|
|
|
echo 'Tipo: ', $detail['cobranca'], PHP_EOL; |
48
|
|
|
echo 'Comprador: ', $detail['comprador']['nome'], PHP_EOL; |
49
|
|
|
echo 'Parcelas: ', PHP_EOL; |
50
|
|
|
|
51
|
|
|
foreach ($detail['parcelas'] as $parcel) { |
52
|
|
|
echo ' # ', key($detail['parcelas']), PHP_EOL; |
53
|
|
|
echo ' R$ ', number_format($parcel[ 'valor'], 2, ',', '.'), PHP_EOL; |
54
|
|
|
echo ' Qtd ', (int) $parcel['quantidade'], PHP_EOL; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
echo 'Status: ', $detail['descricao'], PHP_EOL; |
58
|
|
|
echo PHP_EOL, PHP_EOL; |
59
|
|
|
} |
60
|
|
|
} catch (\InvalidArgumentException $ex) { |
61
|
|
|
echo sprintf('Erro: %s in file: %s - line: %s', $ex->getMessage(), $ex->getFile(), $ex->getLine()), PHP_EOL; |
62
|
|
|
} |
63
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.