Check if the file exists prior to checking if its writable
When calling deptrac init if the file doesn't exist then isWritable is false and we error out.
The SplFileInfo->isFile() "Checks if the file referenced by this SplFileInfo object exists and is a regular file."
So if it exists and is a file but is not writeable then throw an error otherwise allow the file to be created and populated.
It would likely also be smart to add more error checking here. Such as checking if the dirname($target) exists and is writeable and if not try to create it or something.
Hey, thank you for your PR it was really valuable in understanding the problem.
I was curious, why the if condition before doesn't catch the existing file, so I started writing a test for the Dumper. I hope #987 solves your problem and prevents something similar from happening.
Feel free to copy my solution, so that I can merge your PR, if you would like to get the contribution credit. Otherwise I will just merge #987 instead.
I'm happy for the fix to be in more than anything. You've got it all done so go ahead and merge your work!