Skip to content

fix: remove mixed type hints from RawData trait for PHP 7.4 compatibility#280

Open
daniolivet8 wants to merge 1 commit intopipedrive:masterfrom
daniolivet8:fix/remove-mixed-type-hints-for-php74-compat
Open

fix: remove mixed type hints from RawData trait for PHP 7.4 compatibility#280
daniolivet8 wants to merge 1 commit intopipedrive:masterfrom
daniolivet8:fix/remove-mixed-type-hints-for-php74-compat

Conversation

@daniolivet8
Copy link

Summary

  • Remove mixed native type hints from RawData trait (v1 and v2) to restore PHP 7.4 compatibility
  • Keep PHPDoc @var mixed, @param mixed, and @return mixed annotations for documentation
  • Fully backward compatible with PHP 8.x (no type hint = accepts any type, same as mixed)

Problem

composer.json declares "php": "^7.4 || ^8.0", but the mixed type (property, parameter, and return type) was introduced in PHP 8.0. On PHP 7.4, it causes a fatal error:

Argument 1 passed to Pipedrive\versions\v2\Model\DealItem::setRawData() must be an instance of
Pipedrive\versions\v2\Traits\mixed, instance of stdClass given

PHP 7.4 interprets mixed as a class name in the current namespace instead of the native type.

Files changed

  • lib/versions/v1/Traits/RawData.php
  • lib/versions/v2/Traits/RawData.php

Closes #279

…lity

The `mixed` type was introduced in PHP 8.0. Using it as a property type,
parameter type, or return type causes a fatal error on PHP 7.4, where it
is interpreted as a class name within the current namespace.

Since `composer.json` declares `"php": "^7.4 || ^8.0"`, this change
removes the native `mixed` type hints while keeping the PHPDoc
annotations (`@var mixed`, `@param mixed`, `@return mixed`) intact.

This is fully backward compatible: omitting a type hint in PHP 8.x
is equivalent to accepting any type, same as `mixed`.

Fixes pipedrive#279
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.

RawData trait uses 'mixed' type hints incompatible with PHP 7.4

1 participant