Skip to content

Commit

Permalink
Deprecate fgetss() and gzgetss()
Browse files Browse the repository at this point in the history
SplFileObject::fgetss() will also generate a deprecation notice
through an internal call to fgetss().

Part of RFC https://wiki.php.net/rfc/deprecations_php_7_3.
  • Loading branch information
nikic committed Jul 5, 2018
1 parent 16dc24e commit 5928950
Show file tree
Hide file tree
Showing 14 changed files with 98 additions and 5 deletions.
5 changes: 4 additions & 1 deletion ext/spl/tests/bug45216.phpt
Expand Up @@ -17,6 +17,9 @@ var_dump(fgetss($handle));
<?php
unlink(dirname(__FILE__) . '/foo.html');
?>
--EXPECT--
--EXPECTF--
Deprecated: Function fgetss() is deprecated in %s on line %d
string(12) "text 0text 1"

Deprecated: Function fgetss() is deprecated in %s on line %d
string(12) "text 0text 1"
2 changes: 1 addition & 1 deletion ext/standard/basic_functions.c
Expand Up @@ -3128,7 +3128,7 @@ static const zend_function_entry basic_functions[] = { /* {{{ */
PHP_FE(feof, arginfo_feof)
PHP_FE(fgetc, arginfo_fgetc)
PHP_FE(fgets, arginfo_fgets)
PHP_FE(fgetss, arginfo_fgetss)
PHP_DEP_FE(fgetss, arginfo_fgetss)
PHP_FE(fread, arginfo_fread)
PHP_NAMED_FE(fopen, php_if_fopen, arginfo_fopen)
PHP_FE(fpassthru, arginfo_fpassthru)
Expand Down
61 changes: 61 additions & 0 deletions ext/standard/tests/file/fgetss.phpt
Expand Up @@ -39,45 +39,106 @@ var_dump(fgetss($fp, 0));
echo "Done\n";
?>
--EXPECTF--
Deprecated: Function fgetss() is deprecated in %s on line %d
string(18) "askasdfasdfaaaaaa
"

Deprecated: Function fgetss() is deprecated in %s on line %d
string(6) "dddddd"

Deprecated: Function fgetss() is deprecated in %s on line %d
string(6) "asdqw
"

Deprecated: Function fgetss() is deprecated in %s on line %d
string(8) "aaaaqqqq"

Deprecated: Function fgetss() is deprecated in %s on line %d
string(23) "aaafunction foo() {}qqq"

Deprecated: Function fgetss() is deprecated in %s on line %d
bool(false)

Deprecated: Function fgetss() is deprecated in %s on line %d
string(6) "asdasd"

Deprecated: Function fgetss() is deprecated in %s on line %d
string(0) ""

Deprecated: Function fgetss() is deprecated in %s on line %d
bool(false)

Deprecated: Function fgetss() is deprecated in %s on line %d
bool(false)

Deprecated: Function fgetss() is deprecated in %s on line %d
string(11) "some text
"

Deprecated: Function fgetss() is deprecated in %s on line %d
string(4) "blah"

Deprecated: Function fgetss() is deprecated in %s on line %d
string(24) "some another text hoho "

Deprecated: Function fgetss() is deprecated in %s on line %d
bool(false)

Deprecated: Function fgetss() is deprecated in %s on line %d
string(9) "askasdfas"

Deprecated: Function fgetss() is deprecated in %s on line %d
string(6) "dfaaaa"

Deprecated: Function fgetss() is deprecated in %s on line %d
string(5) "asdqw"

Deprecated: Function fgetss() is deprecated in %s on line %d
string(0) ""

Deprecated: Function fgetss() is deprecated in %s on line %d
string(3) "aaa"

Deprecated: Function fgetss() is deprecated in %s on line %d
string(7) "functio"

Deprecated: Function fgetss() is deprecated in %s on line %d
string(6) "asdasd"

Deprecated: Function fgetss() is deprecated in %s on line %d
string(0) ""

Deprecated: Function fgetss() is deprecated in %s on line %d
bool(false)

Deprecated: Function fgetss() is deprecated in %s on line %d
bool(false)

Deprecated: Function fgetss() is deprecated in %s on line %d
string(9) "some text"

Deprecated: Function fgetss() is deprecated in %s on line %d
string(2) "
"

Deprecated: Function fgetss() is deprecated in %s on line %d
string(9) "some anot"

Deprecated: Function fgetss() is deprecated in %s on line %d
string(9) "her text "

Deprecated: Function fgetss() is deprecated in %s on line %d

Warning: fgetss(): Length parameter must be greater than 0 in %s on line %d
bool(false)

Deprecated: Function fgetss() is deprecated in %s on line %d

Warning: fgetss(): Length parameter must be greater than 0 in %s on line %d
bool(false)

Deprecated: Function fgetss() is deprecated in %s on line %d

Warning: fgetss(): supplied resource is not a valid stream resource in %s on line %d
bool(false)
Done
1 change: 1 addition & 0 deletions ext/standard/tests/file/fgetss1.phpt
Expand Up @@ -2,6 +2,7 @@
more fgetss() tests
--FILE--
<?php
error_reporting(E_ALL & ~E_DEPRECATED);

$filename = dirname(__FILE__)."/fgetss1.html";

Expand Down
2 changes: 2 additions & 0 deletions ext/standard/tests/file/fgetss_basic1.phpt
Expand Up @@ -2,6 +2,8 @@
Test fgetss() function : Basic functionality - read modes only
--FILE--
<?php
error_reporting(E_ALL & ~E_DEPRECATED);

/*
Prototype: string fgetss ( resource $handle [, int $length [, string $allowable_tags]] );
Description: Gets line from file pointer and strip HTML tags
Expand Down
2 changes: 2 additions & 0 deletions ext/standard/tests/file/fgetss_basic2.phpt
Expand Up @@ -8,6 +8,8 @@ if (substr(PHP_OS, 0, 3) == 'WIN') {
?>
--FILE--
<?php
error_reporting(E_ALL & ~E_DEPRECATED);

/*
Prototype: string fgetss ( resource $handle [, int $length [, string $allowable_tags]] );
Description: Gets line from file pointer and strip HTML tags
Expand Down
2 changes: 2 additions & 0 deletions ext/standard/tests/file/fgetss_error.phpt
Expand Up @@ -2,6 +2,8 @@
Test fgetss() function : error conditions
--FILE--
<?php
error_reporting(E_ALL & ~E_DEPRECATED);

/*
Prototype: string fgetss ( resource $handle [, int $length [, string $allowable_tags]] );
Description: Gets line from file pointer and strip HTML tags
Expand Down
2 changes: 2 additions & 0 deletions ext/standard/tests/file/fgetss_variation1.phpt
Expand Up @@ -8,6 +8,8 @@ if (substr(PHP_OS, 0, 3) == 'WIN') {
?>
--FILE--
<?php
error_reporting(E_ALL & ~E_DEPRECATED);

/*
Prototype: string fgetss ( resource $handle [, int $length [, string $allowable_tags]] );
Description: Gets line from file pointer and strip HTML tags
Expand Down
2 changes: 2 additions & 0 deletions ext/standard/tests/file/fgetss_variation2.phpt
Expand Up @@ -2,6 +2,8 @@
Test fgetss() function : usage variations - read modes
--FILE--
<?php
error_reporting(E_ALL & ~E_DEPRECATED);

/*
Prototype: string fgetss ( resource $handle [, int $length [, string $allowable_tags]] );
Description: Gets line from file pointer and strip HTML tags
Expand Down
2 changes: 2 additions & 0 deletions ext/standard/tests/file/fgetss_variation3.phpt
Expand Up @@ -8,6 +8,8 @@ if (substr(PHP_OS, 0, 3) == 'WIN') {
?>
--FILE--
<?php
error_reporting(E_ALL & ~E_DEPRECATED);

/*
Prototype: string fgetss ( resource $handle [, int $length [, string $allowable_tags]] );
Description: Gets line from file pointer and strip HTML tags
Expand Down
2 changes: 2 additions & 0 deletions ext/standard/tests/file/fgetss_variation4.phpt
Expand Up @@ -7,6 +7,8 @@ if(substr(PHP_OS, 0, 3) == "WIN")
?>
--FILE--
<?php
error_reporting(E_ALL & ~E_DEPRECATED);

/*
Prototype: string fgetss ( resource $handle [, int $length [, string $allowable_tags]] );
Description: Gets line from file pointer and strip HTML tags
Expand Down
2 changes: 2 additions & 0 deletions ext/standard/tests/file/fgetss_variation5.phpt
Expand Up @@ -8,6 +8,8 @@ if (substr(PHP_OS, 0, 3) == 'WIN') {
?>
--FILE--
<?php
error_reporting(E_ALL & ~E_DEPRECATED);

/*
Prototype: string fgetss ( resource $handle [, int $length [, string $allowable_tags]] );
Description: Gets line from file pointer and strip HTML tags
Expand Down
16 changes: 14 additions & 2 deletions ext/zlib/tests/gzgetss.phpt
Expand Up @@ -16,5 +16,17 @@ while (!gzeof($handle)){
}
gzclose($handle);
?>
--EXPECT--
<code>stringgzgetss(resource $zp, int $length [, string $allowable_tags ]);<code/>
--EXPECTF--
Deprecated: Function gzgetss() is deprecated in %s on line %d


Deprecated: Function gzgetss() is deprecated in %s on line %d


Deprecated: Function gzgetss() is deprecated in %s on line %d
<code>stringgzgetss(resource $zp, int $length [, string $allowable_tags ]);<code/>

Deprecated: Function gzgetss() is deprecated in %s on line %d


Deprecated: Function gzgetss() is deprecated in %s on line %d
2 changes: 1 addition & 1 deletion ext/zlib/zlib.c
Expand Up @@ -1393,7 +1393,7 @@ static const zend_function_entry php_zlib_functions[] = {
PHP_FALIAS(gzeof, feof, arginfo_gzpassthru)
PHP_FALIAS(gzgetc, fgetc, arginfo_gzpassthru)
PHP_FALIAS(gzgets, fgets, arginfo_gzgets)
PHP_FALIAS(gzgetss, fgetss, arginfo_gzgetss)
PHP_DEP_FALIAS(gzgetss, fgetss, arginfo_gzgetss)
PHP_FALIAS(gzread, fread, arginfo_gzread)
PHP_FE(gzopen, arginfo_gzopen)
PHP_FALIAS(gzpassthru, fpassthru, arginfo_gzpassthru)
Expand Down

0 comments on commit 5928950

Please sign in to comment.