upgrade symfony
This commit is contained in:
@@ -8,9 +8,7 @@ use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
class IndexController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* @Route("/", name="homepage")
|
||||
*/
|
||||
#[Route(path: '/', name: 'homepage')]
|
||||
public function index() : Response
|
||||
{
|
||||
return $this->render("index/index.html.twig");
|
||||
|
||||
@@ -20,9 +20,7 @@ use Symfony\Component\Validator\Constraints\File;
|
||||
|
||||
class TaxesController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* @Route("/taxes/{type}", name="app_taxes")
|
||||
*/
|
||||
#[Route(path: '/taxes/{type}', name: 'app_taxes')]
|
||||
public function index(Request $request, string $type): Response
|
||||
{
|
||||
if (!in_array($type, ["crypto", "dividend"])) {
|
||||
@@ -63,7 +61,7 @@ class TaxesController extends AbstractController
|
||||
$form->handleRequest($request);
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
$files = $form->get('uploads')->getData();
|
||||
$hash = substr(md5(rand()),0,16);
|
||||
$hash = substr(md5(random_int(0, mt_getrandmax())),0,16);
|
||||
if ($files) {
|
||||
$i=1;
|
||||
/** @var UploadedFile $file */
|
||||
@@ -90,9 +88,7 @@ class TaxesController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/taxes/dividend/{hash}", name="app_taxes_dividend_show")
|
||||
*/
|
||||
#[Route(path: '/taxes/dividend/{hash}', name: 'app_taxes_dividend_show')]
|
||||
public function showDividend(DividendsService $tax) : Response
|
||||
{
|
||||
if ($tax->readFiles()) {
|
||||
@@ -109,9 +105,7 @@ class TaxesController extends AbstractController
|
||||
}
|
||||
return new Response("error");
|
||||
}
|
||||
/**
|
||||
* @Route("/taxes/crypto/{hash}", name="app_taxes_crypto_show")
|
||||
*/
|
||||
#[Route(path: '/taxes/crypto/{hash}', name: 'app_taxes_crypto_show')]
|
||||
public function showCrypto(CryptoService $tax) : Response
|
||||
{
|
||||
if ($tax->readFiles()) {
|
||||
|
||||
@@ -6,32 +6,23 @@ use App\Repository\ExchangeRatesRepository;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Doctrine\ORM\Mapping\Index;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass=ExchangeRatesRepository::class)
|
||||
* @ORM\Table(indexes={@Index(name="currency", columns={"date_date","str_currency"})})
|
||||
*/
|
||||
#[ORM\Table]
|
||||
#[Index(columns: ['date_date', 'str_currency'], name: 'currency')]
|
||||
#[ORM\Entity(repositoryClass: ExchangeRatesRepository::class)]
|
||||
class ExchangeRates
|
||||
{
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
* @ORM\Column(type="integer")
|
||||
*/
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column(type: 'integer')]
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", length=3)
|
||||
*/
|
||||
#[ORM\Column(type: 'string', length: 3)]
|
||||
private $strCurrency;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="float")
|
||||
*/
|
||||
#[ORM\Column(type: 'float')]
|
||||
private $intRate;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="date")
|
||||
*/
|
||||
#[ORM\Column(type: 'date')]
|
||||
private $dateDate;
|
||||
|
||||
public function getId(): ?int
|
||||
|
||||
@@ -10,12 +10,10 @@ class Currency
|
||||
public static array $currencies = ["USD","GBP","PLN","EUR","CAD","AUD"];
|
||||
public static array $currenciesCrypto = ["USDT"];
|
||||
private static string $apiUrl = "https://api.nbp.pl/api/exchangerates/rates/a/:code/:date/?format=json";
|
||||
private EntityManager $manager;
|
||||
private array $ratesPerDate;
|
||||
|
||||
public function __construct(EntityManager $manager)
|
||||
public function __construct(private readonly EntityManager $manager)
|
||||
{
|
||||
$this->manager = $manager;
|
||||
$this->takeRates();
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ final class CryptoValues
|
||||
}
|
||||
$ret = false;
|
||||
foreach (self::$values[$type] as $value) {
|
||||
if (strpos($text,$value) !== false) {
|
||||
if (str_contains($text,(string) $value)) {
|
||||
$ret = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ class DividendValues
|
||||
$val = trim($val);
|
||||
foreach (self::$samples as $key => $sample) {
|
||||
foreach ($sample as $item) {
|
||||
if (strpos($val, $item) !== false) {
|
||||
if (str_contains($val, (string) $item)) {
|
||||
$ret = $key;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ class NeedFileName
|
||||
$name = null;
|
||||
$fileName = strtolower($fileName);
|
||||
foreach (self::NAMES as $str) {
|
||||
if (strpos($fileName, $str) !== false) {
|
||||
if (str_contains($fileName, $str)) {
|
||||
$name = $str;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ class Main
|
||||
}
|
||||
if ($name === "setValue") {
|
||||
$data = "$datum[$key]";
|
||||
if (strpos($data,",") !== false || strpos($data,".") !== false) {
|
||||
if (str_contains($data,",") || str_contains($data,".")) {
|
||||
$data = str_replace(",",".",$data);
|
||||
}
|
||||
$realInt = floatval($data)*MainObject::_CRYPTO_DIVIDER;
|
||||
@@ -89,7 +89,7 @@ class Main
|
||||
}
|
||||
if ($name === "setPrice" && is_string($datum[$key])) {
|
||||
$val = $datum[$key];
|
||||
if (strpos($val, ".") !== false && strpos($val, ",") !== false) {
|
||||
if (str_contains($val, ".") && str_contains($val, ",")) {
|
||||
$val = str_replace(",", "", $val);
|
||||
$datum[$key] = intval(floatval($val)*100);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ class DividendsSummary
|
||||
private array $sheetData=[];
|
||||
/** @var XMLReader|array $sheetData */
|
||||
private array $xmlData=[];
|
||||
private Currency $currencyObj;
|
||||
private readonly Currency $currencyObj;
|
||||
/** @var array|DividendsData $error */
|
||||
private ?array $errorDividend=null;
|
||||
private ?array $errorString=null;
|
||||
|
||||
@@ -14,7 +14,7 @@ class ExanteSheet extends SheetDataAll
|
||||
continue;
|
||||
}
|
||||
foreach ($rawDatum as $key => $value) {
|
||||
$value = strtolower($value);
|
||||
$value = strtolower((string) $value);
|
||||
if (str_contains($value, "comment")) {
|
||||
$commentKey = $key;
|
||||
}
|
||||
@@ -28,15 +28,15 @@ class ExanteSheet extends SheetDataAll
|
||||
if ($index<2) {
|
||||
continue;
|
||||
}
|
||||
$operationType = strtolower($rawDatum[$operationKey]);
|
||||
$operationType = strtolower((string) $rawDatum[$operationKey]);
|
||||
if (!str_contains($operationType,"dividend")) {
|
||||
continue;
|
||||
}
|
||||
$comment = $rawDatum[$commentKey];
|
||||
if (!str_contains($comment, "dividend")) {
|
||||
if (!str_contains((string) $comment, "dividend")) {
|
||||
continue;
|
||||
}
|
||||
$separate = explode(" ",$comment);
|
||||
$separate = explode(" ",(string) $comment);
|
||||
$tax = intval(str_replace(["(","-","%",")"],"",$separate[16]));
|
||||
$value = floatval(str_replace(["(",")"],"",$separate[10]));
|
||||
$date = new \DateTime($separate[3]);
|
||||
|
||||
@@ -39,7 +39,7 @@ class IbkrSheet extends SheetDataAll
|
||||
}
|
||||
}
|
||||
$test[$row['groupId']][] = $row['amount'];
|
||||
if (str_contains($row['type'], "Dividend")) {
|
||||
if (str_contains((string) $row['type'], "Dividend")) {
|
||||
$dividendArr[$row['groupId']] = $row;
|
||||
} else {
|
||||
if (!isset($taxArr[$row['groupId']])) {
|
||||
@@ -61,7 +61,7 @@ class IbkrSheet extends SheetDataAll
|
||||
$taxPercentage = 19;
|
||||
}
|
||||
|
||||
$separate = explode(" ", $dividend['description']);
|
||||
$separate = explode(" ", (string) $dividend['description']);
|
||||
$perShare = floatval($separate[4]);
|
||||
if (!$perShare) {
|
||||
$perShare = floatval($separate[5]);
|
||||
@@ -69,7 +69,7 @@ class IbkrSheet extends SheetDataAll
|
||||
if (!$perShare) {
|
||||
continue;
|
||||
}
|
||||
$date = explode(";", $dividend['date'])[0];
|
||||
$date = explode(";", (string) $dividend['date'])[0];
|
||||
if (substr_count($date, "-") !== 2) {
|
||||
$date = substr($date, 0, 4) . "-" . substr($date, 4, 2) . "-" . substr($date, 6, 2);
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ class SheetData extends SheetDataAll
|
||||
$count++;
|
||||
return $ret;
|
||||
}
|
||||
if (in_array(mb_substr($data, 0, 2), ['CA', 'US', 'IE', 'GB']) && intval(mb_substr($data, 2, 1))>0) {
|
||||
if (in_array(mb_substr((string) $data, 0, 2), ['CA', 'US', 'IE', 'GB']) && intval(mb_substr((string) $data, 2, 1))>0) {
|
||||
$count = &$setDatas['data'];
|
||||
$ret = "isin";
|
||||
if ($count > 0) {
|
||||
@@ -106,7 +106,7 @@ class SheetData extends SheetDataAll
|
||||
if (in_array($data, Currency::$currencies)) {
|
||||
return "currency";
|
||||
}
|
||||
if (count(explode(".", $data)) === 3 || count(explode("-", $data)) === 3) {
|
||||
if (count(explode(".", (string) $data)) === 3 || count(explode("-", (string) $data)) === 3) {
|
||||
return "date";
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ class SheetData extends SheetDataAll
|
||||
$ret = -1;
|
||||
|
||||
foreach ($this->takeColumnNames() as $index => $takeColumnName) {
|
||||
if (strpos($takeColumnName,"DATE") !== false || strpos($takeColumnName,"DATA") !== false) {
|
||||
if (str_contains((string) $takeColumnName,"DATE") || str_contains((string) $takeColumnName,"DATA")) {
|
||||
$ret = $index;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -12,16 +12,14 @@ abstract class SheetDataAll
|
||||
*/
|
||||
protected array $data = [];
|
||||
protected array $dataNotCalculate = [];
|
||||
private array $rawData;
|
||||
|
||||
/**
|
||||
* Assign raw data to field, then create array of DividendsData
|
||||
*
|
||||
* @param array $rawData
|
||||
*/
|
||||
public function __construct(array $rawData)
|
||||
public function __construct(private readonly array $rawData)
|
||||
{
|
||||
$this->rawData = $rawData;
|
||||
$this->countData = count($this->rawData) - 1;
|
||||
$this->data = $this->takeData();
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ class XMLReader
|
||||
$obj->setCurrency($value);
|
||||
}
|
||||
if ($key === "payDate") {
|
||||
$tmp = str_split($value, 4);
|
||||
$tmp = str_split((string) $value, 4);
|
||||
$y=$tmp[0];
|
||||
$tmp = str_split($tmp[1],2);
|
||||
$d = $tmp[1];
|
||||
|
||||
@@ -18,7 +18,7 @@ class DividendsService extends MasterServices
|
||||
$summaryObj = new DividendsSummary($this->manager);
|
||||
|
||||
foreach ($this->allFiles as $file) {
|
||||
$extension = pathinfo($file)['extension'];
|
||||
$extension = pathinfo((string) $file)['extension'];
|
||||
$market = MarketNames::tryFromCase($file);
|
||||
|
||||
if (in_array($extension, ['xlsx','csv'])) {
|
||||
|
||||
@@ -6,15 +6,11 @@ use Doctrine\ORM\EntityManager;
|
||||
|
||||
class MasterServices
|
||||
{
|
||||
protected EntityManager $manager;
|
||||
protected string $hashParam;
|
||||
protected string $uploadPath;
|
||||
protected array $allFiles;
|
||||
|
||||
public function __construct(EntityManager $entity,string $hash)
|
||||
public function __construct(protected EntityManager $manager, protected string $hashParam)
|
||||
{
|
||||
$this->manager = $entity;
|
||||
$this->hashParam = $hash;
|
||||
}
|
||||
|
||||
public function setUploadsPath(string $path)
|
||||
|
||||
@@ -11,7 +11,7 @@ class AppExtension extends AbstractExtension
|
||||
public function getFilters(): array
|
||||
{
|
||||
return [
|
||||
new TwigFilter("price", [$this, 'formatPrice'])
|
||||
new TwigFilter("price", $this->formatPrice(...))
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user