rfc:typecheckingweak

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
rfc:typecheckingweak [2009/07/12 15:43] – Add reference to object conversion zeevrfc:typecheckingweak [2009/07/13 07:23] – Remove a note which turns out to be more confusing than useful zeev
Line 32: Line 32:
  
 <code php> <code php>
-function foo(int x) {} +function foo(int $x) {} 
-function bar(x, string y) {} +function bar($x, string $y) {} 
-function baz(int x, float y, string z) {} +function baz(int $x, float $y, string $z) {} 
-function foobar(int &x) {}+function foobar(int &$x) {}
 </code> </code>
  
Line 48: Line 48:
 bar('whatever', 17.5);  // argument will be converted to a string '17.5' before being passed to bar() bar('whatever', 17.5);  // argument will be converted to a string '17.5' before being passed to bar()
 foobar(17.5);           // will fail (scalar value cannot be passed by reference) foobar(17.5);           // will fail (scalar value cannot be passed by reference)
-$x=17.5;  foobar($x);   // $x will be converted to 17(int), and then passed to foobar()+$x=17.5;  foobar($x);   // $x will be converted to 17(int), and then passed to foobar(); $x remains 17(int) after the call to foobar()
 </code> </code>
  
Line 57: Line 57:
   - Emit an error or throw an exception.   - Emit an error or throw an exception.
  
-**Note:**  In step 2, if the argument is designated as a pass-by-reference argument - the conversion will apply to the variable being passed.  This is consistent with the expectation that arguments passed by reference may be modified by the function they're sent to. 
  
  
Line 124: Line 123:
  
 <code php> <code php>
-function baz(int x, float y, string z) {}+function baz(int $x, float $y, string $z) {}
  
 // Strict type checking // Strict type checking
rfc/typecheckingweak.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1