Skip to main content
added 318 characters in body
Source Link
Clive
  • 167.9k
  • 19
  • 303
  • 337

All hooks are in the global scope; PHP doesn’t allow two functions to have the same name in the global scope (it wouldn’t be able to distinguish which the intended callee was). It will exit with a fatal error during parsing.

Yes, there is a definite potential for conflicts in the style you mentioned, but I doubt you’ll see it happen that often in the real world.

I’m not really sure what you mean by the 2nd example. Modules don’t “declare” hooks as such, not in any programmatically significant way at least, they just invoke them (and hopefully document them in an include api file).

There’s the hook_hook_info concept, but that’s just for allowing hooks to be implemented in an automatically included sub-file of a module.

All hooks are in the global scope; PHP doesn’t allow two functions to have the same name in the global scope (it wouldn’t be able to distinguish which the intended callee was). It will exit with a fatal error during parsing.

Yes, there is a definite potential for conflicts in the style you mentioned, but I doubt you’ll see it happen that often in the real world.

All hooks are in the global scope; PHP doesn’t allow two functions to have the same name in the global scope (it wouldn’t be able to distinguish which the intended callee was). It will exit with a fatal error during parsing.

Yes, there is a definite potential for conflicts in the style you mentioned, but I doubt you’ll see it happen that often in the real world.

I’m not really sure what you mean by the 2nd example. Modules don’t “declare” hooks as such, not in any programmatically significant way at least, they just invoke them (and hopefully document them in an include api file).

There’s the hook_hook_info concept, but that’s just for allowing hooks to be implemented in an automatically included sub-file of a module.

Source Link
Clive
  • 167.9k
  • 19
  • 303
  • 337

All hooks are in the global scope; PHP doesn’t allow two functions to have the same name in the global scope (it wouldn’t be able to distinguish which the intended callee was). It will exit with a fatal error during parsing.

Yes, there is a definite potential for conflicts in the style you mentioned, but I doubt you’ll see it happen that often in the real world.