phpinspectionsea icon indicating copy to clipboard operation
phpinspectionsea copied to clipboard

Request for Change; inspections regarding mkdir are incorrect (in my opinion)

Open rmpel opened this issue 2 years ago • 3 comments

Hi.

First of; this plugin is amazing! Really helpful tips, however, regarding mkdir, the suggestion is weird to say the least, or perhaps even wrong.

example;

when using mkdir( $some_folder ), the suggestion is to use ! mkdir( $some_folder ) && ! is_dir( $some_folder ) This, however, creates the situation where PHP complaints;

PHP Warning: mkdir(): File exists in /some/script.php

To solve this, an ! is_dir() is needed around the construction. but; is_dir is already in there ...

I would suggest the suggestion be changed to

! is_dir( $some_folder ) && ! mkdir( $some_folder )

This way, a check is done before attempting the creation of the folder and everyone is happy :)

Thanks for reading/listening :)

Remon.

rmpel avatar Aug 26 '22 08:08 rmpel

Couldn't agree more! Any progress on this?

luukvhoudt avatar Oct 19 '22 09:10 luukvhoudt

Seems like the problem is located in the MkdirRaceConditionInspector.java file.

luukvhoudt avatar Oct 19 '22 09:10 luukvhoudt

I'll try to make a pull-request for it, perhaps that is the preferred method??? (don't have a lot of experience in java, though, but I'll do my best)

rmpel avatar Oct 19 '22 09:10 rmpel