title: Why typecasting is not an option in PHP function parameters
body: <p>This might sound like a silly question to many of you, but it keeps me wondering why PHP does not allow typecasting in its function parameters. Many people use this method to cast into their parameters:</p>
  
  <pre><code>private function dummy($id,$string){
      echo (int)$id." ".(string)$string
  }
  </code></pre>
  
  <p>Or</p>
  
  <pre><code>private function dummy($id,$string){
      $number=(int)$id;
      $name=(string)$string;
      echo $number." ".$name;
  }
  </code></pre>
  
  <p>But looking at many other programming languages, they accept typecasting into their function parameters. But doing this in PHP may lead to errors.</p>
  
  <pre><code>private function dummy((int)$id,(string)$string){
      echo $id." ".$string;
  }
  </code></pre>
  
  <blockquote>
    <p>Parse error: syntax error, unexpected T_INT_CAST, expecting '&amp;' or T_VARIABLE</p>
  </blockquote>
  
  <p>Or</p>
  
  <pre><code>private function dummy(intval($id),strval($string)){
      echo $id." ".$string;
  }
  </code></pre>
  
  <blockquote>
    <p>Parse error: syntax error, unexpected '(', expecting '&amp;' or T_VARIABLE</p>
  </blockquote>
  
  <p>Just want to know why this does not work and if there is a way. If there is no way, then going to the regular way is alright for me:</p>
  
  <pre><code>private function dummy($id,$string){
      echo (int)$id." ".(string)$string;
  }
  </code></pre>