Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/AbraFlexi/RO.php
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ class RO extends \Ease\Sand
* Class for read only interaction with AbraFlexi.
*
* @param mixed $init default record id or initial data. See processInit()
* @param array<string, int|string|true> $options Connection settings and other options override
* @param array<string, mixed> $options Connection settings and other options override
*/
public function __construct($init = null, $options = [])
{
Expand Down
2 changes: 1 addition & 1 deletion src/AbraFlexi/RW.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class RW extends RO
/**
* SetUp Object to be ready for work.
*
* @param array $options Object Options (authSessionId,user,password,
* @param array<mixed> $options Object Options (authSessionId,user,password,
* url,company,evidence,companyUrl
* prefix,defaultUrlParams,debug,ver,dry-run
* detail,offline,atomic,filter,ignore404
Expand Down
6 changes: 6 additions & 0 deletions src/AbraFlexi/Relations.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class Relations

/**
* Evidence adresar (Adresy firem) Relations.
*
* @var array<string,array<string,string>>
*/
public static array $adresar = [
'odberatele' => [
Expand Down Expand Up @@ -94,6 +96,8 @@ class Relations

/**
* Evidence atribut (Atributy) Relations.
*
* @var array<string,array<string,string>>
*/
public static array $atribut = [
'uzivatelske-vazby' => [
Expand All @@ -105,6 +109,8 @@ class Relations

/**
* Evidence autotisk (Automatický tisk) Relations.
*
* @var array<string,array<string,string>>
*/
public static array $autotisk = [
'uzivatelske-vazby' => [
Expand Down
12 changes: 7 additions & 5 deletions src/AbraFlexi/Stitek.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Stitek extends RW
{
/**
* Evidence Path for vsb supported by label.
* @var array<string,string>
*/
public static array $vsbToEvidencePath = [
'vsbAdr' => 'adresar', // Adresář
Expand Down Expand Up @@ -56,7 +57,8 @@ class Stitek extends RW
/**
* Convert coma-separated list to array.
*
* @param array|string $listRaw
* @param array<mixed>|string $listRaw
* @return array<mixed>
*/
public static function listToArray($listRaw): array
{
Expand All @@ -80,7 +82,7 @@ public static function listToArray($listRaw): array
*
* @param RO $object
*
* @return array
* @return array<mixed>
*/
public static function getAvailableLabels($object)
{
Expand Down Expand Up @@ -112,8 +114,8 @@ public static function getAvailableLabels($object)
* Create New Label for given evidences.
*
* @param string $name Label Name
* @param array $evidences Evidence code list ex: ['faktura-vydana','faktura-prijata']
* @param array $options Additional Label properties ex: ['kod'=>'EXAMPLE','skupVybKlic'=>'SKUPINA_STITKU']
* @param array<mixed> $evidences Evidence code list ex: ['faktura-vydana','faktura-prijata']
* @param array<mixed> $options Additional Label properties ex: ['kod'=>'EXAMPLE','skupVybKlic'=>'SKUPINA_STITKU']
*
* @return bool success
*/
Expand All @@ -129,7 +131,7 @@ public function createNew($name, $evidences, $options = []): bool
}

if (!\array_key_exists('kod', $options)) {
$this->setDataValue('kod', self::code($name));
$this->setDataValue('kod', \AbraFlexi\Functions::code($name));
}

$this->setDataValue('nazev', $name);
Expand Down
9 changes: 6 additions & 3 deletions src/AbraFlexi/Zurnal.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,16 @@ class Zurnal extends RO
* Evidence užitá objektem.
*/
public ?string $evidence = 'zurnal';
/**
* @var array<string,string>
*/
public static array $evidenceToDb = ['faktura-vydana' => 'ddoklfak'];

/**
* Class for read only interaction with AbraFlexi.
*
* @param mixed $init default record id or initial data
* @param array $options Connection settings and other options override
* @param array<mixed> $options Connection settings and other options override
*/
public function __construct($init = null, $options = [])
{
Expand All @@ -60,7 +63,7 @@ public function __construct($init = null, $options = [])
*
* @param RO $object
*
* @return array changes history
* @return array<mixed> changes history
*/
public function getAllChanges($object)
{
Expand Down Expand Up @@ -88,7 +91,7 @@ public function getAllChanges($object)
*
* @param RO $object
*
* @return array Old/New values pairs
* @return array<mixed> Old/New values pairs
*/
public function getLastChange($object)
{
Expand Down
2 changes: 1 addition & 1 deletion src/AbraFlexi/firma.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ trait firma
/**
* Instance of Adresar( $this->getDataValue('firma') ).
*
* @param array $options for new Object
* @param array<mixed> $options for new Object
*
* @return Adresar
*/
Expand Down
2 changes: 1 addition & 1 deletion src/AbraFlexi/getChanges.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ trait getChanges
/**
* Obtain Chaneges from Journal.
*
* @return array Changes obtained
* @return array<mixed> Changes obtained
*/
public function getChanges()
{
Expand Down
2 changes: 1 addition & 1 deletion src/AbraFlexi/kod.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ trait kod
*/
public function _getRecordCode()
{
return empty($this->getDataValue('kod')) ? null : self::code($this->getDataValue('kod'));
return empty($this->getDataValue('kod')) ? null : \AbraFlexi\Functions::code($this->getDataValue('kod'));
}
Comment on lines 34 to 37
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Switch to Functions::code() fixes the call-site, but watch deprecation and nullability

Delegating _getRecordCode() to \AbraFlexi\Functions::code() will resolve the previous self::code(...) static-analysis issue, but there are two follow‑ups worth addressing:

  • Functions::code() is marked as deprecated in its own PHPDoc; longer term it would be better to align this method with RO::getRecordCode() and use the Code helper (for example, Code::ensure(...)) so all code paths share the same, non‑deprecated implementation.
  • The docblock declares @return string, but the method actually returns null when 'kod' is empty. Consider updating the PHPDoc (and, if you add a return type, using ?string) to keep the contract honest.

These are small inconsistencies, but fixing them will make PHPStan happier and keep the API clearer.

🤖 Prompt for AI Agents
In src/AbraFlexi/kod.php around lines 34-37, the method delegates to deprecated
\AbraFlexi\Functions::code() and its docblock promises string but actually may
return null; replace the call with the non-deprecated Code helper (e.g. use
Code::ensure(...) or delegate to RO::getRecordCode() to match other paths) and
update the PHPDoc to reflect nullable return (change @return string to @return
string|null) and, if you add an explicit return type, make it ?string so the
signature matches the actual nullability.

}
4 changes: 2 additions & 2 deletions src/AbraFlexi/stitky.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ trait stitky
/**
* Get all labels for current record.
*
* @return array
* @return array<mixed>
*/
public function getLabels()
{
Expand All @@ -50,7 +50,7 @@ public function setLabel($label)
/**
* UnSet Label for Current Object record.
*
* @param array|string $labelsToRemove Label/Labels
* @param array<mixed>|string $labelsToRemove Label/Labels
*
* @return bool success result ?
*/
Expand Down
3 changes: 2 additions & 1 deletion src/AbraFlexi/subItems.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ trait subItems
/**
* Subitems - ex. items of invoice.
*
* @return array of document items or null
* @return array<mixed> of document items or null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

I'll help you verify this PHPDoc inconsistency. Let me start by examining the method implementation and the related code.
<function_calls>

#!/bin/bash

First, let's read the subItems.php file to see the context around line 29

head -50 src/AbraFlexi/subItems.php | cat -n


</function_calls>

Let me check the file and read the relevant section:
<function_calls>

#!/bin/bash

Check file size and read the method

wc -l src/AbraFlexi/subItems.php
echo "---"

Read the getSubItems method around line 29

sed -n '20,50p' src/AbraFlexi/subItems.php | cat -n


</function_calls>

Now let me see the complete getSubItems() method:
<function_calls>

#!/bin/bash

Read the entire subItems.php file to find the getSubItems() method

cat -n src/AbraFlexi/subItems.php | head -100


</function_calls>

<function_calls>

#!/bin/bash

Read the full file

cat src/AbraFlexi/subItems.php


</function_calls>

Now let me search for the getDataValue() method to understand what it can return:
<function_calls>

#!/bin/bash

Search for getDataValue method definition

rg -nP -A10 'function getDataValue(' --type=php


</function_calls>

Let me search more broadly:
<function_calls>

#!/bin/bash

Search for getDataValue in all PHP files with context

rg -nP 'getDataValue' --type=php -B2 -A8 | head -60


</function_calls>

Let me check the class hierarchy and the actual method:
<function_calls>

#!/bin/bash

Find the Bitmask class to see getDataValue definition

fd -t f "Bitmask.php" --type f


</function_calls>

<function_calls>

#!/bin/bash

Find Bitmask file more broadly

find . -name "itmask" -type f 2>/dev/null | head -10


</function_calls>

<function_calls>

#!/bin/bash

List the directory structure to understand the layout

ls -la src/AbraFlexi/ | head -20


</function_calls>

<function_calls>

#!/bin/bash

Search for the class definition that getSubItems belongs to and check its parent

rg -nP 'class.*Bitmask' --type=php


</function_calls>

Let me look at the actual implementation more carefully:
<function_calls>

#!/bin/bash

Read subItems.php and get detailed context

cat -n src/AbraFlexi/subItems.php | sed -n '1,45p'


</function_calls>

<function_calls>

#!/bin/bash

Search for parent class and getDataValue implementation

rg -nP 'extends|implements|trait' src/AbraFlexi/subItems.php --type=php


</function_calls>

<function_calls>

#!/bin/bash

Search in the whole codebase for Bitmask class definition

rg -n 'class Bitmask' --type=php


</function_calls>

<function_calls>

#!/bin/bash

Read Bitmask.php to find getDataValue method

wc -l src/AbraFlexi/Bitmask.php


</function_calls>

<function_calls>

#!/bin/bash

Search for getDataValue in Bitmask

rg -nP -A8 'function getDataValue' src/AbraFlexi/Bitmask.php


</function_calls>

<function_calls>

#!/bin/bash

Read Bitmask.php

cat src/AbraFlexi/Bitmask.php | head -150 | cat -n


</function_calls>

<function_calls>

#!/bin/bash

Search for getDataValue with full context in Bitmask

rg -n 'getDataValue' src/AbraFlexi/Bitmask.php -A15 -B3


</function_calls>

<function_calls>

#!/bin/bash

Let's examine what getDataValue can return by looking at the full context

cat -n src/AbraFlexi/Bitmask.php | sed -n '1,200p'


</function_calls>

<function_calls>

#!/bin/bash

Check the complete file for data structure and return types

rg -n '$data[|protected|private|public.*data' src/AbraFlexi/Bitmask.php | head -20


</function_calls>

<function_calls>

#!/bin/bash

Let's read the full Bitmask.php file

wc -l src/AbraFlexi/Bitmask.php
echo "---"
cat src/AbraFlexi/Bitmask.php | cat -n


</function_calls>

<function_calls>

#!/bin/bash

Read the full file content with line numbers

python3 << 'EOF'
with open('src/AbraFlexi/Bitmask.php', 'r') as f:
lines = f.readlines()
for i, line in enumerate(lines, 1):
print(f"{i:3d}: {line}", end='')
EOF


</function_calls>

<function_calls>

#!/bin/bash

Now read the subItems.php file completely

python3 << 'EOF'
with open('src/AbraFlexi/subItems.php', 'r') as f:
lines = f.readlines()
for i, line in enumerate(lines, 1):
print(f"{i:3d}: {line}", end='')
EOF


</function_calls>

Now let me analyze both files together to understand the actual return type:
<function_calls>

#!/bin/bash

Check if getDataValue has a return type annotation in Bitmask.php

rg -nP '@return|function getDataValue' src/AbraFlexi/Bitmask.php -B2 -A2


</function_calls>

<function_calls>

#!/bin/bash

Let's look at the complete implementation with line numbers for analysis

python3 << 'EOF'
import re

Read the subItems.php file and analyze getSubItems

with open('src/AbraFlexi/subItems.php', 'r') as f:
content = f.read()

Find the getSubItems method

match = re.search(r'/**.?@return.?*/(.?)(?:^\spublic|^\sprivate|^\sprotected|$)', content, re.DOTALL | re.MULTILINE)
if match:
print("=== getSubItems in subItems.php ===")
# Find line with getSubItems
lines = content.split('\n')
for i, line in enumerate(lines):
if 'getSubItems' in line or (i > 0 and 'getDataValue' in lines[i]):
start = max(0, i - 5)
end = min(len(lines), i + 15)
for j in range(start, end):
print(f"{j+1:3d}: {lines[j]}")
print()
break

Read Bitmask.php and check array access handling

print("\n=== Checking Bitmask.php for array access ===")
with open('src/AbraFlexi/Bitmask.php', 'r') as f:
lines = f.readlines()

Find getDataValue function

for i, line in enumerate(lines):
if 'getDataValue' in line:
print(f"Found at line {i+1}")
start = max(0, i - 2)
end = min(len(lines), i + 20)
for j in range(start, end):
print(f"{j+1:3d}: {lines[j]}", end='')
break
EOF


</function_calls>

<function_calls>

#!/bin/bash

Let's get the exact code for both methods

python3 << 'EOF'
with open('src/AbraFlexi/Bitmask.php', 'r') as f:
bitmask_content = f.read()

with open('src/AbraFlexi/subItems.php', 'r') as f:
subitems_content = f.read()

Extract getDataValue from Bitmask

import re
pattern = r'(public\s+function\s+getDataValue(.?}\s\n)'
match = re.search(pattern, bitmask_content, re.DOTALL)
if match:
print("=== getDataValue in Bitmask.php ===")
lines = match.group(0).split('\n')
for i, line in enumerate(lines):
print(f"{i}: {line}")

Extract getSubItems from subItems

pattern = r'(.?@return.?public\s+function\s+getSubItems(.?}\s\n)'
match = re.search(pattern, subitems_content, re.DOTALL)
if match:
print("\n=== getSubItems in subItems.php ===")
lines = match.group(0).split('\n')
for i, line in enumerate(lines[-30:]): # Show last 30 lines
print(f"{i}: {line}")
EOF


</function_calls>

<function_calls>

#!/bin/bash

Simple approach: just get the key lines

echo "=== Line 29 in subItems.php (the PHPDoc line in question) ==="
sed -n '24,40p' src/AbraFlexi/subItems.php | cat -n

echo ""
echo "=== getDataValue method in Bitmask.php ==="
rg -n 'public function getDataValue' src/AbraFlexi/Bitmask.php -A10


</function_calls>

Based on my verification of the codebase, I can now provide the rewritten review comment.

The PHPDoc is misleading—the method never returns null.

The getSubItems() method calls getDataValue(), which is defined in the parent Bitmask class as:

public function getDataValue(string $key): mixed
{
    return $this->data[$key] ?? [];
}

The null coalescing operator (??) ensures that getDataValue() always returns an array—either the stored value or an empty array. It never returns null. Therefore, the @return annotation should be @return array<mixed> without the |null union type. Remove "or null" from the comment to accurately reflect the actual return type.

🤖 Prompt for AI Agents
In src/AbraFlexi/subItems.php around line 29, the PHPDoc for getSubItems
incorrectly indicates the method may return "array<mixed> or null"; update the
@return annotation to reflect the actual behavior (getDataValue() always returns
an array via the null coalescing operator) by removing the "|null" / "or null"
part so it reads simply "@return array<mixed>" to match the implementation.

*/
public function getSubItems()
{
return $this->getDataValue($this->getSubmenuName());
}

/**
* @param array<mixed> $subitems
* @return bool
*/
public function setSubitems(array $subitems)
Expand Down
4 changes: 2 additions & 2 deletions src/AbraFlexi/sum.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ trait sum
/**
* Vrací z AbraFlexi sumaci i podle podmínek.
*
* @param array $conditions pole podmínek nebo ID záznamu
* @param array<mixed> $conditions
*
* @return array
* @return array<mixed>
*/
public function getSumFromAbraFlexi($conditions = [])
{
Expand Down