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

functions_products: zen_get_prid(): Argument #1 ($uprid) must be of type string, int given #6082

Closed
torvista opened this issue Dec 11, 2023 · 1 comment · Fixed by #6157
Closed

Comments

@torvista
Copy link
Member

add
declare(strict_types=1);
to the start of functions_products

Add a product to the cart
PHP Fatal error: Uncaught TypeError: zen_get_prid(): Argument #1 ($uprid) must be of type string, int given, called in includes\functions\functions_products.php on line 550 and defined in \includes\functions\functions_products.php:458

I suggest adding the same (declare(strict_types=1);) to the shopping_cart class at the same time for related useages/as it is debateable exactly where fixes should be applied.

@drbyte drbyte changed the title functions_products: fatal error with shopping_cart when declare(strict_types=1); functions_products: zen_get_prid(): Argument #1 ($uprid) must be of type string, int given Jan 3, 2024
@drbyte
Copy link
Member

drbyte commented Jan 27, 2024

This is a case where coercive typing is intentional, because the incoming value could at any time be a string or an integer.

Fortunately we can change the function signature to accept a hybrid in this case.

drbyte added a commit to drbyte/zencart that referenced this issue Jan 27, 2024
drbyte added a commit that referenced this issue Jan 31, 2024
* Declare parameter as `string|int` for zen_get_prid

Fixes #6082

* Manually coerce values back and forth for strict-type limitations

* Force types

* Specify types

* Rework inspection for gift certs in cart

* Try to avoid loss of precision while implementing strict type support

* force override of coercive types to strict
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 a pull request may close this issue.

2 participants