Gregwar / Image

A PHP library to handle images
MIT License
1k stars 190 forks source link

Inconsistencies between fromData and fromFile #110

Open nebulousGirl opened 8 years ago

nebulousGirl commented 8 years ago

fromFile only changes the source, but fromData creates a new instance losing any configuration previously set (like the cacheFolder)

Is there a reason why a new instance is created only for fromData?

nebulousGirl commented 8 years ago

I just saw that the function is static that would explain why a new instance is returned, but why is fromFile not static?

nebulousGirl commented 8 years ago

This cannot be resolved without breaking changes. It is essentially a naming problem.

There are methods like setResource and setData that do not create new instances, but no setFile method.

And there are fromData and fromResource which create a new instance while fromFile does not.

That kind of inconsistencies can be confusing when you start using a library. To fix the issue, fromFile would have to return a new instance and a setFile method should be created with the current behavior from fromFile.

Is a new major version planned to correct this issue?

Gregwar commented 8 years ago

Hello, Actually, the fromFile that creates an instance is open () I agree that the namd is not really good, one could ask what it would break to change this