title: in PHP correct solution for String offset cast occurred
body: <p>on the following functions, I get the error </p>
  
  <blockquote>
    <p>'String offset cast occured'</p>
  </blockquote>
  
  <pre><code>protected function setBitAtPosition($pos) {
      list($char, $byte) = $this-&gt;position2CharAndByte($pos);
      // Error Notice :  String offset cast occurred in ....
      $this-&gt;bitField[$char] = $this-&gt;bitField[$char] | $byte;
  }
  
  protected function getBitAtPosition($pos) {
      list($char, $byte) = $this-&gt;position2CharAndByte($pos);
      // Error Notice :  String offset cast occurred in ....
      return ($this-&gt;bitField[$char] &amp; $byte) === $byte;
  }
  
  
  var_dump($this-&gt;position2CharAndByte($pos));
  array(2) {
    [0] =&gt;
    double(9552303)
    [1] =&gt;
    string(1) "Ç"
  }
  </code></pre>
  
  <p>As of PHP 5.4 string offsets have to either be integers or integer-like strings, otherwise a warning will be thrown.</p>
  
  <p>Is the correct solution is to cast to integer like this </p>
  
  <p><code>$this-&gt;bitField[(int)$char] = $this-&gt;bitField[(int)$char] | $byte;</code></p>
  
  <p><code>return ($this-&gt;bitField[(int)$char] &amp; $byte) === $byte;</code></p>