rfc:objects-can-be-falsifiable

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:objects-can-be-falsifiable [2022/10/31 19:57] – Add stricter implicit boolean coercions joshbrucerfc:objects-can-be-falsifiable [2022/11/04 23:14] (current) – Add static analysis section joshbruce
Line 2: Line 2:
   * Version: 0.92   * Version: 0.92
   * Date: 2020-07-16   * Date: 2020-07-16
-  * Author: Josh Bruce, josh@joshbruce.dev +  * Author: Josh Bruce, josh@joshbruce.com 
-  * Implementer: seeking (or someone willing to answer specific questions when I have them)+  * Implementer: seeking (or someone willing to answer specific questions when I have them) - https://github.com/joshbruce/php-src/pull/2
   * Status: Under discussion   * Status: Under discussion
   * First Published at: http://wiki.php.net/rfc/objects-can-be-falsifiable   * First Published at: http://wiki.php.net/rfc/objects-can-be-falsifiable
Line 145: Line 145:
 // ]; // ];
 </code> </code>
 +
 +===== Notes for static analysis ====
 +
 +Validate that the implementation can have both a true and false return, not just one or the other.
  
 ===== Type juggling tables ==== ===== Type juggling tables ====
Line 215: Line 219:
  
 ===== Open Issues ===== ===== Open Issues =====
 +
 +==== November 3, 2022 ====
 +
 +  * How would this impact <php>callable</php>? Would a class using <php>__invoke()</php> default to true? Can the same class implement Falsifiable and return false?
 +
  
 ==== July 16, 2020 ==== ==== July 16, 2020 ====
  
-  *  Default value for parameters with a class type can only be NULL+  * Default value for parameters with a class type can only be NULL 
        
 ==== July 15, 2020 ==== ==== July 15, 2020 ====
  
   * How type safe is this really? (desire is to increase type safety - partially by being able to return a single type from a method that resolves to false)   * How type safe is this really? (desire is to increase type safety - partially by being able to return a single type from a method that resolves to false)
-  * Impact to static analysis. Multiple static analyzers for PHP exist: Phan (Rasmus and Morrison), PHPStan (Mirtes), Psalm (Vimeo), and a general list - https://github.com/exakat/php-static-analysis-tools+  * RESOLVED (see static analysis section): Impact to static analysis. Multiple static analyzers for PHP exist: Phan (Rasmus and Morrison), PHPStan (Mirtes), Psalm (Vimeo), and a general list - https://github.com/exakat/php-static-analysis-tools
   * Interaction with equality operators.   * Interaction with equality operators.
   * Language around <php>bool|Falsifiable</php> implementation and need.   * Language around <php>bool|Falsifiable</php> implementation and need.
   * What version of PHP switched to only allowing <php>__construct()</php>   * What version of PHP switched to only allowing <php>__construct()</php>
- 
  
 ==== < July 15, 2020 ==== ==== < July 15, 2020 ====
Line 233: Line 242:
   * Presumes impact similar to <php>__toString()</php> and <php>Stringable</php>. RFC for <php>Stringable</php> listed concerns related to <php>__toString()</php> already being a method. Would look at the implementation as it should be similar, level of knowledge to implement is not there yet.   * Presumes impact similar to <php>__toString()</php> and <php>Stringable</php>. RFC for <php>Stringable</php> listed concerns related to <php>__toString()</php> already being a method. Would look at the implementation as it should be similar, level of knowledge to implement is not there yet.
   * As of this writing I do not have the knowledge, practice, and practical understanding of implementing within PHP internals to implement this myself. If you're interested in (helping) implement this concept, please do reach out (help may be in the form guidance and instruction or full implementation, up to you).   * As of this writing I do not have the knowledge, practice, and practical understanding of implementing within PHP internals to implement this myself. If you're interested in (helping) implement this concept, please do reach out (help may be in the form guidance and instruction or full implementation, up to you).
 +
  
 ===== Unaffected PHP Functionality ===== ===== Unaffected PHP Functionality =====
Line 257: Line 267:
 ===== Implementation ===== ===== Implementation =====
  
-Temporary PR for implementation, with status notes: https://github.com/joshbruce/php-src/pull/1+Temporary PR for implementation, with status notes: https://github.com/joshbruce/php-src/pull/2
  
 After the project is implemented, this section should contain  After the project is implemented, this section should contain 
Line 273: Line 283:
 Implemented: Implemented:
  
 +  * [[https://wiki.php.net/rfc/null-false-standalone-types|PHP RFC: Allow null and false as stand-alone types]]
   * [[https://wiki.php.net/rfc/union_types_v2|PHP RFC: Union Types 2.0]] - accept multiple types, including <php>null</php>   * [[https://wiki.php.net/rfc/union_types_v2|PHP RFC: Union Types 2.0]] - accept multiple types, including <php>null</php>
   * [[https://wiki.php.net/rfc/counting_non_countables|PHP RFC: Counting of non-countable objects]] - return <php>1</php> or <php>0</php>, not <php>null</php>.   * [[https://wiki.php.net/rfc/counting_non_countables|PHP RFC: Counting of non-countable objects]] - return <php>1</php> or <php>0</php>, not <php>null</php>.
Line 287: Line 298:
  
   * [[https://wiki.php.net/rfc/to-array|PHP RFC:__toArray()]] - implementation reference and where magic method should live   * [[https://wiki.php.net/rfc/to-array|PHP RFC:__toArray()]] - implementation reference and where magic method should live
 +  * [[https://wiki.php.net/rfc/invokable|PHP RFC: Invokable]] - see also [[https://www.php.net/manual/en/function.is-callable.php|is_callable]]
  
 Declined: Declined:
Line 297: Line 309:
 Other: Other:
  
-  * [[https://wiki.php.net/rfc/null_coercion_consistency|RFC describing some NULL-related issues]]+  * [[https://wiki.php.net/rfc/null_coercion_consistency|RFC describing some NULL-related issues]] and [[https://wiki.php.net/rfc/allow_null|another]]
   * [[https://externals.io/message/111009|Official thread]]   * [[https://externals.io/message/111009|Official thread]]
   * [[https://externals.io/message/111076|Mention of type juggling tables being added]] - started as new thread   * [[https://externals.io/message/111076|Mention of type juggling tables being added]] - started as new thread
rfc/objects-can-be-falsifiable.1667246253.txt.gz · Last modified: 2022/10/31 19:57 by joshbruce