• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Find double file names in helper directory?

#1
[eluser]Nummero2[/eluser]
Hi again,

is it possible to search the helpers directory for doubled entries? (like you have 10 helpers and two have accidentally the same name)

Greetings Sebastian

#2
[eluser]Nummero2[/eluser]
Is there nothing?

#3
[eluser]xwero[/eluser]
Accidentally adding 2 helpers with the same name isn't possible because the name of the helper is filename based. You can't have two files with the same name in the same directory in any OS i know.

If you have a helper file in the system/helpers directory and one in the application/helpers directory the file in the latter directory will be loaded. But it's not a good idea because it causes confusion.

I think accidentally is the key word here. If you did it you should detect it in the development period of the app. If you create helper files in your app you should prevent helpers from having the same name.

#4
[eluser]sophistry[/eluser]
I believe that Nummero2 is asking about function name collision rather than filename collision. PHP will cry if you try to load a function that already is loaded. I suppose that is why you ask. One way is to force every function to be wrapped inside the PHP function called function_exists(). see the CI helpers for examples.

Numerro2... have you considered maintaining a "registry" of functions in a db table and checking against when loading functions that so that you don't get the PHP errors on duplicate function declaration? OR maybe just write the errors to the log file and check the log file for any functions that failed the function_exists() check?

I still think you should reconsider your approach... the problems you are posting on these forums are not "normal" problems and probably stem from a fundamentally flawed initial code architecture decision.

#5
[eluser]xwero[/eluser]
He's maintaining two related threads and i mentioned the same in his other thread. By wanting something he got blind to other solutions.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.