Conversation
…ature-a-few-fixes
There was a problem hiding this comment.
Pull request overview
This PR updates the package to target Laravel 13 / newer PHP, and hardens DTO/response parsing and test utilities to better handle variable JSON shapes and async DocuWare processing.
Changes:
- Bump framework/tooling support (Laravel 13, PHP matrix, PHPUnit/Pest/PHPStan) and update CI workflows accordingly.
- Introduce safer JSON-to-Collection mapping via
Support\JsonArrays, and apply it across multiple response mappers/DTOs. - Improve test stability by polling for document processing completion instead of using a fixed sleep.
Reviewed changes
Copilot reviewed 43 out of 43 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/TestCase.php | Removes custom test setup hooks and unused imports. |
| tests/Pest.php | Reworks test helpers to reuse a single connector and polls for doc processing completion. |
| src/Support/ParseValue.php | Adds stronger type expectations and guards when parsing DocuWare field values/tables. |
| src/Support/JsonArrays.php | Adds helper to normalize “array-of-records” JSON payloads safely. |
| src/Support/Auth.php | Adds type-safety around cached cookies and cookie array handling. |
| src/Responses/Workflow/GetDocumentWorkflowHistoryResponse.php | Uses JsonArrays to safely map instance history arrays. |
| src/Responses/General/UserManagement/GetUsers/GetUsersResponse.php | Uses JsonArrays and tightens return type to Collection<int, User>. |
| src/Responses/General/UserManagement/GetModifyRoles/GetRolesResponse.php | Uses JsonArrays and tightens return type to Collection<int, Role>. |
| src/Responses/General/UserManagement/GetModifyGroups/GetGroupsResponse.php | Uses JsonArrays and tightens return type to Collection<int, Group>. |
| src/Responses/General/Organization/GetOrganizationResponse.php | Uses JsonArrays and tightens return type to Collection<int, Organization>. |
| src/Responses/General/Organization/GetAllFileCabinetsAndDocumentTraysResponse.php | Uses JsonArrays and tightens return type to Collection<int, FileCabinet>. |
| src/Responses/FileCabinets/Dialogs/GetAllDialogsResponse.php | Uses JsonArrays and tightens return type to Collection<int, Dialog>. |
| src/Responses/Fields/GetFieldsResponse.php | Uses JsonArrays and tightens return type to Collection<int, Field>. |
| src/Responses/Documents/UpdateIndexValues/UpdateIndexValuesResponse.php | Uses JsonArrays before mapping field values. |
| src/Facades/DocuWare.php | Improves PHPDoc generics/array shape annotations for facade methods. |
| src/DTO/SuggestionField.php | Adds array-shape PHPDoc to constructors/factories. |
| src/DTO/General/Organization/Organization.php | Adds array-shape PHPDoc to constructors/factories. |
| src/DTO/Documents/TrashDocumentPaginator.php | Adds stronger input validation when mapping headers/rows and improves PHPDoc typing. |
| src/DTO/Documents/TableRow.php | Normalizes field arrays before converting to DocumentField objects. |
| src/DTO/Documents/DocumentPaginator.php | Normalizes Items input to ensure it is a list of arrays before mapping to DTOs. |
| src/DTO/Documents/DocumentIndex/PrepareDTO.php | Adds richer generic PHPDoc for index collections and output shapes. |
| src/DTO/Documents/DocumentIndex/IndexTextDTO.php | Adds explicit return shape for values(). |
| src/DTO/Documents/DocumentIndex/IndexTableDTO.php | Adds typing/guards for row conversion from arrays/collections. |
| src/DTO/Documents/DocumentIndex/IndexNumericDTO.php | Adds explicit return shape for values(). |
| src/DTO/Documents/DocumentIndex/IndexMemoDTO.php | Adds explicit return shape for values(). |
| src/DTO/Documents/DocumentIndex/IndexKeywordDTO.php | Adds explicit return shape for values(). |
| src/DTO/Documents/DocumentIndex/IndexDecimalDTO.php | Adds explicit return shape for values(). |
| src/DTO/Documents/DocumentIndex/IndexDateTimeDTO.php | Tightens typing on fallback constructor and adds return shape for values(). |
| src/DTO/Documents/DocumentIndex/IndexDateDTO.php | Tightens typing on fallback constructor and adds return shape for values(). |
| src/DTO/Documents/DocumentField.php | Adds PHPDoc for accepted value union type. |
| src/DTO/Documents/Document.php | Normalizes nested array fields/sections/suggestions before mapping and tightens extension extraction. |
| src/DTO/Authentication/OAuth/IdentityServiceConfiguration.php | Ensures list-like string arrays are normalized via stringList(). |
| src/DocuWareSearchRequestBuilder.php | Tightens typing and modifies filter handling (dates, in-filters). |
| src/Connectors/DocuWareConnector.php | Centralizes token-response validation and improves token cache TTL calculation. |
| phpunit.xml.dist | Updates PHPUnit schema reference. |
| phpstan.neon.dist | Raises PHPStan level from 5 to 6. |
| composer.json | Updates required Laravel/PHP/tooling versions and scripts. |
| .github/workflows/run-tests.yml | Updates test matrix and actions versions; adjusts coverage config and setup steps. |
| .github/workflows/phpstan.yml | Updates CI PHP version used for PHPStan job. |
| .github/workflows/fix-php-code-style-issues.yml | Switches to installing deps + running Pint directly. |
| .github/workflows/dependabot-auto-merge.yml | Updates dependabot metadata action and sets Node 24 override env var. |
| .github/workflows/composer-audit.yml | Adds scheduled/on-change composer audit workflow. |
| .github/ISSUE_TEMPLATE/bug_report.yml | Updates default PHP/Laravel version placeholders. |
Comments suppressed due to low confidence (1)
src/DocuWareSearchRequestBuilder.php:274
array_searchcan return0when the operator is found at the first index, which makes this condition falsey and prevents the intended override behavior (leading to duplicate operators and potentialInvalidDateFiltersCount). Use a strict comparison (!== false) when checking the result ofarray_search.
if (isset($this->usedDateOperators[$name])) {
if ($operatorFilterIndex = array_search($operator, $this->usedDateOperators[$name])) {
unset($this->filters[$name][$operatorFilterIndex]);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 'Date', 'DateTime' => self::date($item), | ||
| 'Keywords' => Arr::join($item['Keyword'], ', '), | ||
| 'Table' => self::table($item), | ||
| 'Date', 'DateTime' => self::date(is_string($item) ? $item : ''), |
There was a problem hiding this comment.
In the Date/DateTime branch, falling back to an empty string when $item is not a string will cause Carbon::createFromTimestampMs('') to resolve to epoch (or potentially throw), which is likely incorrect. Consider returning $default when the item isn’t a string (or validating the /Date(...) format) instead of parsing ''.
| protected static function listOfFieldArraysFromData(array $data, string $key): array | ||
| { | ||
| $raw = Arr::get($data, $key); | ||
| if (! is_array($raw)) { | ||
| return []; | ||
| } |
There was a problem hiding this comment.
listOfFieldArraysFromData() duplicates the new Support\JsonArrays::listOfRecords() logic introduced elsewhere in this PR. To reduce duplication and keep array-sanitization consistent across DTOs, consider reusing JsonArrays::listOfRecords(Arr::get($data, $key)) here instead of maintaining a separate implementation.
| public function filterDate(string $name, string $operator, ?Carbon $date): self | ||
| { | ||
| if ($date === null) { | ||
| throw new \InvalidArgumentException('A date is required for date filters.'); |
There was a problem hiding this comment.
filterDate accepts ?Carbon $date but now throws when $date is null. This is inconsistent with the signature and can surprise callers. Either change the parameter type to Carbon $date (non-null) or keep it nullable and treat null as a no-op/ignored filter.
| throw new \InvalidArgumentException('A date is required for date filters.'); | |
| return $this; |
No description provided.