Skip to content

Commit bad3cef

Browse files
committed
fileinfo: Deprecate finfo_close()
This is for consistency with other `*_close()` functions that have become obsolete when migrating from resources to objects.
1 parent 7831f65 commit bad3cef

File tree

5 files changed

+23
-4
lines changed

5 files changed

+23
-4
lines changed

ext/fileinfo/fileinfo.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@
3131
#include "php_ini.h"
3232
#include "ext/standard/info.h"
3333
#include "ext/standard/file.h" /* needed for context stuff */
34+
#include "Zend/zend_attributes.h"
35+
#include "Zend/zend_exceptions.h"
3436
#include "php_fileinfo.h"
3537
#include "fileinfo_arginfo.h"
3638
#include "fopen_wrappers.h" /* needed for is_url */
37-
#include "Zend/zend_exceptions.h"
3839

3940
static zend_object_handlers finfo_object_handlers;
4041
zend_class_entry *finfo_class_entry;

ext/fileinfo/fileinfo.stub.php

+1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ public function set_flags(int $flags): true {}
9292
/** @refcount 1 */
9393
function finfo_open(int $flags = FILEINFO_NONE, ?string $magic_database = null): finfo|false {}
9494

95+
#[\Deprecated(since: '8.5', message: 'as finfo objects are freed automatically')]
9596
function finfo_close(finfo $finfo): true {}
9697

9798
function finfo_set_flags(finfo $finfo, int $flags): true {}

ext/fileinfo/fileinfo_arginfo.h

+15-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/fileinfo/tests/finfo_close_basic.phpt

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ unset( $finfo );
2323
*** Testing finfo_close() : basic functionality ***
2424
object(finfo)#%d (0) {
2525
}
26+
27+
Deprecated: Function finfo_close() is deprecated since 8.5, as finfo objects are freed automatically in %s on line %d
2628
bool(true)
2729
object(finfo)#%d (%d) {
2830
}

ext/fileinfo/tests/finfo_close_error.phpt

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ try {
1515
}
1616

1717
?>
18-
--EXPECT--
18+
--EXPECTF--
1919
*** Testing finfo_close() : error conditions ***
2020

2121
-- Testing finfo_close() function with wrong resource type --
22+
23+
Deprecated: Function finfo_close() is deprecated since 8.5, as finfo objects are freed automatically in %s on line %d
2224
finfo_close(): Argument #1 ($finfo) must be of type finfo, resource given

0 commit comments

Comments
 (0)