Skip to content

Commit 0b22dca

Browse files
committed
Removing functions that have been removed from PHP before 7.1
Removing functions that have been removed BEFORE PHP 7.1. Closes #60
1 parent 4547d46 commit 0b22dca

File tree

9 files changed

+23
-247
lines changed

9 files changed

+23
-247
lines changed

generated/functionsList.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,6 @@
296296
'imageopenpolygon',
297297
'imagepng',
298298
'imagepolygon',
299-
'imagepsencodefont',
300-
'imagepsextendfont',
301-
'imagepsfreefont',
302-
'imagepsslantfont',
303299
'imagerectangle',
304300
'imageresolution',
305301
'imagerotate',
@@ -366,7 +362,6 @@
366362
'phpinfo',
367363
'putenv',
368364
'set_include_path',
369-
'set_magic_quotes_runtime',
370365
'set_time_limit',
371366
'ingres_autocommit',
372367
'ingres_close',
@@ -491,7 +486,6 @@
491486
'mssql_data_seek',
492487
'mssql_field_length',
493488
'mssql_field_name',
494-
'mssql_field_seek',
495489
'mssql_field_type',
496490
'mssql_free_result',
497491
'mssql_free_statement',
@@ -874,9 +868,7 @@
874868
'session_decode',
875869
'session_destroy',
876870
'session_regenerate_id',
877-
'session_register',
878871
'session_reset',
879-
'session_unregister',
880872
'session_unset',
881873
'session_write_close',
882874
'shmop_delete',
@@ -1009,7 +1001,6 @@
10091001
'uopz_implement',
10101002
'base64_decode',
10111003
'get_headers',
1012-
'import_request_variables',
10131004
'settype',
10141005
'xdiff_file_bdiff',
10151006
'xdiff_file_bpatch',

generated/image.php

Lines changed: 0 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,92 +1519,6 @@ function imagepolygon($image, array $points, int $num_points, int $color): void
15191519
}
15201520

15211521

1522-
/**
1523-
* Loads a character encoding vector from a file and changes the fonts
1524-
* encoding vector to it. As a PostScript fonts default vector lacks most of
1525-
* the character positions above 127, you'll definitely want to change this
1526-
* if you use a language other than English.
1527-
*
1528-
* If you find yourself using this function all the time, a much
1529-
* better way to define the encoding is to set ps.default_encoding in
1530-
* the configuration file
1531-
* to point to the right encoding file and all fonts you load will
1532-
* automatically have the right encoding.
1533-
*
1534-
* @param resource $font_index A font resource, returned by imagepsloadfont.
1535-
* @param string $encodingfile The exact format of this file is described in T1libs documentation.
1536-
* T1lib comes with two ready-to-use files,
1537-
* IsoLatin1.enc and
1538-
* IsoLatin2.enc.
1539-
* @throws ImageException
1540-
*
1541-
*/
1542-
function imagepsencodefont($font_index, string $encodingfile): void
1543-
{
1544-
error_clear_last();
1545-
$result = \imagepsencodefont($font_index, $encodingfile);
1546-
if ($result === false) {
1547-
throw ImageException::createFromPhpError();
1548-
}
1549-
}
1550-
1551-
1552-
/**
1553-
* Extend or condense a font (font_index), if
1554-
* the value of the extend parameter is less
1555-
* than one you will be condensing the font.
1556-
*
1557-
* @param resource $font_index A font resource, returned by imagepsloadfont.
1558-
* @param float $extend Extension value, must be greater than 0.
1559-
* @throws ImageException
1560-
*
1561-
*/
1562-
function imagepsextendfont($font_index, float $extend): void
1563-
{
1564-
error_clear_last();
1565-
$result = \imagepsextendfont($font_index, $extend);
1566-
if ($result === false) {
1567-
throw ImageException::createFromPhpError();
1568-
}
1569-
}
1570-
1571-
1572-
/**
1573-
* imagepsfreefont frees memory used by a PostScript
1574-
* Type 1 font.
1575-
*
1576-
* @param resource $font_index A font resource, returned by imagepsloadfont.
1577-
* @throws ImageException
1578-
*
1579-
*/
1580-
function imagepsfreefont($font_index): void
1581-
{
1582-
error_clear_last();
1583-
$result = \imagepsfreefont($font_index);
1584-
if ($result === false) {
1585-
throw ImageException::createFromPhpError();
1586-
}
1587-
}
1588-
1589-
1590-
/**
1591-
* Slant a given font.
1592-
*
1593-
* @param resource $font_index A font resource, returned by imagepsloadfont.
1594-
* @param float $slant Slant level.
1595-
* @throws ImageException
1596-
*
1597-
*/
1598-
function imagepsslantfont($font_index, float $slant): void
1599-
{
1600-
error_clear_last();
1601-
$result = \imagepsslantfont($font_index, $slant);
1602-
if ($result === false) {
1603-
throw ImageException::createFromPhpError();
1604-
}
1605-
}
1606-
1607-
16081522
/**
16091523
* imagerectangle creates a rectangle starting at
16101524
* the specified coordinates.

generated/info.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -557,23 +557,6 @@ function set_include_path(string $new_include_path): string
557557
}
558558

559559

560-
/**
561-
* Set the current active configuration setting of magic_quotes_runtime.
562-
*
563-
* @param bool $new_setting FALSE for off, TRUE for on.
564-
* @throws InfoException
565-
*
566-
*/
567-
function set_magic_quotes_runtime(bool $new_setting): void
568-
{
569-
error_clear_last();
570-
$result = \set_magic_quotes_runtime($new_setting);
571-
if ($result === false) {
572-
throw InfoException::createFromPhpError();
573-
}
574-
}
575-
576-
577560
/**
578561
* Set the number of seconds a script is allowed to run. If this is reached,
579562
* the script returns a fatal error. The default limit is 30 seconds or, if

generated/mssql.php

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -184,27 +184,6 @@ function mssql_field_name($result, int $offset = -1): string
184184
}
185185

186186

187-
/**
188-
* Seeks to the specified field offset. If the next call to
189-
* mssql_fetch_field won't include a field
190-
* offset, this field would be returned.
191-
*
192-
* @param resource $result The result resource that is being evaluated. This result comes from a
193-
* call to mssql_query.
194-
* @param int $field_offset The field offset, starts at 0.
195-
* @throws MssqlException
196-
*
197-
*/
198-
function mssql_field_seek($result, int $field_offset): void
199-
{
200-
error_clear_last();
201-
$result = \mssql_field_seek($result, $field_offset);
202-
if ($result === false) {
203-
throw MssqlException::createFromPhpError();
204-
}
205-
}
206-
207-
208187
/**
209188
* Returns the type of field no. offset in
210189
* result.

generated/session.php

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -94,47 +94,6 @@ function session_regenerate_id(bool $delete_old_session = false): void
9494
}
9595

9696

97-
/**
98-
* session_register accepts a variable number of
99-
* arguments, any of which can be either a string holding the name of a
100-
* variable or an array consisting of variable names or other arrays. For
101-
* each name, session_register registers the global
102-
* variable with that name in the current session.
103-
*
104-
* You can also create a session variable by simply setting the
105-
* appropriate member of the $_SESSION array.
106-
*
107-
*
108-
*
109-
* ]]>
110-
*
111-
*
112-
*
113-
* If session_start was not called before this function
114-
* is called, an implicit call to session_start with no
115-
* parameters will be made. $_SESSION does not mimic
116-
* this behavior and requires session_start before use.
117-
*
118-
* @param mixed $name A string holding the name of a variable or an array consisting of
119-
* variable names or other arrays.
120-
* @param mixed $params
121-
* @throws SessionException
122-
*
123-
*/
124-
function session_register($name, ...$params): void
125-
{
126-
error_clear_last();
127-
if ($params !== []) {
128-
$result = \session_register($name, ...$params);
129-
} else {
130-
$result = \session_register($name);
131-
}
132-
if ($result === false) {
133-
throw SessionException::createFromPhpError();
134-
}
135-
}
136-
137-
13897
/**
13998
* session_reset reinitializes a session with
14099
* original values stored in session storage. This function requires an active session and
@@ -153,24 +112,6 @@ function session_reset(): void
153112
}
154113

155114

156-
/**
157-
* session_unregister unregisters the global variable
158-
* named name from the current session.
159-
*
160-
* @param string $name The variable name.
161-
* @throws SessionException
162-
*
163-
*/
164-
function session_unregister(string $name): void
165-
{
166-
error_clear_last();
167-
$result = \session_unregister($name);
168-
if ($result === false) {
169-
throw SessionException::createFromPhpError();
170-
}
171-
}
172-
173-
174115
/**
175116
* The session_unset function frees all session variables
176117
* currently registered.

generated/var.php

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -4,52 +4,6 @@
44

55
use Safe\Exceptions\VarException;
66

7-
/**
8-
* Imports GET/POST/Cookie variables into the global scope. It is useful if
9-
* you disabled register_globals,
10-
* but would like to see some variables in the global scope.
11-
*
12-
* If you're interested in importing other variables into the global scope,
13-
* such as $_SERVER, consider using extract.
14-
*
15-
* @param string $types Using the types parameter, you can specify
16-
* which request variables to import. You can use 'G', 'P' and 'C'
17-
* characters respectively for GET, POST and Cookie. These characters are
18-
* not case sensitive, so you can also use any combination of 'g', 'p'
19-
* and 'c'. POST includes the POST uploaded file information.
20-
*
21-
* Note that the order of the letters matters, as when using
22-
* "GP", the
23-
* POST variables will overwrite GET variables with the same name. Any
24-
* other letters than GPC are discarded.
25-
* @param string $prefix Variable name prefix, prepended before all variable's name imported
26-
* into the global scope. So if you have a GET value named
27-
* "userid", and provide a prefix
28-
* "pref_", then you'll get a global variable named
29-
* $pref_userid.
30-
*
31-
* Although the prefix parameter is optional, you
32-
* will get an E_NOTICE level
33-
* error if you specify no prefix, or specify an empty string as a
34-
* prefix. This is a possible security hazard. Notice level errors are
35-
* not displayed using the default error reporting level.
36-
* @throws VarException
37-
*
38-
*/
39-
function import_request_variables(string $types, string $prefix = null): void
40-
{
41-
error_clear_last();
42-
if ($prefix !== null) {
43-
$result = \import_request_variables($types, $prefix);
44-
} else {
45-
$result = \import_request_variables($types);
46-
}
47-
if ($result === false) {
48-
throw VarException::createFromPhpError();
49-
}
50-
}
51-
52-
537
/**
548
* Set the type of variable var to
559
* type.

generator/src/DocPage.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Safe;
44

5+
use function explode;
6+
57
class DocPage
68
{
79
/*
@@ -27,6 +29,23 @@ public function detectFalsyFunction(): bool
2729
{
2830
$file = file_get_contents($this->path);
2931

32+
if (preg_match('/&warn\.deprecated\.function-(\d+-\d+-\d+)\.removed-(\d+-\d+-\d+)/', $file, $matches)) {
33+
$removedVersion = $matches[2];
34+
[$major, $minor, $fix] = explode('-', $removedVersion);
35+
if ($major < 7 || ($major == 7 && $minor == 0)) {
36+
// Ignore function if it was removed before PHP 7.1
37+
return false;
38+
}
39+
}
40+
if (preg_match('/&warn\.removed\.function-(\d+-\d+-\d+)/', $file, $matches)) {
41+
$removedVersion = $matches[2];
42+
[$major, $minor, $fix] = explode('-', $removedVersion);
43+
if ($major < 7 || ($major == 7 && $minor == 0)) {
44+
// Ignore function if it was removed before PHP 7.1
45+
return false;
46+
}
47+
}
48+
3049
if (preg_match('/&false;\s+on\s+error/m', $file)) {
3150
return true;
3251
}

generator/tests/DocPageTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@ public function testDetectFalsyFunction() {
1212
$getCwd = new DocPage(__DIR__ . '/../doc/doc-en/en/reference/dir/functions/getcwd.xml');
1313
$setTime = new DocPage(__DIR__ . '/../doc/doc-en/en/reference/datetime/datetime/settime.xml');
1414
$filesize = new DocPage(__DIR__ . '/../doc/doc-en/en/reference/filesystem/functions/filesize.xml');
15+
$sessionRegister = new DocPage(__DIR__ . '/../doc/doc-en/en/reference/session/functions/session-register.xml');
16+
$mcryptDecrypt = new DocPage(__DIR__ . '/../doc/doc-en/en/reference/mcrypt/functions/mcrypt-decrypt.xml');
1517

1618
$this->assertTrue($pregMatch->detectFalsyFunction());
1719
$this->assertFalse($implode->detectFalsyFunction());
1820
$this->assertTrue($getCwd->detectFalsyFunction());
1921
$this->assertTrue($setTime->detectFalsyFunction());
2022
$this->assertTrue($filesize->detectFalsyFunction());
23+
$this->assertFalse($sessionRegister->detectFalsyFunction());
24+
$this->assertTrue($mcryptDecrypt->detectFalsyFunction());
2125
}
2226
}

0 commit comments

Comments
 (0)