Code improvements (#1649)
* use global namespace for faster lookups * phpstan level 5
This commit is contained in:
@@ -36,13 +36,13 @@ class ShortInvoiceCalculator extends AbstractMergedCalculator implements Calcula
|
||||
if (null !== $entry->getFixedRate()) {
|
||||
$key = 'fixed_' . (string) $entry->getFixedRate();
|
||||
}
|
||||
if (!in_array($key, $keys)) {
|
||||
if (!\in_array($key, $keys)) {
|
||||
$keys[] = $key;
|
||||
}
|
||||
$this->mergeInvoiceItems($invoiceItem, $entry);
|
||||
}
|
||||
|
||||
if (count($keys) > 1) {
|
||||
if (\count($keys) > 1) {
|
||||
$invoiceItem->setAmount(1);
|
||||
$invoiceItem->setFixedRate($invoiceItem->getRate());
|
||||
$invoiceItem->setHourlyRate($invoiceItem->getRate());
|
||||
|
||||
@@ -67,9 +67,12 @@ final class ConfigurableNumberGenerator implements NumberGeneratorInterface
|
||||
|
||||
// number format
|
||||
if (substr_count($tmp, ',') !== 0) {
|
||||
$formatter = explode(',', $tmp);
|
||||
$tmp = $formatter[0];
|
||||
$formatter = $formatter[1];
|
||||
$parts = explode(',', $tmp);
|
||||
$tmp = $parts[0];
|
||||
$formatter = \intval($parts[1]);
|
||||
if ((string) $formatter !== $parts[1]) {
|
||||
$formatter = null;
|
||||
}
|
||||
}
|
||||
|
||||
switch ($tmp) {
|
||||
|
||||
@@ -45,7 +45,7 @@ abstract class AbstractSpreadsheetRenderer extends AbstractRenderer
|
||||
$worksheet = $spreadsheet->getActiveSheet();
|
||||
$entries = $model->getCalculator()->getEntries();
|
||||
$sheetReplacer = $model->toArray();
|
||||
$invoiceItemCount = count($entries);
|
||||
$invoiceItemCount = \count($entries);
|
||||
if ($invoiceItemCount > 1) {
|
||||
$this->addTemplateRows($worksheet, $invoiceItemCount);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ class AdvancedValueBinder extends DefaultValueBinder implements IValueBinder
|
||||
*/
|
||||
public function bindValue(Cell $cell, $value = null)
|
||||
{
|
||||
if (is_string($value)) {
|
||||
if (\is_string($value)) {
|
||||
$value = StringHelper::sanitizeUTF8($value);
|
||||
}
|
||||
|
||||
|
||||
@@ -41,10 +41,10 @@ final class DocxRenderer extends AbstractRenderer implements RendererInterface
|
||||
}
|
||||
|
||||
try {
|
||||
$template->cloneRow('entry.description', count($model->getCalculator()->getEntries()));
|
||||
$template->cloneRow('entry.description', \count($model->getCalculator()->getEntries()));
|
||||
} catch (OfficeException $ex) {
|
||||
try {
|
||||
$template->cloneRow('entry.row', count($model->getCalculator()->getEntries()));
|
||||
$template->cloneRow('entry.row', \count($model->getCalculator()->getEntries()));
|
||||
} catch (OfficeException $ex) {
|
||||
@trigger_error(
|
||||
sprintf('Invoice document (%s) did not contain a clone row, was that on purpose?', $document->getFilename())
|
||||
|
||||
@@ -206,7 +206,7 @@ final class ServiceInvoice
|
||||
continue;
|
||||
}
|
||||
$filename = explode('filename=', $part);
|
||||
if (count($filename) > 1) {
|
||||
if (\count($filename) > 1) {
|
||||
$filename = $filename[1];
|
||||
}
|
||||
}
|
||||
@@ -233,7 +233,7 @@ final class ServiceInvoice
|
||||
|
||||
public function changeInvoiceStatus(Invoice $invoice, string $status)
|
||||
{
|
||||
if (!in_array($status, [Invoice::STATUS_NEW, Invoice::STATUS_PENDING, Invoice::STATUS_PAID])) {
|
||||
if (!\in_array($status, [Invoice::STATUS_NEW, Invoice::STATUS_PENDING, Invoice::STATUS_PAID])) {
|
||||
throw new \InvalidArgumentException('Unknown invoice status');
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ final class ServiceInvoice
|
||||
|
||||
/**
|
||||
* @param InvoiceQuery $query
|
||||
* @return InvoiceItemInterface[]
|
||||
* @return array<string, InvoiceItemInterface[]>
|
||||
*/
|
||||
private function findInvoiceItemsWithRepository(InvoiceQuery $query): array
|
||||
{
|
||||
@@ -278,7 +278,7 @@ final class ServiceInvoice
|
||||
$items = [];
|
||||
|
||||
foreach ($repositories as $repository) {
|
||||
$items[get_class($repository)] = $repository->getInvoiceItemsForQuery($query);
|
||||
$items[\get_class($repository)] = $repository->getInvoiceItemsForQuery($query);
|
||||
}
|
||||
|
||||
return $items;
|
||||
@@ -301,7 +301,7 @@ final class ServiceInvoice
|
||||
}
|
||||
|
||||
/**
|
||||
* @param InvoiceItemInterface[] $entries
|
||||
* @param array<string, InvoiceItemInterface[]> $entries
|
||||
*/
|
||||
private function markEntriesAsExported(iterable $entries)
|
||||
{
|
||||
@@ -309,7 +309,7 @@ final class ServiceInvoice
|
||||
|
||||
foreach ($entries as $repo => $items) {
|
||||
foreach ($repositories as $repository) {
|
||||
if (get_class($repository) === $repo) {
|
||||
if (\get_class($repository) === $repo) {
|
||||
$repository->setExported($items);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user