title: How to prevent usage of public parent methods in child instance in PHP?
body: <p>So let's say I have classes called parent and child, which will be then used from PHP file called caller.php</p>
  
  <pre><code>class Child extends Parent {
  
  }
  
  class Parent {
  
      public function parentMethod(){
  
      }
  }
  </code></pre>
  
  <p>caller.php</p>
  
  <p>PREVENTED:</p>
  
  <pre><code>$child = new Child();
  $child-&gt;parentMethod();
  </code></pre>
  
  <p>ALLOWED:</p>
  
  <pre><code>$parent = new Parent();
  $parent-&gt;parentMethod();
  </code></pre>
  
  <p>I want to prevent calling parentMethod like this. But if I created Parent object I want to be able to call the parentMethod. Is there some way that I can use to hide this method from being public in Child class, but still allowing parent object to call this method publicly?</p>
  
  <p>Only solution I have come up with so far is making those methods protected and then creating an other class that would extend parent and then have public method for each function that it needs, but that doesn't sound very smart.</p>