Skip to content

Commit 7d5c5d3

Browse files
authored
Merge pull request #7 from LibreCodeCoop/chore/bump-php-versions
chore: bump php versions
2 parents 72c00a1 + 5362e9c commit 7d5c5d3

File tree

15 files changed

+3363
-981
lines changed

15 files changed

+3363
-981
lines changed

.github/workflows/lint-php-cs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
- name: Set up php
3333
uses: shivammathur/setup-php@1a18b2267f80291a81ca1d33e7c851fe09e7dfc4 # v2
3434
with:
35-
php-version: 8.3
35+
php-version: 8.5
3636
coverage: none
3737
env:
3838
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/lint-php.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
runs-on: ubuntu-latest
2525
strategy:
2626
matrix:
27-
php-versions: [ "8.3" ]
27+
php-versions: [ 8.5 ]
2828

2929
name: php-lint
3030

.github/workflows/phpunit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020

2121
strategy:
2222
matrix:
23-
php-versions: ['8.3']
23+
php-versions: [8.5]
2424

2525
steps:
2626
- name: Checkout

composer.lock

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Service/INSS.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* @copyright Copyright (c) 2023, Vitor Mattos <vitor@php.rio>
45
*
@@ -28,6 +29,10 @@
2829
use DateTime;
2930
use InvalidArgumentException;
3031

32+
/**
33+
* @psalm-suppress UnusedClass
34+
* @psalm-suppress ClassMustBeFinal
35+
*/
3136
class INSS
3237
{
3338
private float $baseMaxima;
@@ -53,10 +58,15 @@ private function loadTabela(string $arquivoDaTabela): void
5358
throw new InvalidArgumentException('Arquivo da tabela INSS não encontrado: ' . $arquivoDaTabela);
5459
}
5560
$data = file_get_contents($arquivoDaTabela);
61+
if ($data === false) {
62+
throw new InvalidArgumentException('Não foi possível ler o arquivo da tabela INSS: ' . $arquivoDaTabela);
63+
}
5664
if (!json_validate($data)) {
5765
throw new InvalidArgumentException('Conteúdo do arquivo da tabela INSS ser um JSON: ' . $arquivoDaTabela);
5866
}
59-
$this->tabela = json_decode($data, true);
67+
/** @var array<array-key, array<string, float>> $tabela */
68+
$tabela = json_decode($data, true);
69+
$this->tabela = $tabela;
6070
}
6171

6272
private function getBaseMaxima(): float

src/Service/IRPF.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* @copyright Copyright (c) 2023, Vitor Mattos <vitor@php.rio>
45
*
@@ -30,6 +31,9 @@
3031
/**
3132
* Calculadora de teste: https://www27.receita.fazenda.gov.br/simulador-irpf/
3233
* Fonte de dados: https://www.gov.br/receitafederal/pt-br/assuntos/meu-imposto-de-renda/tabelas
34+
*
35+
* @psalm-suppress UnusedClass
36+
* @psalm-suppress ClassMustBeFinal
3337
*/
3438
class IRPF
3539
{
@@ -56,10 +60,15 @@ private function loadTabelaProgressiva(string $arquivoDaTabelaIRPF): void
5660
throw new InvalidArgumentException('Arquivo da tabela progressiva do IRPF não encontrado: ' . $arquivoDaTabelaIRPF);
5761
}
5862
$data = file_get_contents($arquivoDaTabelaIRPF);
63+
if ($data === false) {
64+
throw new InvalidArgumentException('Não foi possível ler o arquivo da tabela progressiva do IRPF: ' . $arquivoDaTabelaIRPF);
65+
}
5966
if (!json_validate($data)) {
6067
throw new InvalidArgumentException('Conteúdo do arquivo da tabela progressiva do IRPF ser um JSON: ' . $arquivoDaTabelaIRPF);
6168
}
62-
$this->tabelaProgressiva = json_decode($data, true);
69+
/** @var array<int, list<array<string, mixed>>> $tabelaProgressiva */
70+
$tabelaProgressiva = json_decode($data, true);
71+
$this->tabelaProgressiva = $tabelaProgressiva;
6372
}
6473

6574
private function filtraTabelaProgressiva(): array
@@ -72,7 +81,12 @@ private function filtraTabelaProgressiva(): array
7281
$tabelasDoAnoBase,
7382
fn (array $t) => $this->isOnMonthInterval($t)
7483
);
75-
return current($aliquotasDoMes);
84+
$tabelaDoMes = current($aliquotasDoMes);
85+
if ($tabelaDoMes === false) {
86+
throw new InvalidArgumentException('Mês inexistente: '. $this->mes . '. Corrija a tabela progressiva do IRPF.');
87+
}
88+
89+
return $tabelaDoMes;
7690
}
7791

7892
private function isOnMonthInterval(array $row): bool
@@ -156,6 +170,7 @@ private function calculaDeducaoTradicional(float $inss, int $dependentes): float
156170
return $inss + $dependentes * $this->tabela['deducao_por_dependente'];
157171
}
158172

173+
/** @psalm-suppress PossiblyUnusedParam */
159174
public function calcula(float $base, int $dependentes): float
160175
{
161176
$faixa = $this->getFaixa($base);

src/Service/TipoProducao.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* @copyright Copyright (c) 2023, Vitor Mattos <vitor@php.rio>
45
*
@@ -25,6 +26,9 @@
2526

2627
namespace Impostos\Service;
2728

29+
/**
30+
* @psalm-suppress UnusedClass
31+
*/
2832
enum TipoProducao: int
2933
{
3034
case PRODUCAO_INTERNA = 1;

src/bootstrap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* @copyright Copyright (c) 2023, Vitor Mattos <vitor@php.rio>
45
*

tests/php/Service/INSSTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* @copyright Copyright (c) 2023, Vitor Mattos <vitor@php.rio>
45
*

tests/php/Service/IRPFTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* @copyright Copyright (c) 2023, Vitor Mattos <vitor@php.rio>
45
*

0 commit comments

Comments
 (0)