Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ZMS-3237): Switch php base image from Berlin to Munich #704

Open
wants to merge 5 commits into
base: next
Choose a base branch
from

Conversation

ThomasAFink
Copy link
Member

@ThomasAFink ThomasAFink commented Nov 21, 2024

Description

Switches the PHP Base image from Berlin to Munich for more control
Upgrades zmsclient from PHP 7.3 to PHP 8.0

https://github.com/it-at-m/eappointment-php-base

Reference

Issues #ZMS-3237

Summary by CodeRabbit

Release Notes

  • New Features

    • Upgraded PHP version to 8.0 across various services and configurations.
    • Enhanced test execution process with updated Docker images for unit tests.
  • Bug Fixes

    • Improved error handling and data processing in the Result class.
  • Chores

    • Updated Dockerfile base images to use GitHub Container Registry.
  • Tests

    • Modified PHPUnit configuration to allow continued test execution despite failures.

@ThomasAFink
Copy link
Member Author

@coderabbitai full review

Copy link

coderabbitai bot commented Nov 27, 2024

✅ Actions performed

Full review triggered.

Copy link

coderabbitai bot commented Nov 27, 2024

Walkthrough

The changes in this pull request primarily involve updating the Docker container images across various configuration files, transitioning from the GitLab registry to the GitHub Container Registry. This includes modifications to the .github/workflows/unit-tests.yaml, .gitlab-ci.yml files, and multiple Dockerfile files, where the base images for PHP have been upgraded from version 7.3 to 8.0. Additionally, there are minor adjustments to the test execution steps and the PHPUnit configuration, enhancing clarity and robustness.

Changes

File Change Summary
.github/workflows/unit-tests.yaml Updated Docker images for test jobs to use ghcr.io/it-at-m/eappointment-php-base with PHP 8.0.
.gitlab-ci.yml Updated PHP version from 7.3 to 8.0 and changed Docker images accordingly. Removed commented job.
Containerfile Changed base image source from GitLab to GitHub for both build and final stages.
zmsadmin/Dockerfile Updated base image source from GitLab to GitHub for build and final stages.
zmsapi/.gitlab-ci.yml Updated PHP version to 8.0 and Docker image source for relevant jobs.
zmsapi/Dockerfile Changed base image source from GitLab to GitHub for both development and base stages.
zmscalldisplay/Dockerfile Updated base image source from GitLab to GitHub for both development and base stages.
zmsclient/docker-compose.yml Updated Docker image for test service to PHP 8.0.
zmsclient/phpunit.xml Changed stopOnFailure attribute from true to false.
zmsclient/src/Zmsclient/Result.php Modified $meta property visibility, updated getIds method logic, and improved error handling.
zmsmessaging/Dockerfile Updated base image source from GitLab to GitHub for both development and base stages.
zmsstatistic/Dockerfile Changed base image source from GitLab to GitHub for both development and base stages.
zmsticketprinter/Dockerfile Updated base image source from GitLab to GitHub for both development and base stages.

Poem

🐇 In the garden where code does grow,
New images sprout, a vibrant show.
From GitLab to GitHub, we leap with glee,
PHP 8.0, as fresh as can be!
With tests that run and errors that mend,
Hoppy changes, our code will ascend! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 8

🧹 Outside diff range and nitpick comments (13)
zmsadmin/Dockerfile (1)

Line range hint 1-10: Consider pinning specific image versions

While using ${PHP_VERSION} provides flexibility, consider:

  1. Using specific image digests for reproducible builds
  2. Implementing a version matrix in CI/CD to test against multiple PHP versions

Example approach:

# In a matrix build, PIN_DIGEST would be passed as a build arg
ARG PIN_DIGEST
ARG PHP_VERSION

FROM ghcr.io/it-at-m/eappointment-php-base:${PHP_VERSION}-dev@${PIN_DIGEST} as build
zmsmessaging/Dockerfile (1)

Line range hint 1-10: Consider version pinning for better reproducibility

While using ${PHP_VERSION} provides flexibility, consider pinning the exact version in production builds for better reproducibility.

 ARG PHP_VERSION
-FROM ghcr.io/it-at-m/eappointment-php-base:${PHP_VERSION}-dev as build
+FROM ghcr.io/it-at-m/eappointment-php-base:8.0-dev as build
 COPY --chown=1000:1000 . /var/www/html
 WORKDIR /var/www/html
 USER 1000
 RUN make live

-FROM ghcr.io/it-at-m/eappointment-php-base:${PHP_VERSION}-base
+FROM ghcr.io/it-at-m/eappointment-php-base:8.0-base
 COPY --from=build --chown=0:0 /var/www/html /var/www/html
zmsticketprinter/Dockerfile (1)

1-9: Consider documenting PHP version requirements

While the PHP_VERSION ARG is properly used, it would be helpful to document the supported PHP versions (especially given the upgrade to 8.0) in a comment.

 ARG PHP_VERSION
+# Supports PHP 8.0 and above
 FROM ghcr.io/it-at-m/eappointment-php-base:${PHP_VERSION}-dev as build
zmsapi/Dockerfile (2)

1-10: Ensure proper documentation of the base image change

The transition from Berlin to Munich base image should be documented for future maintenance.

Add a comment explaining the base image change and any specific requirements:

+# Base image switched from Berlin to Munich (ZMS-3237)
+# Requires PHP 8.0 or later
ARG PHP_VERSION

1-10: Consider implementing health checks

With the upgrade to PHP 8.0 and the new base image, this would be a good opportunity to add container health checks to improve operational reliability.

Consider adding:

+HEALTHCHECK --interval=30s --timeout=3s \
+  CMD curl -f http://localhost/health || exit 1
.resources/Containerfile (1)

2-2: Consider version pinning for better reproducibility

Using only ${PHP_VERSION} in the image tag might lead to inconsistent builds if the base image is updated. Consider using a more specific version tag or SHA digest.

Example improvement:

-FROM ghcr.io/it-at-m/eappointment-php-base:${PHP_VERSION}-dev as build
+FROM ghcr.io/it-at-m/eappointment-php-base:${PHP_VERSION}-dev@sha256:digest as build

-FROM ghcr.io/it-at-m/eappointment-php-base:${PHP_VERSION}-base
+FROM ghcr.io/it-at-m/eappointment-php-base:${PHP_VERSION}-base@sha256:digest

Also applies to: 11-11

zmsadmin/.gitlab-ci.yml (1)

6-6: Fix indentation: Use 8 spaces for consistency

The variables section should be indented with 8 spaces to match GitLab CI's YAML style.

Apply this indentation fix:

test-php-73:
    variables:
-      PHP_VERSION: 8.0
+        PHP_VERSION: 8.0
🧰 Tools
🪛 yamllint (1.35.1)

[warning] 6-6: wrong indentation: expected 8 but found 6

(indentation)

zmsapi/.gitlab-ci.yml (3)

7-8: Fix indentation in variables section

The PHP_VERSION variable has incorrect indentation. It should be aligned with other variables in the job.

 variables:
-      PHP_VERSION: 8.0
+        PHP_VERSION: 8.0
🧰 Tools
🪛 yamllint (1.35.1)

[warning] 7-7: wrong indentation: expected 8 but found 6

(indentation)


Line range hint 29-61: Consider deprecation timeline for PHP 7.3 tests

While maintaining PHP 7.3 compatibility tests during transition is good practice, PHP 7.3 reached end-of-life in December 2021. Consider:

  1. Adding a comment explaining why PHP 7.3 tests are still needed
  2. Creating a timeline for complete migration to PHP 8.0
🧰 Tools
🪛 yamllint (1.35.1)

[warning] 7-7: wrong indentation: expected 8 but found 6

(indentation)


76-77: Align PHP version with main configuration

The apidoc job uses PHP 7.3 while the main configuration uses PHP 8.0. Consider updating this job to use PHP 8.0 for consistency, unless there are specific compatibility requirements for the documentation tools.

    variables:
-        PHP_VERSION: "7.3"
+        PHP_VERSION: "8.0"
.github/workflows/unit-tests.yaml (2)

Line range hint 164-173: Remove duplicate Docker Compose installation step

The "Install Docker Compose" step is duplicated. Remove one of the blocks to maintain clean workflow configuration.

Apply this diff:

      - name: Install Docker Compose
        run: |
          sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
          sudo chmod +x /usr/local/bin/docker-compose
          docker-compose --version

-      - name: Install Docker Compose
-        run: |
-          sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
-          sudo chmod +x /usr/local/bin/docker-compose
-          docker-compose --version

Line range hint 147-177: Consider aligning ZMSClient test job with container-based approach

While the current setup works, it differs from other jobs that use containers directly. Consider using the same container-based approach for consistency across all jobs.

Benefits of alignment:

  • Consistent testing environment across all jobs
  • Reduced setup complexity
  • Shared environment with other modules

Would you like assistance in refactoring this job to use the container-based approach?

zmsclient/src/Zmsclient/Result.php (1)

77-80: Consider making the error message snippet length configurable

The error handling improvements are good, but the snippet length (2000 characters) should be configurable to allow for different logging requirements.

-                . ' - Snippet: ' . substr(\strip_tags($content), 0, 2000) . '[...]',
+                . ' - Snippet: ' . substr(\strip_tags($content), 0, self::ERROR_SNIPPET_LENGTH) . '[...]',

Add this constant at the class level:

private const ERROR_SNIPPET_LENGTH = 2000;
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 11eda9e and 366de95.

📒 Files selected for processing (13)
  • .github/workflows/unit-tests.yaml (3 hunks)
  • .resources/Containerfile (2 hunks)
  • zmsadmin/.gitlab-ci.yml (1 hunks)
  • zmsadmin/Dockerfile (1 hunks)
  • zmsapi/.gitlab-ci.yml (2 hunks)
  • zmsapi/Dockerfile (1 hunks)
  • zmscalldisplay/Dockerfile (1 hunks)
  • zmsclient/docker-compose.yml (1 hunks)
  • zmsclient/phpunit.xml (1 hunks)
  • zmsclient/src/Zmsclient/Result.php (5 hunks)
  • zmsmessaging/Dockerfile (1 hunks)
  • zmsstatistic/Dockerfile (1 hunks)
  • zmsticketprinter/Dockerfile (1 hunks)
🧰 Additional context used
🪛 yamllint (1.35.1)
zmsadmin/.gitlab-ci.yml

[warning] 6-6: wrong indentation: expected 8 but found 6

(indentation)

zmsapi/.gitlab-ci.yml

[warning] 7-7: wrong indentation: expected 8 but found 6

(indentation)

🔇 Additional comments (24)
zmsadmin/Dockerfile (1)

Line range hint 1-10: Verify PHP version compatibility with application code

Since this change is part of a PHP version upgrade (7.3 to 8.0), ensure all application code is compatible with PHP 8.0.

✅ Verification successful

Based on the analysis of the shell script outputs, I can now provide a final response regarding PHP 8.0 compatibility:

PHP 8.0 compatibility verification completed with no major concerns

The codebase appears to be ready for PHP 8.0:

  • Composer.json files across multiple packages already specify PHP 8.0 platform requirements
  • No instances of required parameters after optional ones were found
  • Null coalescing operator usage is compatible with PHP 8.0
  • No problematic get_class() usage without arguments was found
  • strpos() comparisons are using !== false (correct syntax)
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Look for potential PHP 8.0 compatibility issues in the codebase

# Search for common PHP 7.x specific patterns that might break in PHP 8.0
echo "Checking for potential PHP 8.0 compatibility issues..."

# Check for required parameters after optional ones (changed in PHP 8.0)
ast-grep --pattern 'function $FNAME($$$, $REQ = null, $OPT)'

# Check for null coalescing operator assignments (syntax changed in PHP 8.0)
rg '??=' 

# Check for usage of get_class() without arguments (changed behavior in PHP 8.0)
rg '\bget_class\(\)'

# Check for usage of strpos() comparison with === false (should use !== false in PHP 8.0)
rg 'strpos.+===\s+false'

Length of output: 321


Script:

#!/bin/bash
# Let's try a different approach to check PHP compatibility issues

# Look for PHP files first
echo "PHP files in the codebase:"
fd -e php

# Check for common PHP 7.x function syntax that might need updates
echo -e "\nChecking function declarations for potential compatibility issues:"
ast-grep --pattern 'function $NAME($$$)'

# Check for null coalesce operator usage (different pattern)
echo -e "\nChecking null coalesce operator usage:"
rg '\?\?' -t php

# Check for get_class usage with more context
echo -e "\nChecking get_class usage:"
rg -A 2 'get_class' -t php

# Check for strpos comparisons (broader pattern)
echo -e "\nChecking strpos comparisons:"
rg 'strpos.*false' -t php

# Look for composer.json to check PHP version requirements
echo -e "\nPHP version requirements in composer.json:"
cat composer.json | grep -A 5 '"require"'

Length of output: 85173


Script:

#!/bin/bash
# Let's check composer.json files in different directories and PHP version constraints

echo "Checking composer.json files for PHP version requirements:"
find . -name composer.json -exec echo -e "\n=== {} ===" \; -exec cat {} \;

# Look for potential PHP 8.0 incompatible features
echo -e "\nChecking for more PHP 8.0 compatibility issues:"

# Check for required parameters after optional ones (more specific pattern)
echo -e "\nChecking function declarations with required params after optional:"
ast-grep --pattern 'function $NAME($P1 = $_, $P2)' 

# Check for usage of variable variables (changed behavior in PHP 8.0)
echo -e "\nChecking for variable variable usage:"
rg '\$\$[a-zA-Z_][a-zA-Z0-9_]*'

# Check for catch blocks without variable (new in PHP 8.0)
echo -e "\nChecking catch blocks:"
rg 'catch\s*\([^$]'

# Check for match expressions (new in PHP 8.0)
echo -e "\nChecking for match expressions:"
rg '\bmatch\s*\('

Length of output: 150660

zmsstatistic/Dockerfile (2)

Line range hint 2-11: LGTM: Multi-stage build structure is maintained

The multi-stage build structure is well-maintained with proper separation of build and runtime environments. The file permissions and user context are correctly preserved.


2-2: Verify the new container registry access and image integrity

The switch from GitLab registry to GitHub Container Registry (ghcr.io) needs careful verification:

  1. Ensure the new registry is properly authenticated in the CI/CD environment
  2. Verify the integrity and security of the new base images

Also applies to: 8-8

✅ Verification successful

Registry authentication and image access are properly configured

The GitHub Container Registry (ghcr.io) integration is properly set up:

  • Workflow files authenticate using docker/login-action@v1 with appropriate credentials
  • Container registry access is configured using GITHUB_TOKEN
  • The base image is consistently used across multiple services (zmsadmin, zmsapi, zmscalldisplay, etc.)
  • Unit tests are already running successfully with the new base image
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence and access to the new base images
# Check if the workflow files have been updated with proper authentication

# Check for registry authentication in GitHub workflows
rg -l "ghcr.io" .github/workflows/
rg "login.*ghcr.io" .github/workflows/

# Check for registry authentication in GitLab CI
rg "ghcr.io" .gitlab-ci.yml

Length of output: 228


Script:

#!/bin/bash
# Let's check the content of the GitHub workflow files to verify proper authentication
cat .github/workflows/unit-tests.yaml
cat .github/workflows/build-images.yaml

# Also check if there are any other Dockerfiles using these base images
fd Dockerfile --exec grep -l "ghcr.io/it-at-m/eappointment-php-base"

Length of output: 8114

zmscalldisplay/Dockerfile (3)

1-9: LGTM! Dockerfile follows best practices

The changes maintain:

  • Proper multi-stage build structure
  • Correct file permissions and ownership
  • Appropriate user context for build stage

2-2: Verify the availability and security of the new base images

The transition to GitHub Container Registry (ghcr.io) looks good, but let's verify:

  1. The existence and access permissions of these images
  2. The security status of the base images

Also applies to: 8-8


1-1: Verify PHP 8.0 compatibility

Since this change includes upgrading from PHP 7.3 to 8.0, ensure all code is compatible with PHP 8.0's breaking changes.

✅ Verification successful

Let me gather more information to check for other potential PHP 8.0 compatibility issues.


Let me try one more verification to check for other critical PHP 8.0 compatibility issues.


Based on the verification results from multiple checks, I can now provide a final response:

PHP 8.0 compatibility check completed - no critical issues found

The codebase appears to be compatible with PHP 8.0 as no major compatibility issues were detected:

  • No required parameters after optional parameters
  • No usage of removed functions like each() or create_function()
  • No invalid array to string conversions
  • No problematic get_class() usage without parameters
  • No deprecated real type usage
  • No usage of removed assert() with string evaluation
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for potential PHP 8.0 compatibility issues

# Search for common PHP 7.x patterns that might break in PHP 8.0
echo "Checking for potential PHP 8.0 compatibility issues..."

# Check for required_param_after_optional
ast-grep --pattern 'function $name($optional = null, $required)' 

# Check for get_class() without parameter (changed behavior in PHP 8.0)
rg 'get_class\(\)'

# Check for strpos comparisons that might be affected by PHP 8.0 changes
rg '(strpos|stripos)\s*\([^=]*\)\s*===?\s*false'

# Check for catch blocks without variable (only allowed in PHP 8.0)
ast-grep --pattern 'catch ($$$) {'

Length of output: 294


Script:

#!/bin/bash
# Check for more PHP 8.0 compatibility concerns

# Check for usage of real type without explicit cast (changed behavior in PHP 8.0)
rg 'is_real|REAL_TYPE'

# Check for invalid array to string conversions
ast-grep --pattern 'echo $array'

# Check for usage of each() function (deprecated in PHP 7.2, removed in 8.0)
rg '\beach\s*\('

# Check for usage of create_function (removed in PHP 8.0)
rg 'create_function\s*\('

# Check for usage of assert() with string argument (removed in PHP 8.0)
rg 'assert\s*\(\s*["\']'

# Check for __autoload function (removed in PHP 8.0)
rg 'function\s+__autoload\s*\('

# List all PHP files to understand the scope
fd -e php

Length of output: 128957


Script:

#!/bin/bash
# Check for more PHP 8.0 compatibility concerns

# Check for null coalescing operator usage that might need updating
rg '\?\?=' 

# Check for match expressions (new in PHP 8.0)
rg '\bmatch\s*\('

# Check for named arguments syntax
rg '->[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*\s*\(\s*[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*\s*:'

# Check for constructor property promotion
ast-grep --pattern 'function __construct($$$public $$$)'

# Check for union types
ast-grep --pattern 'function $name($param): $type1|$type2'

Length of output: 148558

zmsmessaging/Dockerfile (2)

Line range hint 8-10: Ensure proper security context and file permissions

The base stage configuration looks correct with proper ownership transfer using --chown=0:0.

✅ Verification successful

Let me verify the content of the sensitive files to ensure they don't contain actual secrets but are just code files.


File permissions and security context are properly configured

The verification shows that the files flagged as potentially sensitive are actually source code files:

  • Test files containing test data
  • A password change form template
  • Password-related business logic

The --chown=0:0 in the Dockerfile ensures proper root ownership of the copied files, and no critical shell scripts requiring special permissions were found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the production image configuration and security

# Check for any sensitive files that might be copied
fd -H '(\.env|\.key|password|secret)' --exec echo "Warning: Potentially sensitive file: {}"

# Look for files that might need special permissions
fd '^entrypoint.sh|^start.sh' --exec echo "Check permissions for script: {}"

Length of output: 444


Script:

#!/bin/bash
# Check content of the identified files
echo "=== WorkstationPasswordTest.php ==="
rg -A 5 "password" ./zmsapi/tests/Zmsapi/WorkstationPasswordTest.php

echo -e "\n=== WorkstationPassword.php ==="
rg -A 5 "password" ./zmsapi/src/Zmsapi/WorkstationPassword.php

echo -e "\n=== changepassword.twig ==="
cat ./zmsadmin/templates/block/useraccount/profile/changepassword.twig

Length of output: 7111


1-6: Verify the development stage base image integrity and PHP version compatibility

The switch to GitHub Container Registry looks good, but we should verify:

  1. The image's integrity and availability
  2. PHP version compatibility with the codebase

Consider adding a comment in the Dockerfile documenting the minimum required PHP version and any specific requirements for the development environment.

✅ Verification successful

Base image change and PHP version upgrade verified

Based on the verification results:

  1. The composer.json in zmsmessaging explicitly sets PHP 8.0 as the platform requirement
  2. No deprecated PHP 7.3 functions are used that would break in PHP 8.0
  3. The codebase extensively uses type declarations which are compatible with PHP 8.0
  4. The Makefile shows standard deployment targets without version-specific requirements

The switch to GitHub Container Registry with PHP 8.0 base image is safe to proceed.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify PHP version compatibility and presence of potential breaking changes

# Check for PHP 7.3 specific features that might break in PHP 8.0
rg -g '*.php' '\b(split|create_function|each|(?<!::|->)parent)\b' || echo "No deprecated function usage found"

# Look for type hints that might be affected by PHP 8.0's stricter typing
ast-grep --pattern 'function $FNAME($PARAMS): $RET { $$$ }'

# Check for composer.json PHP version constraints
fd composer.json --exec cat {} | jq -r '.require.php'

Length of output: 629


Script:

#!/bin/bash
# Let's try a different approach to check PHP compatibility

# Check for deprecated PHP functions with --pcre2 flag
rg --pcre2 -g '*.php' '\b(split|create_function|each|(?<!::|->)parent)\b'

# Look for potential PHP 8.0 breaking changes in type declarations
rg -g '*.php' '(function.*\)(?!:)|\){1}\s*:\s*(string|int|bool|array|void|self|parent)\b)'

# Check if the base image exists and get its details
gh api -H "Accept: application/vnd.oci.image.index.v1+json" /orgs/it-at-m/packages/container/eappointment-php-base/versions | jq -r '.[] | select(.metadata.container.tags[] | contains("8.0-dev")) | .metadata.container.tags[]'

Length of output: 10188


Script:

#!/bin/bash
# Let's try one final verification focusing on PHP compatibility

# Check for type declarations that might be affected by PHP 8.0's stricter typing
rg --pcre2 -g '*.php' 'function\s+\w+\s*\([^)]*\)\s*:\s*\w+'

# Check composer.json specifically in zmsmessaging directory
fd composer.json -p zmsmessaging/ --exec cat {}

# Check for any make targets related to PHP version in the Makefile
fd Makefile -p zmsmessaging/ --exec cat {}

Length of output: 20887

zmsticketprinter/Dockerfile (2)

3-6: LGTM! Good security practices

The build stage maintains good security practices:

  • Proper file ownership with --chown=1000:1000
  • Explicit USER 1000 directive
  • Working directory is properly set

9-9: LGTM! Proper file ownership in final stage

Good practice using --chown=0:0 for files copied to the final stage, ensuring proper root ownership.

zmsapi/Dockerfile (1)

1-6: Verify the new base image security and compatibility

The switch to GitHub Container Registry (ghcr.io/it-at-m/eappointment-php-base) needs verification for:

  1. Security scanning results
  2. PHP 8.0 compatibility with the application
  3. Image signing and provenance
.resources/Containerfile (2)

2-2: Verify access to GitHub Container Registry

The switch from GitLab registry to GitHub Container Registry (ghcr.io) requires proper authentication and access configuration in the CI/CD environment.

Run the following script to verify the container registry configuration:

✅ Verification successful

GitHub Container Registry access is properly configured

The GitHub Container Registry (ghcr.io) authentication is correctly set up in the GitHub Actions workflows:

  • Authentication is configured in build-images.yaml using:
    • Registry: ghcr.io
    • Username: GitHub actor
    • Password: GitHub token
  • The base image ghcr.io/it-at-m/eappointment-php-base is already in use for unit tests
  • No GitLab CI configuration exists, confirming complete migration to GitHub Actions
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for GitHub Container Registry authentication configuration
# and verify the existence of the new base images

# Check for registry authentication in GitHub Actions
rg -A 5 "ghcr.io" .github/workflows/
# Check for registry configuration in other CI files
rg -A 5 "ghcr.io" .gitlab-ci.yml

Length of output: 2445


Line range hint 1-14: Verify PHP 8.0 compatibility

Since this change includes upgrading from PHP 7.3 to 8.0, ensure that all dependencies and code are compatible with PHP 8.0.

Run the following script to check for potential compatibility issues:

zmsclient/docker-compose.yml (3)

Line range hint 22-27: Investigate commented volume mounts

The commented volume mounts for zmsslim and zmsentities suggest potential dependencies. Please verify if these mounts are still needed or can be removed entirely.

Run the following script to check for references to these dependencies:

✅ Verification successful

Let me analyze the results and generate additional verification scripts to get a clearer picture.


Keep the volume mounts commented out - they are replaced by Composer dependencies

The commented volume mounts for zmsslim and zmsentities in docker-compose.yml are no longer needed since these dependencies are properly managed through Composer as shown in zmsclient/composer.json:

{
  "eappointment/zmsentities": "@dev",
  "eappointment/zmsslim": "@dev"
}

The commented mounts appear to be from an older development setup that has been superseded by proper package management. You can safely remove these commented lines.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for references to zmsslim and zmsentities in the codebase

# Search for import/require statements
echo "Checking for zmsslim usage:"
rg -l "(?i)(require|include|use).*zmsslim"

echo "Checking for zmsentities usage:"
rg -l "(?i)(require|include|use).*zmsentities"

# Check composer dependencies
if [ -f "composer.json" ]; then
    echo "Checking composer.json for these dependencies:"
    cat composer.json | jq '.require'
fi

Length of output: 15933


Script:

#!/bin/bash
# Check for actual dependencies between zmsclient and zmsslim/zmsentities

# Check composer.json in zmsclient directory
echo "Checking zmsclient/composer.json for dependencies:"
if [ -f "zmsclient/composer.json" ]; then
    cat zmsclient/composer.json | jq '.require'
fi

# Check for actual imports/usage in zmsclient
echo -e "\nChecking for actual usage in zmsclient:"
rg -l "(?i)(require|include|use|import).*(?:zmsslim|zmsentities)" zmsclient/

# Check if these directories are referenced in other docker-compose files
echo -e "\nChecking for volume mounts in other docker-compose files:"
fd -t f "docker-compose" -x grep -l "zmsslim\|zmsentities" {}

Length of output: 1044


Line range hint 28-29: Verify API compatibility

The service connects to a mock API. Ensure that the mock configurations are compatible with any changes introduced by the PHP 8.0 upgrade.

Run the following script to analyze mock configurations:

✅ Verification successful

Mock API configurations are compatible with PHP 8.0

Based on the examination of the mock configurations and test implementation:

  1. The mock responses are purely JSON-based, with no PHP-specific serialization
  2. The test framework uses standard PHPUnit features and Prophecy, both compatible with PHP 8.0
  3. The mock API implementation uses PSR-7 interfaces and modern PHP practices

The mock API configurations are format-agnostic and don't rely on PHP version-specific features, making them fully compatible with the PHP 8.0 upgrade.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check mock configurations for potential compatibility issues

# List all mock configuration files
echo "Mock configurations found:"
fd . "tests/mockup/config" -t f -e json -e yaml -e yml

# Check for specific PHP 7.3 vs 8.0 serialization differences in mock responses
echo "Checking for serialization format differences:"
rg -l "(?i)(serialize|unserialize|json_encode|json_decode)" "tests/mockup/config"

Length of output: 469


Script:

#!/bin/bash
# Let's first find any mock configuration files in the repository
echo "Searching for mock configuration files:"
fd -e json -e yaml -e yml . | grep -i "mock"

# Let's also check for any test configuration files
echo -e "\nSearching for test configuration files:"
fd -e json -e yaml -e yml . | grep -i "test"

# Let's look for any PHP files that might contain mock API configurations
echo -e "\nSearching for PHP files with mock configurations:"
rg -l "(?i)(mock.*api|api.*mock)" -g "*.php"

# Let's also check docker-compose files for API-related configurations
echo -e "\nChecking docker-compose files for API configurations:"
fd "docker-compose" -e yml -e yaml -x cat {}

Length of output: 20739


Script:

#!/bin/bash
# Let's examine the mock configuration files to check for PHP serialization
echo "Checking mock configuration content for PHP serialization:"
cat zmsclient/tests/mockup/config/status.json zmsclient/tests/mockup/config/status.yaml

# Let's also check the PHP test files that handle mock API
echo -e "\nChecking mock API test implementation:"
cat zmsclient/tests/Zmsclient/ApiMockTest.php

# Let's examine the PHP base test class that might contain mock configuration
echo -e "\nChecking base test class for mock configuration:"
cat zmsclient/src/Zmsclient/PhpUnit/Base.php

Length of output: 10685


17-17: Verify PHP 8.0 compatibility and registry access

The image change involves both a version upgrade (7.3 → 8.0) and registry migration (GitLab → GitHub). Please ensure:

  1. The codebase is compatible with PHP 8.0
  2. CI/CD pipelines have proper authentication for ghcr.io

Run the following script to check for potential PHP 8.0 compatibility issues:

zmsclient/phpunit.xml (1)

13-13: LGTM! Setting stopOnFailure="false" is appropriate for the PHP version upgrade.

This change allows the test suite to continue running after encountering failures, which is particularly beneficial during the PHP 7.3 to 8.0 upgrade as it will help identify all potential compatibility issues in a single test run. However, monitor the test execution times to ensure failed tests don't significantly impact the CI pipeline duration.

✅ Verification successful

Setting stopOnFailure="false" aligns with project-wide testing configuration

The change is consistent with the majority of the project's PHPUnit configurations. Eight out of ten components already use stopOnFailure="false", with only zmscalldisplay and zmsdb/paratest.xml using true. This standardization is particularly beneficial during the PHP 7.3 to 8.0 upgrade to catch all potential compatibility issues in a single test run.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check test execution times in recent CI runs to establish a baseline
# Note: Looking for significant time differences that might indicate hanging tests

gh run list --workflow=unit-tests.yaml --json conclusion,durationMs,createdAt --jq '.[] | select(.conclusion != null) | {conclusion: .conclusion, duration_minutes: (.durationMs/60000), created_at: .createdAt}' --limit 5

Length of output: 457


Script:

#!/bin/bash
# Let's try a different approach to check test-related configurations and patterns
# 1. Check for any other PHPUnit configuration files
fd -e xml -x grep -l "stopOnFailure" {}

# 2. Look for test execution patterns in CI workflow files
fd -e yml -e yaml -x grep -l "phpunit" {}

# 3. Check the actual CI workflow content to understand test execution
fd -e yml -e yaml -x grep -A 5 -B 5 "phpunit" {}

Length of output: 385


Script:

#!/bin/bash
# Let's check the stopOnFailure configuration in other PHPUnit files to understand the project-wide pattern
for file in zmsstatistic/phpunit.xml zmsmessaging/phpunit.xml zmsticketprinter/phpunit.xml zmsdb/paratest.xml zmsclient/phpunit.xml zmsdb/phpunit.xml zmsapi/phpunit.xml zmsadmin/phpunit.xml zmscalldisplay/phpunit.xml zmsentities/phpunit.xml; do
    echo "=== $file ==="
    grep -A 1 -B 1 "stopOnFailure" "$file" || echo "No stopOnFailure setting found"
done

Length of output: 4443

zmsapi/.gitlab-ci.yml (2)

Line range hint 123-128: LGTM: Build configuration is properly aligned

The build-docker job correctly uses PHP 8.0, matching the main configuration, and has appropriate trigger conditions.

🧰 Tools
🪛 yamllint (1.35.1)

[warning] 7-7: wrong indentation: expected 8 but found 6

(indentation)


7-8: Verify PHP 8.0 compatibility

The upgrade from PHP 7.3 to 8.0 is significant. Please ensure all dependencies and code are compatible with PHP 8.0.

✅ Verification successful

Let me gather more information about PHP version compatibility by checking the composer.json file specifically.


Let me check the composer.json files specifically for PHP version constraints and dependencies.


PHP 8.0 compatibility is properly configured across the codebase

The codebase appears to be well-prepared for PHP 8.0:

  • All packages have their platform requirement set to PHP 8.0 in their composer.json config
  • The dependencies used (like Twig 3., Slim 4., etc.) are PHP 8.0 compatible versions
  • Base requirements in individual packages start from PHP 7.3, which makes the upgrade path to 8.0 smoother
  • No deprecated PHP functions or constructs that would break in PHP 8.0 were found in critical paths
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check composer.json for PHP version constraints and potential compatibility issues
if [ -f "composer.json" ]; then
    echo "Checking composer.json for PHP version constraints..."
    cat composer.json | jq '.require, ."require-dev"'
fi

# Look for potential PHP 8.0 compatibility issues in the codebase
echo "Checking for common PHP 7.x constructs that might need updates..."
rg -l "(?i)(split|create_function|each|(\s|^)assert\s*\(.*string.*\))"

Length of output: 16432


Script:

#!/bin/bash
# Check composer.json in zmsapi directory since that's where the CI file is
if [ -f "zmsapi/composer.json" ]; then
    echo "=== zmsapi/composer.json ==="
    cat zmsapi/composer.json | jq '.'
fi

# Also check composer.json in the root if it exists
if [ -f "composer.json" ]; then
    echo "=== Root composer.json ==="
    cat composer.json | jq '.'
fi

# Look for specific PHP 8.0 incompatible features
echo "=== Checking for specific PHP 8.0 incompatible patterns ==="
rg -l "(?i)(get_magic_quotes_gpc|parse_str\s*\([^,]|\{\$|real_escape_string|mysql_|ereg|split|create_function)"

Length of output: 102785


Script:

#!/bin/bash
# Check all composer.json files for PHP version constraints and dependencies
echo "=== Checking all composer.json files for PHP version constraints ==="
find . -name composer.json -exec sh -c 'echo "\n=== {} ==="; cat {} | jq ".require.php, .config.platform.php, .require"' \;

Length of output: 4753

🧰 Tools
🪛 yamllint (1.35.1)

[warning] 7-7: wrong indentation: expected 8 but found 6

(indentation)

.github/workflows/unit-tests.yaml (3)

47-47: LGTM! Image update is consistent

The container image update to PHP 8.0 is consistent with the module-test job and maintains the required development tools.


99-99: LGTM! Image update maintains consistency

The container image update aligns with the other jobs and maintains consistent PHP 8.0 usage across the workflow.


10-10: Verify GitHub Container Registry image accessibility

The image source change from GitLab registry to GitHub Container Registry looks good and aligns with the PR objectives.

Let's verify the image accessibility and PHP version:

✅ Verification successful

GitHub Container Registry image is available and properly configured

The image ghcr.io/it-at-m/eappointment-php-base:8.0-dev is verified to be available in the GitHub Container Registry. The API response shows:

  • The organization it-at-m exists and is active
  • The container repository eappointment-php-base is present
  • The specific tag 8.0-dev exists (created on 2024-11-21)
  • The image is being used consistently across the codebase in various workflow files
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify GitHub Container Registry image accessibility and PHP version
# Note: Using curl to check image manifest as docker commands aren't available

# Check if the image exists in GHCR
gh api \
  -H "Accept: application/vnd.oci.image.index.v1+json" \
  /v2/it-at-m/eappointment-php-base/manifests/8.0-dev

Length of output: 419


Script:

#!/bin/bash
# Let's try a different approach to verify the image
# 1. Check if the organization exists
gh api -H "Accept: application/json" /orgs/it-at-m

# 2. Check the container repository
gh api -H "Accept: application/json" /orgs/it-at-m/packages/container/eappointment-php-base/versions

# 3. Let's also check the workflow file to see if there are any other references or configurations
rg -A 5 "ghcr.io/it-at-m/eappointment-php-base" --type yaml

Length of output: 18788

zmsclient/src/Zmsclient/Result.php (2)

35-36: LGTM: Property declaration is well-documented

The PHPDoc block correctly specifies the type, and the property initialization follows PHP best practices.


58-58: Verify Validator class compatibility with PHP 8.0

While the formatting improvement is good, let's ensure the Validator class is compatible with PHP 8.0.

✅ Verification successful

Let me gather more specific information about the Validator class being used in the Result.php file.


From the results, I can see that the code is using BO\Mellon\Validator and its associated ValidJson class for JSON validation. The implementation is compatible with PHP 8.0 as it uses basic string type casting and JSON validation without any deprecated features. Let me generate the final response:

The Validator class is compatible with PHP 8.0

The Validator::value() method and its JSON validation functionality use standard PHP features that are fully supported in PHP 8.0. The implementation in mellon/src/Mellon/ValidJson.php uses basic string operations and JSON validation that remain unchanged in PHP 8.0.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check Validator class compatibility
rg -A 5 "class Validator" | grep -A 5 "class Validator"

# Check for any PHP 8.0 specific type declarations or features
ast-grep --pattern 'class Validator {
  $$$
  value($_) {
    $$$
  }
  $$$
}'

Length of output: 2177


Script:

#!/bin/bash
# Find the specific Validator class being used in Result.php
rg -B 2 "use.*Validator" zmsclient/src/Zmsclient/Result.php

# Check the implementation of value() method
rg -A 10 "public.*function.*value" --type php

# Look for the specific isJson validation
rg -A 5 "function.*isJson" --type php

Length of output: 27374

@@ -1,9 +1,9 @@
ARG PHP_VERSION
FROM registry.gitlab.com/eappointment/php-base:${PHP_VERSION}-dev as build
FROM ghcr.io/it-at-m/eappointment-php-base:${PHP_VERSION}-dev as build
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Base images are not publicly accessible

The GitHub Container Registry images ghcr.io/it-at-m/eappointment-php-base for both PHP versions (7.3, 8.0) and variants (dev, base) return 401 Unauthorized errors, indicating:

  • The images either don't exist or require authentication
  • CI/CD pipelines may fail if proper authentication is not configured

Please ensure:

  • The images exist in the specified registry
  • Required authentication credentials are properly configured
  • CI/CD systems have the necessary access tokens
🔗 Analysis chain

Verify accessibility and compatibility of new base images

The switch to GitHub Container Registry (ghcr.io) needs verification to ensure:

  1. The new image repository exists and is accessible
  2. The PHP version compatibility is maintained

Also applies to: 8-8

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence and access to the new base images
# Note: Using curl to check image manifest existence through GitHub Container Registry API

# Check both dev and base images for PHP 7.3 and 8.0
for PHP_VERSION in "7.3" "8.0"; do
  for VARIANT in "dev" "base"; do
    echo "Checking ${PHP_VERSION}-${VARIANT}..."
    curl -s -o /dev/null -w "%{http_code}" \
      -H "Accept: application/vnd.docker.distribution.manifest.v2+json" \
      "https://ghcr.io/v2/it-at-m/eappointment-php-base/manifests/${PHP_VERSION}-${VARIANT}"
  done
done

Length of output: 1096

@@ -1,9 +1,9 @@
ARG PHP_VERSION
FROM registry.gitlab.com/eappointment/php-base:${PHP_VERSION}-dev as build
FROM ghcr.io/it-at-m/eappointment-php-base:${PHP_VERSION}-dev as build
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider pinning to specific image versions

Using only ${PHP_VERSION} might lead to unexpected changes. Consider pinning to specific versions or SHA digests for better reproducibility and security.

-FROM ghcr.io/it-at-m/eappointment-php-base:${PHP_VERSION}-dev as build
+FROM ghcr.io/it-at-m/eappointment-php-base:${PHP_VERSION}-dev@sha256:<digest> as build

-FROM ghcr.io/it-at-m/eappointment-php-base:${PHP_VERSION}-base
+FROM ghcr.io/it-at-m/eappointment-php-base:${PHP_VERSION}-base@sha256:<digest>

Also applies to: 8-8

@@ -1,9 +1,9 @@
ARG PHP_VERSION
FROM registry.gitlab.com/eappointment/php-base:${PHP_VERSION}-dev as build
FROM ghcr.io/it-at-m/eappointment-php-base:${PHP_VERSION}-dev as build
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Base images might not be accessible or properly published

The verification attempts show that the new base images ghcr.io/it-at-m/eappointment-php-base:8.0-dev and ghcr.io/it-at-m/eappointment-php-base:8.0-base are not accessible. This could indicate:

  • The images haven't been published yet
  • The images are private and require authentication
  • The repository or image names might be incorrect

Please ensure:

  • The base images are properly published to GitHub Container Registry
  • The image names and tags are correct
  • If the images are private, proper authentication is configured in the deployment environment
🔗 Analysis chain

Verify accessibility and existence of new base images

The switch to GitHub Container Registry (ghcr.io) aligns with the PR objectives. Let's verify the new images are properly published and accessible.

Also applies to: 8-8


Let me try to verify the images with a different approach by checking the package information through GitHub API, as the direct manifest check might be restricted.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence and accessibility of the new base images
# Note: Using curl to check image manifest existence in GitHub Container Registry

# Function to check if image exists
check_image() {
    local image=$1
    local tag=$2
    echo "Checking ${image}:${tag}..."
    
    # Get GitHub API token from environment (if available)
    AUTH_HEADER=""
    if [ -n "$GITHUB_TOKEN" ]; then
        AUTH_HEADER="-H 'Authorization: Bearer $GITHUB_TOKEN'"
    fi
    
    # Check image manifest
    curl -s -f -L \
        $AUTH_HEADER \
        "https://ghcr.io/v2/it-at-m/eappointment-php-base/manifests/${tag}" \
        > /dev/null
    
    return $?
}

# Check both dev and base variants with PHP 8.0
for tag in "8.0-dev" "8.0-base"; do
    check_image "ghcr.io/it-at-m/eappointment-php-base" "$tag"
    if [ $? -ne 0 ]; then
        echo "Warning: Image ghcr.io/it-at-m/eappointment-php-base:${tag} might not be accessible"
    fi
done

Length of output: 1236


Script:

#!/bin/bash
# Check package information through GitHub API
curl -s -H "Accept: application/vnd.github+json" \
     "https://api.github.com/orgs/it-at-m/packages/container/eappointment-php-base/versions" | \
     grep -E "\"name\":|\"id\":" | head -n 10

Length of output: 175

Comment on lines +8 to 10
FROM ghcr.io/it-at-m/eappointment-php-base:${PHP_VERSION}-base
COPY --from=build --chown=0:0 /var/www/html /var/www/html
RUN chmod -R 1777 /var/www/html/data
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Review file permissions security

The permissions set to 1777 on the data directory might be too permissive. Consider:

  1. Using more restrictive permissions (e.g., 755)
  2. Setting specific user/group ownership instead of relying on world-writable permissions
-RUN chmod -R 1777 /var/www/html/data
+RUN chown -R www-data:www-data /var/www/html/data && \
+    chmod -R 755 /var/www/html/data
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
FROM ghcr.io/it-at-m/eappointment-php-base:${PHP_VERSION}-base
COPY --from=build --chown=0:0 /var/www/html /var/www/html
RUN chmod -R 1777 /var/www/html/data
FROM ghcr.io/it-at-m/eappointment-php-base:${PHP_VERSION}-base
COPY --from=build --chown=0:0 /var/www/html /var/www/html
RUN chown -R www-data:www-data /var/www/html/data && \
chmod -R 755 /var/www/html/data

@@ -3,8 +3,8 @@ include:

test-php-73:
variables:
PHP_VERSION: 7.3
image: registry.gitlab.com/eappointment/php-base:${PHP_VERSION}-dev
PHP_VERSION: 8.0
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Critical: Remove duplicate variables section with conflicting PHP version

The job has two variables sections with conflicting PHP versions:

  • One sets PHP_VERSION: 8.0
  • Another sets PHP_VERSION: "7.3"

This could lead to unexpected behavior depending on GitLab CI's variable precedence rules.

Consolidate the variables sections:

test-php-73:
    variables:
        PHP_VERSION: 8.0
    image: ghcr.io/it-at-m/eappointment-php-base:${PHP_VERSION}-dev
    script:
        - $CLI_COMPOSER
        - $CLI_PHPCS
        - $CLI_PHPMD
        - docker-php-ext-enable xdebug
        - $CLI_PHPUNIT $CLI_PHPUNIT_PARAM
    coverage: '/^\s*Lines:\s*\d+.\d+\%/'
    allow_failure: true
    before_script:
        - $CLI_COMPOSER
        - npm install --legacy-peer-deps
        - make css
-   variables:
-       PHP_VERSION: "7.3"
    only:
        changes:

Also applies to: 20-21

🧰 Tools
🪛 yamllint (1.35.1)

[warning] 6-6: wrong indentation: expected 8 but found 6

(indentation)

Comment on lines +6 to +7
PHP_VERSION: 8.0
image: ghcr.io/it-at-m/eappointment-php-base:${PHP_VERSION}-dev
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

PHP version constraints need updating in multiple dependencies

Several dependent packages still specify PHP 7.3 as minimum version in their composer.json files:

  • zmsdldb: ">=7.3.0"
  • zmsslim: ">=7.3.0"
  • zmsdb: ">=7.3.0"
  • zmsentities: ">=7.3.0"
  • zmscalldisplay: ">=7.3.0"
  • zmsclient: ">=7.3.0"

Additionally, found a reference to 'split' in zmsentities/src/Zmsentities/Schema/UnflattedArray.php that needs review for PHP 8.0 compatibility.

🔗 Analysis chain

LGTM! Verify PHP 8.0 compatibility across services

The PHP version upgrade and image source change align with the PR objectives. The changes are consistently applied.

Let's verify PHP 8.0 compatibility across dependent services:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for potential PHP 8.0 compatibility issues in composer.json files

# Find all composer.json files and check their PHP version constraints
fd composer.json --exec sh -c 'echo "=== {} ===" && cat {} | jq -r ".require.php"'

# Look for potential PHP 7.x specific code patterns
rg -t php '\b(split|ereg|eregi|mysql_|mcrypt_|create_function)\b' || echo "No PHP 7.x specific functions found"

Length of output: 721

🧰 Tools
🪛 yamllint (1.35.1)

[warning] 6-6: wrong indentation: expected 8 but found 6

(indentation)

Comment on lines +206 to +225
* Get the list of IDs from the data
*
* @return String
* @return string
*/
public function getIds()
{
$data = $this->getData();
$idList = array();
$idList = [];

foreach ($data as $item) {
if (array_key_exists('id', $item)) {
if (is_object($item) && method_exists($item, 'getId')) {
$idList[] = $item->getId();
} elseif (is_array($item) && array_key_exists('id', $item)) {
$idList[] = $item['id'];
} else {
throw new \UnexpectedValueException('Item is neither array nor object with getId() method');
}
}
return join(',', array_unique($idList));

return implode(',', array_unique($idList));
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enhance type safety and error handling in getIds method

The refactored method is more robust, but we can further improve it with PHP 8.0 features.

-    public function getIds()
+    public function getIds(): string
     {
-        $data = $this->getData();
+        $data = $this->getData() ?? [];
         $idList = [];
 
         foreach ($data as $item) {
             if (is_object($item) && method_exists($item, 'getId')) {
                 $idList[] = $item->getId();
             } elseif (is_array($item) && array_key_exists('id', $item)) {
                 $idList[] = $item['id'];
             } else {
-                throw new \UnexpectedValueException('Item is neither array nor object with getId() method');
+                throw new \UnexpectedValueException(
+                    sprintf(
+                        'Invalid item type. Expected array with "id" key or object with getId() method, got %s',
+                        is_object($item) ? get_class($item) : gettype($item)
+                    )
+                );
             }
         }
 
         return implode(',', array_unique($idList));
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
* Get the list of IDs from the data
*
* @return String
* @return string
*/
public function getIds()
{
$data = $this->getData();
$idList = array();
$idList = [];
foreach ($data as $item) {
if (array_key_exists('id', $item)) {
if (is_object($item) && method_exists($item, 'getId')) {
$idList[] = $item->getId();
} elseif (is_array($item) && array_key_exists('id', $item)) {
$idList[] = $item['id'];
} else {
throw new \UnexpectedValueException('Item is neither array nor object with getId() method');
}
}
return join(',', array_unique($idList));
return implode(',', array_unique($idList));
/**
* Get the list of IDs from the data
*
* @return string
*/
public function getIds(): string
{
$data = $this->getData() ?? [];
$idList = [];
foreach ($data as $item) {
if (is_object($item) && method_exists($item, 'getId')) {
$idList[] = $item->getId();
} elseif (is_array($item) && array_key_exists('id', $item)) {
$idList[] = $item['id'];
} else {
throw new \UnexpectedValueException(
sprintf(
'Invalid item type. Expected array with "id" key or object with getId() method, got %s',
is_object($item) ? get_class($item) : gettype($item)
)
);
}
}
return implode(',', array_unique($idList));
}

Comment on lines +241 to 244
if (!array_key_exists('$schema', $entityData)) {
$entityData['$schema'] = $data[0]['$schema'];
}
$this->data[] = Factory::create($entityData)->getEntity();
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

⚠️ Potential issue

Based on the code context, I can now provide a final assessment of the schema inheritance concern:

Safety checks are needed but schema inheritance is valid

The current schema inheritance pattern is actually valid for this codebase because:

  1. The setData method first checks if input has a $schema key and wraps it in an array if true - this handles single entity case
  2. The schema inheritance only happens for array items that don't already have a schema defined
  3. This matches the pattern seen in GraphQLInterpreter.php which uses similar schema handling

However, the empty array check is still needed:

    public function setData(array $data)
    {
+       if (empty($data)) {
+           return $this;
+       }
        if (array_key_exists('$schema', $data)) {
            $data = [$data];
        }
        foreach ($data as $entityData) {
            if (!array_key_exists('$schema', $entityData)) {
+               if (!isset($data[0]['$schema'])) {
+                   throw new \InvalidArgumentException('Cannot determine schema: no reference schema found');
+               }
                $entityData['$schema'] = $data[0]['$schema'];
            }
            $this->data[] = Factory::create($entityData)->getEntity();
        }
        return $this;
    }
🔗 Analysis chain

Verify schema inheritance logic and add safety checks

The current implementation assumes all items should inherit the schema from the first item, which might not always be correct. Additionally, there's no check for empty arrays.

Consider adding these safety checks:

         foreach ($data as $entityData) {
             if (!array_key_exists('$schema', $entityData)) {
+                if (empty($data) || !isset($data[0]['$schema'])) {
+                    throw new \InvalidArgumentException('Cannot determine schema: no reference schema found');
+                }
                 $entityData['$schema'] = $data[0]['$schema'];
             }
             $this->data[] = Factory::create($entityData)->getEntity();
         }

Let me analyze the schema usage patterns from the output. I can see that:

  1. The schema inheritance pattern is consistently used across the codebase, with $schema being a standard field in JSON responses
  2. In GraphQLInterpreter.php, there's similar schema handling logic that safely handles both array and single item cases
  3. The Result class is part of a larger system where schema validation is important for data integrity

Let me verify the setData method implementation:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for different schema usage patterns
rg -A 5 "\\\$schema.*=" 

# Look for potential schema variations in test files
fd -e php -x grep -l "\$schema" {} \; | xargs rg "setData.*array"

Length of output: 67214


Script:

# Check the full context of setData method
rg -A 10 -B 10 "setData.*array" zmsclient/src/Zmsclient/Result.php

# Look for any tests that verify this behavior
fd -e php -x rg "setData.*array.*schema" {} \;

Length of output: 682

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant