Torv
Torv

Reputation: 1234

What is the best solution to deprecate include certain files

I have few ini files in project. Some of them is deprecated, how can i prevent their use?

I dont want delete them or change access permissions, i just want some error for slow refactoring=)

Any good solution or advice for this?

Thanks.

Upvotes: 2

Views: 228

Answers (3)

Wiktor
Wiktor

Reputation: 3059

@Jim's answer should do the trick if you want to alter (add throw excepion/warning line) every deprecated file. If you don't want to do that, you can also make list (an array) of deprecated files and check it against list of included files (get_included_files() function).

Upvotes: 2

MadDokMike
MadDokMike

Reputation: 182

you could throw php warnings every time an old function is called.

or throw an exception

depends what level of error seriousness you want to throw.

check here :

Is there any way to show, or throw, a PHP warning?

Upvotes: 0

Jim
Jim

Reputation: 22656

Something like trigger_error with E_USER_DEPRECATED would mean that users get a warning but can continue using it if they require.

If you don't want the files used at all then throwing an exception at the top of the file would probably do the trick.

Upvotes: 2

Related Questions