outscraper-php icon indicating copy to clipboard operation
outscraper-php copied to clipboard

Deprecated PHP 8.4 Warnings: Nullable Parameters Need Explicit Type Declarations

Open wemadefoxnever opened this issue 11 months ago • 2 comments

Hello,

I'm currently using your excellent Outscraper package in a Laravel project, and I've noticed some deprecation warnings when running with PHP 8.4. These warnings are related to implicit nullable parameters that need to be explicitly typed according to PHP 8.4's stricter type system.

The affected areas are:

  1. In outscraper.php:
    • Line 22: Constructor parameter $api_key
    • Line 108: google_search() method parameters $region and $webhook
    • ...

Current warnings:

OutscraperClient::__construct(): Implicitly marking parameter $api_key as nullable is deprecated
OutscraperClient::google_search(): Implicitly marking parameter $region as nullable is deprecated
OutscraperClient::google_search(): Implicitly marking parameter $webhook as nullable is deprecated

To resolve these warnings, the parameters would need to be explicitly marked as nullable using the ? prefix. For example:

public function __construct(?string $api_key)
public function google_search(..., ?string $region, ?string $webhook)

Would you consider updating these method signatures to support PHP 8.4's type system requirements? This would help users who are upgrading their applications to use newer PHP versions. Thank you for maintaining this useful package!

wemadefoxnever avatar Feb 15 '25 07:02 wemadefoxnever

It would be great to get php 8.4 support

colivinggit avatar Mar 22 '25 11:03 colivinggit

patching this for now with https://github.com/symplify/vendor-patches was a smooth and easy fix for me

rmaake1 avatar Apr 23 '25 16:04 rmaake1

fixed in the latest version

vlad-stack avatar Jun 17 '25 17:06 vlad-stack