title: PHP classes conforming a parameter passed to a method to a class - Type Hinting
body: <p>This is a simple question but I do not know the terms for this so thought this question would be useful.</p>
  
  <p>In PHP, I have seen this construct:</p>
  
  <pre><code>Class Class_A{
      ...
      function sampleMethod(Class_B $a){
          ..
      }
  }
  $a = /* some value */;
  $obj = new Class_A;
  $return = $obj-&gt;sampleMethod($a);
  </code></pre>
  
  <p>The part I don't understand is prefixing <code>$a</code> with <code>Class_B</code> in the argument to method <code>sampleMethod()</code>.</p>
  
  <p>Questions I have are:</p>
  
  <ul>
  <li>What is the correct terminology for this method? (So I can research)</li>
  <li>Are we declaring the variable to <em>be</em> Class_B?</li>
  <li>Does <code>$a</code> have to be an object of Class_B already? Are there conditions under which the variable type of <code>$a</code> will not be compatible with Class_B?</li>
  </ul>
  
  <p>-- Edit: the term I was seeking was Type Hinting --</p>