1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Multiple access type modifiers are not allowed

Discussion in 'XenForo Development Discussions' started by CrispinP, Jun 6, 2016.

  1. CrispinP

    CrispinP Active Member

    Hi folks,

    I'm having a clash with one of my add-ons (paid) and someone else's add-on.
    Thread is here: https://xenforo.com/community/threads/user-map-paid.116884

    In my data writer, I extend DataWriter_User

    Code:
    
    class Crispin_UserMap_DataWriter_User extends XFCP_Crispin_UserMap_DataWriter_User
    {
    
        public function _postSave()
        {
            // call parent
            parent::_postSave();
    
            if (!XenForo_Application::get('options')->crispin_usermap_enable_geolocation_on_save)
                return;
    ....snip
    

    The error is coming in because another add-on is doing the same thing but his _postSave method is protected. Mine is public.

    At first I thought fair-enough, it's an _ method so perhaps protected is correct. However, if I specify protected then I get the error:
    Multiple access type modifiers are not allowed


    So...
    a) Who's correct? Me or the other add-on?
    b) if other add-on then what I do too correct it and make it working in future?


    thanks
    C
     
    Sean Kendle likes this.
  2. CrispinP

    CrispinP Active Member

    Perhaps I just need to remove the public and let it be default (which is protected).
     
  3. Thomas.B

    Thomas.B Well-Known Member

    Afaik this error occurs only if you (accidentially) state more than one access modifier such as in public private myMethod()

    The _postSave() method in the XF core is declared as protected. So you should also use this modifier for your method..
     
  4. CrispinP

    CrispinP Active Member

    yup, I was being silly. Apologies - I should have updated the thread.


    I did have it as public by mistake. The give-away should have been the method starting with an underscore.

    When I fixed that I got the "multiple access type" error because one of the methods being called was public.

    All in all - it was a PEBCAK error :)
     

Share This Page