Skip to content

Commit

Permalink
Deprecate FILE_BINARY and FILE_TEXT constants
Browse files Browse the repository at this point in the history
These constants have no effect.

Part of https://wiki.php.net/rfc/deprecations_php_8_1.
  • Loading branch information
nikic committed Jul 8, 2021
1 parent 6390158 commit 92f6e21
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
5 changes: 4 additions & 1 deletion UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,13 @@ PHP 8.1 UPGRADE NOTES
RFC: https://wiki.php.net/rfc/phase_out_serializable

- Standard:
. Calling key(), current(), next(), prev(), reset(), or end() on objects
. Calling key(), current(), next(), prev(), reset(), or end() on objects
is deprecated. Instead cast the object to array first, or make use of
ArrayIterator.
RFC: https://wiki.php.net/rfc/deprecations_php_8_1
. The FILE_BINARY and FILE_TEXT constants are deprecated. They already had
no effect previously.
RFC: https://wiki.php.net/rfc/deprecations_php_8_1

========================================
5. Changed Functions
Expand Down
4 changes: 2 additions & 2 deletions ext/standard/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,8 @@ PHP_MINIT_FUNCTION(file)
REGISTER_LONG_CONSTANT("FILE_APPEND", PHP_FILE_APPEND, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILE_NO_DEFAULT_CONTEXT", PHP_FILE_NO_DEFAULT_CONTEXT, CONST_CS | CONST_PERSISTENT);

REGISTER_LONG_CONSTANT("FILE_TEXT", 0, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILE_BINARY", 0, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("FILE_TEXT", 0, CONST_CS | CONST_PERSISTENT | CONST_DEPRECATED);
REGISTER_LONG_CONSTANT("FILE_BINARY", 0, CONST_CS | CONST_PERSISTENT | CONST_DEPRECATED);

#ifdef HAVE_FNMATCH
REGISTER_LONG_CONSTANT("FNM_NOESCAPE", FNM_NOESCAPE, CONST_CS | CONST_PERSISTENT);
Expand Down
15 changes: 15 additions & 0 deletions ext/standard/tests/file/file_binary_text_deprecated.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--TEST--
The FILE_BINARY and FILE_TEXT constants are deprecated
--FILE--
<?php

var_dump(FILE_BINARY);
var_dump(FILE_TEXT);

?>
--EXPECTF--
Deprecated: Constant FILE_BINARY is deprecated in %s on line %d
int(0)

Deprecated: Constant FILE_TEXT is deprecated in %s on line %d
int(0)

0 comments on commit 92f6e21

Please sign in to comment.