Skip to content

Add 'resource (closed)' type and assertions for closed resources#4365

Merged
sebastianbergmann merged 1 commit into
sebastianbergmann:masterfrom
stemis:fix/issue-4276-closed-resource-assertion
Jul 7, 2020
Merged

Add 'resource (closed)' type and assertions for closed resources#4365
sebastianbergmann merged 1 commit into
sebastianbergmann:masterfrom
stemis:fix/issue-4276-closed-resource-assertion

Conversation

@stemis

@stemis stemis commented Jul 6, 2020

Copy link
Copy Markdown
Contributor

Related #4276

During the release of PHP 7.2 gettype() was improved to be able to detect closed resources. The type resource (closed) was added to the return list. Previously it was very difficult to detect when a resource was closed because php's is_resource() function is not strict

PHP's is_resource():

is_resource() is not a strict type-checking method: it will return FALSE if var is a resource variable that has been closed.

Notes:

  • I have built this with strictness in mind, a closed resource is still a resource.
  • This is a BC change.

This PR adds assertions:

  • assertIsClosedResource()
  • assertIsNotClosedResource()

@codecov

codecov Bot commented Jul 6, 2020

Copy link
Copy Markdown

Codecov Report

Merging #4365 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #4365   +/-   ##
=========================================
  Coverage     85.27%   85.28%           
- Complexity     4609     4610    +1     
=========================================
  Files           219      219           
  Lines         12157    12164    +7     
=========================================
+ Hits          10367    10374    +7     
  Misses         1790     1790           
Impacted Files Coverage Δ Complexity Δ
src/Framework/Assert.php 94.29% <100.00%> (+0.07%) 225.00 <2.00> (+2.00)
src/Framework/Constraint/Type/IsType.php 97.72% <100.00%> (-0.15%) 22.00 <0.00> (-1.00)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f971401...8836ddc. Read the comment docs.

@sebastianbergmann sebastianbergmann added feature/assertion Issues related to assertions and expectations type/enhancement A new idea that should be implemented labels Jul 7, 2020
@sebastianbergmann sebastianbergmann added this to the PHPUnit 9.3 milestone Jul 7, 2020
@sebastianbergmann sebastianbergmann merged commit a30201d into sebastianbergmann:master Jul 7, 2020
@stemis stemis deleted the fix/issue-4276-closed-resource-assertion branch July 7, 2020 06:55
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Apr 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

feature/assertion Issues related to assertions and expectations type/enhancement A new idea that should be implemented

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants