PHPMD Take some time to response - with FileResource PHP Deprecated
- 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
- [x] Be sure that there isn't already an issue about this. See: Issues list
- [x] Be sure that there isn't already a pull request about this. See: Pull requests
- [x] I have added every step to reproduce the bug.
- [x] If possible I added relevant code examples.
- [x] This issue is about 1 bug and nothing more.
- [x] The issue has a descriptive title. For example: "JSON rendering failed on Windows for filenames with space".
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
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
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.
@kylekatarnls Thank You for explanation. That's make senes.
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 https://github.com/symfony/config/commit/b8f4eaed0131c05a18c595b7d9026d88e93508ae )
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 ?
It will until next major version