refactor: fix all 105 PHPStan 2 strict type findings across core and modules
Resolve all non-false-positive PHPStan 2 findings, reducing the baseline from 486 to 382 entries (only unused-public false positives remain). Categories fixed: - Remove 39 redundant type checks (is_string, is_array, is_object, method_exists) - Remove 12 no-op array_values() on already-sequential lists - Simplify 13 null-coalesce on guaranteed offsets - Remove 8 always-true instanceof checks - Replace 12 redundant test assertions (assertTrue(true) → addToAssertionCount) - Simplify 6 unnecessary nullsafe operators (?-> → ->) - Fix 6 always-true !== '' comparisons - Fix remaining: unset.offset, return.unusedType, staticMethod narrowing 53 files changed across core/, modules/, pages/, and tests/. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -141,9 +141,7 @@ class BcODataGateway
|
||||
. '&$count=true'
|
||||
. '&$orderby=' . rawurlencode($sortField . ' ' . $sortDir)
|
||||
. $select;
|
||||
if ($clauses !== []) {
|
||||
$url .= '&$filter=' . rawurlencode(implode(' and ', $clauses));
|
||||
}
|
||||
$url .= '&$filter=' . rawurlencode(implode(' and ', $clauses));
|
||||
|
||||
try {
|
||||
$response = $this->request('GET', $url);
|
||||
@@ -469,9 +467,6 @@ class BcODataGateway
|
||||
$rows = $this->extractODataValues($response);
|
||||
$mapped = [];
|
||||
foreach ($rows as $row) {
|
||||
if (!is_array($row)) {
|
||||
continue;
|
||||
}
|
||||
$ticketNo = trim((string) ($row['No'] ?? ''));
|
||||
if ($ticketNo === '') {
|
||||
continue;
|
||||
@@ -1271,9 +1266,6 @@ class BcODataGateway
|
||||
{
|
||||
$uniqueRows = [];
|
||||
foreach ($rows as $row) {
|
||||
if (!is_array($row)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$no = trim((string) ($row['No'] ?? ''));
|
||||
$rowKey = $no !== '' ? $no : md5((string) json_encode($row));
|
||||
|
||||
@@ -645,7 +645,7 @@ class DebitorDetailService
|
||||
|
||||
$billToNo = trim((string) ($contract['Bill_to_Cust_No'] ?? ''));
|
||||
$sellToNo = trim((string) ($contract['Sell_to_Cust_No'] ?? ''));
|
||||
if ($customerNo !== '' && $billToNo !== $customerNo && $sellToNo !== $customerNo) {
|
||||
if ($billToNo !== $customerNo && $sellToNo !== $customerNo) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1178,7 +1178,7 @@ class DebitorDetailService
|
||||
$days = isset($matches[1]) && $matches[1] !== '' ? (int) $matches[1] : 0;
|
||||
$hours = isset($matches[2]) && $matches[2] !== '' ? (int) $matches[2] : 0;
|
||||
$minutes = isset($matches[3]) && $matches[3] !== '' ? (int) $matches[3] : 0;
|
||||
$secondsFloat = isset($matches[4]) && $matches[4] !== '' ? (float) $matches[4] : 0.0;
|
||||
$secondsFloat = isset($matches[4]) ? (float) $matches[4] : 0.0;
|
||||
$seconds = (int) floor($secondsFloat);
|
||||
|
||||
return ($days * 86400) + ($hours * 3600) + ($minutes * 60) + $seconds;
|
||||
|
||||
@@ -332,7 +332,7 @@ final class RiskRadarService
|
||||
$days = isset($m[1]) && $m[1] !== '' ? (int) $m[1] : 0;
|
||||
$hours = isset($m[2]) && $m[2] !== '' ? (int) $m[2] : 0;
|
||||
$minutes = isset($m[3]) && $m[3] !== '' ? (int) $m[3] : 0;
|
||||
$seconds = isset($m[4]) && $m[4] !== '' ? (int) floor((float) $m[4]) : 0;
|
||||
$seconds = isset($m[4]) ? (int) floor((float) $m[4]) : 0;
|
||||
|
||||
return ($days * 86400) + ($hours * 3600) + ($minutes * 60) + $seconds;
|
||||
}
|
||||
@@ -355,7 +355,7 @@ final class RiskRadarService
|
||||
private static function resolveActivityTimestamp(array $ticket): ?int
|
||||
{
|
||||
$lastActivity = trim((string) ($ticket['Last_Activity_Date'] ?? ''));
|
||||
if ($lastActivity !== '' && !str_starts_with($lastActivity, '0001-01-01')) {
|
||||
if (!str_starts_with($lastActivity, '0001-01-01')) {
|
||||
$ts = strtotime($lastActivity);
|
||||
if (is_int($ts)) {
|
||||
return $ts;
|
||||
|
||||
@@ -244,7 +244,7 @@ class SystemRecommendationEngine
|
||||
return [
|
||||
'recommendations' => array_slice($deduped, 0, $maxItems),
|
||||
'meta' => [
|
||||
'applied_rules' => array_values(array_keys($appliedRulesMap)),
|
||||
'applied_rules' => array_keys($appliedRulesMap),
|
||||
'max_items' => $maxItems,
|
||||
'escalation_data_available' => $escalationAvailable,
|
||||
],
|
||||
@@ -379,9 +379,6 @@ class SystemRecommendationEngine
|
||||
$openTickets = [];
|
||||
|
||||
foreach ($tickets as $ticket) {
|
||||
if (!is_array($ticket)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$state = trim((string) ($ticket['Ticket_State'] ?? ''));
|
||||
if (in_array($state, self::CLOSED_TICKET_STATES, true)) {
|
||||
|
||||
@@ -193,9 +193,6 @@ class TicketCommunicationService
|
||||
// Collect support user name → ticket code mappings
|
||||
$supportUserNamesByTicket = [];
|
||||
foreach ($tickets as $ticket) {
|
||||
if (!is_array($ticket)) {
|
||||
continue;
|
||||
}
|
||||
$no = trim((string) ($ticket['No'] ?? ''));
|
||||
$name = trim((string) ($ticket['Support_User_Name'] ?? ''));
|
||||
if ($no !== '' && $name !== '') {
|
||||
@@ -784,7 +781,7 @@ class TicketCommunicationService
|
||||
}
|
||||
|
||||
if (preg_match('/^(\d{2}:\d{2})(:\d{2})?/', $time, $m) === 1) {
|
||||
return isset($m[2]) && $m[2] !== '' ? ($m[1] . $m[2]) : ($m[1] . ':00');
|
||||
return isset($m[2]) ? ($m[1] . $m[2]) : ($m[1] . ':00');
|
||||
}
|
||||
|
||||
return $time;
|
||||
@@ -902,9 +899,6 @@ class TicketCommunicationService
|
||||
|
||||
$nameMap = [];
|
||||
foreach ($contacts as $contact) {
|
||||
if (!is_array($contact)) {
|
||||
continue;
|
||||
}
|
||||
$contactNo = strtoupper(trim((string) ($contact['No'] ?? '')));
|
||||
$contactName = trim((string) ($contact['Name'] ?? ''));
|
||||
if ($contactNo === '' || $contactName === '') {
|
||||
@@ -1075,7 +1069,7 @@ class TicketCommunicationService
|
||||
}
|
||||
}
|
||||
|
||||
return $trimmed !== '' ? $trimmed : '';
|
||||
return $trimmed;
|
||||
}
|
||||
|
||||
private function normalizeActorRole(string $createdByType, string $actor): string
|
||||
|
||||
Reference in New Issue
Block a user