rfc:introduce-type-affinity

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
rfc:introduce-type-affinity [2015/03/16 22:03] yohgakirfc:introduce-type-affinity [2021/03/27 14:50] (current) – Move to inactive ilutov
Line 3: Line 3:
   * Date: 2015-03-16   * Date: 2015-03-16
   * Author: Yasuo Ohgaki <yohgaki@ohgaki.net>   * Author: Yasuo Ohgaki <yohgaki@ohgaki.net>
-  * Status: Draft+  * Status: Inactive
   * First Published at: http://wiki.php.net/rfc/introduce-type-affinity   * First Published at: http://wiki.php.net/rfc/introduce-type-affinity
  
 ===== Introduction ===== ===== Introduction =====
  
-PHP is weakly typed to make it work with Web smoothly. However, correct data type usage is more an more important in these days. Weakly typed does not mean typeless. SQLite2 was typeless, but SQLite3 became type aware by "Type Affinity" to achieve better performance.+PHP is weakly typed to make it work with Web smoothly. However, precise data type usage is more an more important in these days. Weakly typed does not mean typeless. SQLite2 was typeless, but SQLite3 became type aware by "Type Affinity" to achieve better performance.
  
 https://www.sqlite.org/datatype3.html https://www.sqlite.org/datatype3.html
Line 18: Line 18:
 Since inputs are converted to native type.  Since inputs are converted to native type. 
  
-  * PHP does not have convert ZVAL again and again. (e.g. "int" input is almost always treated as "int"+  * PHP does not have to convert ZVAL again and again. (e.g. "int" input is almost always treated as "int"
-  * It works well with coercive type or strict type if PHP has it.+  * It works well with coercive type or strict type if PHP has it. (Not work well with currently proposed "strict_types", though)
   * User can omit simple data type validation and concentrate what data should like.   * User can omit simple data type validation and concentrate what data should like.
  
Line 29: Line 29:
  
   * Detect possible data type without definition/hint   * Detect possible data type without definition/hint
-  * Have INI option for type affinity conversion+  * Have INI option for type affinity conversion (When "On", affinity conversion is done always for $_GET/$_POST/etc)
   * Data is stored with native data type   * Data is stored with native data type
   * Conversion will never raise error   * Conversion will never raise error
  
   * Provide data type definition/hint prior to the conversion   * Provide data type definition/hint prior to the conversion
-  * Apply type affinity function and convert+  * Apply type affinity function and convert (User must write code unlike previous one)
   * If there is conversion error, it may raise error   * If there is conversion error, it may raise error
  
Line 40: Line 40:
 Introduce type affinity conversion function:  Introduce type affinity conversion function: 
  
-  * void type_affinitize(mixed $input [, array $definition ]);+  * void type_affinitize(mixed &$input [, array $definition ]); 
 +  * void type_affinitize_input(string $input="GPC" [, array $definition ]); \\ "GPC" is for $_GET/$_POST/$_COOKIE
  
-Type affinity could be applied to any inputs including databases/etc. +Type affinity may be applied to any inputs including databases/$argv/etc. 
  
 Please suggest other ways/ideas. Thank you. Please suggest other ways/ideas. Thank you.
Line 82: Line 83:
 ===== Future Scope ===== ===== Future Scope =====
  
-Type affinity can increase usefulness of strict date typing. +Type affinity can increase usefulness of strict data typing. 
  
 ===== Proposed Voting Choices ===== ===== Proposed Voting Choices =====
rfc/introduce-type-affinity.1426543424.txt.gz · Last modified: 2017/09/22 13:28 (external edit)