Skip to content

Instantly share code, notes, and snippets.

@reanim8ed
Created January 17, 2023 15:47
Show Gist options
  • Save reanim8ed/67006e7342cfff9497940bf1f176800a to your computer and use it in GitHub Desktop.
Save reanim8ed/67006e7342cfff9497940bf1f176800a to your computer and use it in GitHub Desktop.
[Prestashop override classes] #prestashop

Sometimes you may need to extend a method that is currently set to be private. Unfortunately, it is not possible to extend private variables or methods in PHP.

This is a design issue. Core modules were written long before the introduction of module overrides. Difference is that private scope “locks down” class features, while protected scope is less strict and allows overrides by a child class.

If you come across a core module method that is private, the best thing to do is change it to protected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment