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

PHPMD Take some time to response - with FileResource PHP Deprecated #1057

Open
6 tasks done
Kotzilla opened this issue Jan 5, 2024 · 6 comments
Open
6 tasks done

Comments

@Kotzilla
Copy link

Kotzilla commented Jan 5, 2024

  • PHPMD version: 2.15
  • PHP Version: 8.3.1
  • Installation type: homebrew
  • Operating System / Distribution & Version: OSX

Current Behavior

im running phpmd via sublime linter and command line with

phpmd -vvv SomeController.php text phpmd.xml

it's return warning and take time around 6s (im on macbook m2)

PHP Deprecated: Symfony\Component\Config\Resource\FileResource implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in phar:///opt/homebrew/Cellar/phpmd/2.15.0/bin/phpmd/vendor/symfony/config/Resource/FileResource.php on line 21

Here is code im testing with

<?php namespace App\Http\Controllers\Backend;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Http\Requests;

class DashboardController extends Controller
{
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct(): void
    {
        $this->middleware('auth');
    }

    public function index()
    {
        $hello = 'John';
        
        return view('backend.dashboard.index');
    }
}

Expected Behavior

Should take less time without warning

Steps To Reproduce:

  • Install the phpmd version 2.15 from the homebrew in command.
  • Run phpmd inside sublime with php 8.3.1, php 8.2 and the warnings will appear.
  • Run phpmd in command line with php 8.3.1, php 8.2 and the warnings will appear.
  • Run phpmd that's install via composer it's no error or any message and still take some time to response.
  • testing with only unuse variable in class

Checks before submitting

  • Be sure that there isn't already an issue about this. See: Issues list
  • Be sure that there isn't already a pull request about this. See: Pull requests
  • I have added every step to reproduce the bug.
  • If possible I added relevant code examples.
  • This issue is about 1 bug and nothing more.
  • The issue has a descriptive title. For example: "JSON rendering failed on Windows for filenames with space".
@AJenbo
Copy link
Member

AJenbo commented Jan 5, 2024

How long is it taking?
What hardware are you using?
Can you share SomeController.php?
What is less time?

Run phpmd that's install via composer it's no error or any message and still take some time to response.

Sounds like the issue is with how homebrew is packaging phpmd, maybe contact them regarding the warning

@Kotzilla
Copy link
Author

Kotzilla commented Jan 5, 2024

Hi,

How long is it taking?
I'm adding an example code and it takes 3s to response.
testing with phpmd from homebrew takes ~3s with warning (both sublimelinter, command line)
testing with phpmd from composer takes ~3s without warning (only command line)

What hardware are you using?
On my local machine is MBP2022(M2)

What is less time?
It's use to be around ~1s

@kylekatarnls
Copy link
Member

kylekatarnls commented Jan 7, 2024

Run phpmd that's install via composer it's no error or any message and still take some time to response.

Installing whith homebrew, you get the PHAR build which is a single build that needs to run everywhere whatever is the PHP version, so you get an old version of symfony/config in it for backward-compatibility reason and this old version uses methods that are deprecated in 8.3. There is no possible fix for that, it will de facto be solved when dropping old versions on next major version.

Composer installation does not have this pitfall as it will install the more recent version of symfony/component compatible with your PHP version.

@Kotzilla
Copy link
Author

Kotzilla commented Jan 8, 2024

@kylekatarnls Thank You for explanation. That's make senes.

@llaville
Copy link

Deprecated1: Symfony\Component\Config\Resource\FileResource implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) in phar:///shared/backups/forks/phpmd.phar/vendor/symfony/config/Resource/FileResource.php on line 21

See source code embeddedd into PHPMD PHAR version : https://github.com/symfony/config/blob/2.8/Resource/FileResource.php

Explains is given on PHP documentation : https://www.php.net/manual/en/class.serializable

This problem was solved since Symfony 4.3 ( see symfony/config@b8f4eae )

Symfony 4.3 did not support PHP 5.3 until 7.0.
The question to have in mind : is it really acceptable to support those PHP versions that are no more maintained ?

@kylekatarnls
Copy link
Member

It will until next major version

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

No branches or pull requests

5 participants