rfc:dbc
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:dbc [2015/02/12 14:05] – francois | rfc:dbc [2018/03/01 23:19] (current) – Typo "Under Discussion" carusogabriel | ||
---|---|---|---|
Line 3: | Line 3: | ||
* Date: 2015-02-09 | * Date: 2015-02-09 | ||
* Author: François Laupretre < | * Author: François Laupretre < | ||
- | * Status: | + | * Status: |
* First Published at: http:// | * First Published at: http:// | ||
+ | |||
+ | This RFC is waiting for the decisions that will be made about scalar | ||
+ | type hinting. The reason is that the design and syntax | ||
+ | decisions that will be made about scalar type hinting heavily impact the | ||
+ | contents of this RFC. Proposal is subject to be changed according scalar type | ||
+ | hinting implementation. | ||
===== Preamble ===== | ===== Preamble ===== | ||
+ | |||
+ | This RFC is part of " | ||
+ | |||
+ | * https:// | ||
+ | |||
+ | There is alternative implementation proposal by " | ||
+ | |||
+ | * https:// | ||
+ | |||
The original idea of introducing DbC in PHP comes from Yasuo Ohgaki | The original idea of introducing DbC in PHP comes from Yasuo Ohgaki | ||
Line 62: | Line 77: | ||
* This function computes the area of a triangle using Heron' | * This function computes the area of a triangle using Heron' | ||
* | * | ||
- | * @param | + | * @param |
* @requires ($a >= 0) | * @requires ($a >= 0) | ||
- | * @param | + | * @param |
* @requires ($b >= 0) | * @requires ($b >= 0) | ||
- | * @param | + | * @param |
* @requires ($c >= 0) | * @requires ($c >= 0) | ||
* @requires ($a <= ($b+$c)) | * @requires ($a <= ($b+$c)) | ||
Line 72: | Line 87: | ||
* @requires ($c <= ($a+$b)) | * @requires ($c <= ($a+$b)) | ||
* | * | ||
- | * @return | + | * @return |
* @ensures ($> >= 0) | * @ensures ($> >= 0) | ||
*/ | */ | ||
Line 94: | Line 109: | ||
$area=triangleArea(' | $area=triangleArea(' | ||
- | -> PHP Fatal error: triangleArea: | + | -> PHP Fatal error: triangleArea: |
$area=triangleArea(10, | $area=triangleArea(10, | ||
Line 143: | Line 158: | ||
/*-- Properties */ | /*-- Properties */ | ||
- | /** @var float Side lengths */ | + | /** @var number |
private $a,$b,$c; | private $a,$b,$c; | ||
Line 149: | Line 164: | ||
//--------- | //--------- | ||
/** | /** | ||
- | * @param | + | * @param |
- | * @param | + | * @param |
- | * @param | + | * @param |
* | * | ||
* No need to repeat constraints on values as they are checked by class invariants. | * No need to repeat constraints on values as they are checked by class invariants. | ||
Line 169: | Line 184: | ||
* This function computes the area of a triangle using Heron' | * This function computes the area of a triangle using Heron' | ||
* | * | ||
- | * @return | + | * @return |
* @ensures ($> >= 0) | * @ensures ($> >= 0) | ||
*/ | */ | ||
Line 191: | Line 206: | ||
$t=new triangle(' | $t=new triangle(' | ||
- | -> PHP Fatal error: triangle:: | + | -> PHP Fatal error: triangle:: |
$area=triangleArea(10, | $area=triangleArea(10, | ||
Line 268: | Line 283: | ||
type = " | type = " | ||
| " | | " | ||
- | | "float" | + | | "number" |
| " | | " | ||
| " | | " | ||
Line 308: | Line 323: | ||
^ integer | ^ integer | ||
^ integer! | ^ integer! | ||
- | ^ float | + | ^ number |
^ float! | ^ float! | ||
^ string | ^ string | ||
^ string! | ^ string! | ||
^ array | No | ^ array | No | ||
- | ^ callable | + | ^ callable |
^ object | ^ object | ||
^ resource | ^ resource | ||
Line 349: | Line 364: | ||
Synonyms: ' | Synonyms: ' | ||
- | == float == | + | == number |
Any value that returns true through is_numeric(). | Any value that returns true through is_numeric(). | ||
Line 355: | Line 370: | ||
Equivalent to ' | Equivalent to ' | ||
- | Synonyms: ' | + | Synonyms: ' |
== float! == | == float! == | ||
Line 389: | Line 404: | ||
== callable == | == callable == | ||
- | A string or array returning true through ' | + | A string, object |
Please consult the [[http:// | Please consult the [[http:// | ||
Line 739: | Line 754: | ||
[[https:// | [[https:// | ||
- |
rfc/dbc.1423749933.txt.gz · Last modified: 2017/09/22 13:28 (external edit)