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

php 8.4 namespace incompatibility #97

Closed
esetnik opened this issue Dec 23, 2024 · 4 comments
Closed

php 8.4 namespace incompatibility #97

esetnik opened this issue Dec 23, 2024 · 4 comments

Comments

@esetnik
Copy link

esetnik commented Dec 23, 2024

Crunz version: 3.7.0

PHP version: 8.4+

Operating system type and version:
macOS, linux

Description
Globals are referencing the task namespace in php 8.4 in closure tasks. The same code works in php <= 8.3.

How to reproduce

<?php

use Crunz\Schedule;

$schedule = new Schedule;

$url = 'http://webservices.oorsprong.org/websamples.countryinfo/CountryInfoService.wso?WSDL';

$task = $schedule->run(function () use ($url) {
    // Do some cool stuff in here
    $soapClient = new SoapClient(
        $url,
        [
            'soap_version' => SOAP_1_2,
            'trace' => true,
            'exceptions' => true,
            'cache_wsdl' => WSDL_CACHE_DISK,
            'keep_alive' => true,
        ]
    );

});

$task
    ->everyMinute()
    ->description('Copying the project directory');

return $schedule;

Possible Solution
You can workaround the issue by adding a leading \ to the globals, e.g. $soapClient = new \SoapClient()

Additional context
laravel/serializable-closure#90

@PabloKowalczyk
Copy link
Member

PabloKowalczyk commented Dec 25, 2024

Please check #98

@esetnik
Copy link
Author

esetnik commented Dec 27, 2024

That should solve the issue. Can you publish a beta version for me to test?

@PabloKowalczyk
Copy link
Member

In this case you can just apply git patch

@esetnik
Copy link
Author

esetnik commented Dec 28, 2024

I tested the changes and everything is working well on php 8.4.2. Thanks.

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

No branches or pull requests

2 participants