title: parent class don't lock file with flock function
body: <p>I've got a batch, which extends a base class.
  I need to implement in base class a unique system execution, made with flock, so everyone extends from base class should have an unique execution</p>
  
  <p>First class</p>
  
  <pre><code>class batch1 extends base_batch
  {
      public function execute()
      {
          //do some stuff
      }
  }
  </code></pre>
  
  <p>base class</p>
  
  <pre><code>abstract class base_batch
  {
      private function realPathExecution()
      {
          $object = new ReflectionObject($this); 
          $location = $object-&gt;getFileName();
          return $location;
      }
  
      public function ensureOneExecution()
      {
          $realPath = $this-&gt;realPathExecution();
          $fp = fopen($realPath, "r+");
          if (!flock($fp, LOCK_EX | LOCK_NB, $blocked)) {
              if ($blocked) {
                  // another process holds the lock
                  print_r("Other sther script in run! \n");
                  return False;
              }
              flock($fp, LOCK_UN);
              // couldn't lock for another reason, e.g. no such file
              print_r("Error! Nothing done. \n");
              return False;
          }
          return true;
      }
  
  
      public function __construct()
      {
          if (!$this-&gt;ensureOneExecution()) {
              print_r("Not flock!! \n");
              exit(1);
          }
          //do some stuff
  
          return;
      }
  
      ....
  
  
  }
  </code></pre>
  
  <p>If I use this structure, I can execute 2 or more times simultaneously this code; but if I take outside ensureOneExecution function it works correctly.</p>