Skip to content

Commit

Permalink
drop support for PHP 7
Browse files Browse the repository at this point in the history
  • Loading branch information
remicollet committed Jan 24, 2024
1 parent 93342c6 commit fcc7dec
Show file tree
Hide file tree
Showing 10 changed files with 6 additions and 204 deletions.
7 changes: 3 additions & 4 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ more than adequate.
</stability>
<license uri="https://www.php.net/license/3_01.txt" filesource="LICENSE">PHP-3.01</license>
<notes>
- drop PHP 5 support
- add type hinting with PHP 8+
- drop support for PHP 5 and 7
- add type hinting
</notes>
<contents>
<dir name="/">
Expand All @@ -68,7 +68,6 @@ more than adequate.
<file name="dio.c" role="src" />
<file name="dio.stub.php" role="src" />
<file name="dio_arginfo.h" role="src" />
<file name="dio_legacy_arginfo.h" role="src" />
<file name="dio_common.c" role="src" />
<file name="dio_posix.c" role="src" />
<file name="dio_win32.c" role="src" />
Expand All @@ -85,7 +84,7 @@ more than adequate.
<dependencies>
<required>
<php>
<min>7.0.0</min>
<min>8.0.0</min>
</php>
<pearinstaller>
<min>1.10.0</min>
Expand Down
5 changes: 1 addition & 4 deletions src/dio.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,8 @@
# endif /* CNEW_RTSCTS */
#endif /* !CRTSCTS */

#if PHP_VERSION_ID < 80000
#include "dio_legacy_arginfo.h"
#else
#include "dio_arginfo.h"
#endif

/*
+----------------------------------------------------------------------+
| DEPRECATED FUNCTIONALITY |
Expand Down
2 changes: 1 addition & 1 deletion src/dio.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/**
* @generate-class-entries
* @generate-legacy-arginfo
* @generate-legacy-arginfo 80000
*/

/**
Expand Down
2 changes: 1 addition & 1 deletion src/dio_arginfo.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 74f93c791a08145405f1f08b0d8ee26876e92798 */
* Stub hash: c960cbb93c3f8966636813ca2346e35030451bf4 */

ZEND_BEGIN_ARG_INFO_EX(arginfo_dio_open, 0, 0, 2)
ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0)
Expand Down
124 changes: 0 additions & 124 deletions src/dio_legacy_arginfo.h

This file was deleted.

25 changes: 0 additions & 25 deletions src/dio_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,8 @@ php_dio_stream_data * dio_create_stream_data(void) {
/* {{{ dio_common_write
* Writes count chars from the buffer to the stream described by the stream data.
*/
#if PHP_VERSION_ID < 70400
size_t dio_common_write(php_dio_stream_data *data, const char *buf, size_t count) {
size_t ret;
#else
ssize_t dio_common_write(php_dio_stream_data *data, const char *buf, size_t count) {
ssize_t ret;
#endif

/* Blocking writes can be interrupted by signals etc. If
* interrupted try again. Not sure about non-blocking
Expand All @@ -264,11 +259,7 @@ ssize_t dio_common_write(php_dio_stream_data *data, const char *buf, size_t coun
}
} while (errno == EINTR);

#if PHP_VERSION_ID < 70400
return 0;
#else
return ret;
#endif
}
/* }}} */

Expand Down Expand Up @@ -311,11 +302,7 @@ static int dio_timeval_subtract(struct timeval *late, struct timeval *early, str
/* {{{ dio_common_read
* Reads count chars to the buffer to the stream described by the stream data.
*/
#if PHP_VERSION_ID < 70400
size_t dio_common_read(php_dio_stream_data *data, const char *buf, size_t count) {
#else
ssize_t dio_common_read(php_dio_stream_data *data, const char *buf, size_t count) {
#endif
int fd = ((php_dio_posix_stream_data*)data)->fd;
size_t ret, total = 0;
char *ptr = (char*)buf;
Expand All @@ -335,11 +322,7 @@ ssize_t dio_common_read(php_dio_stream_data *data, const char *buf, size_t count
data->end_of_file = 1;
}
} while ((errno == EINTR) && !data->end_of_file);
#if PHP_VERSION_ID < 70400
return 0;
#else
return ret;
#endif
}
#ifdef DIO_NONBLOCK
else {
Expand All @@ -366,23 +349,15 @@ ssize_t dio_common_read(php_dio_stream_data *data, const char *buf, size_t count
ret = select(fd + 1, &rfds, NULL, NULL, &timeouttmp);
/* An error. */
if ((ret < 0) && (errno != EINTR) && (errno != EAGAIN)) {
#if PHP_VERSION_ID < 70400
return 0;
#else
return ret;
#endif
}

/* We have data to read. */
if ((ret > 0) && FD_ISSET(fd, &rfds)) {
ret = read(fd, ptr, count);
/* Another error */
if ((ret < 0) && (errno != EINTR) && (errno != EAGAIN)) {
#if PHP_VERSION_ID < 70400
return 0;
#else
return ret;
#endif
}

if (ret > 0) {
Expand Down
10 changes: 0 additions & 10 deletions src/dio_stream_wrappers.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@
/* {{{ dio_stream_write
* Write to the stream
*/
#if PHP_VERSION_ID < 70400
static size_t dio_stream_write(php_stream *stream, const char *buf, size_t count)
#else
static ssize_t dio_stream_write(php_stream *stream, const char *buf, size_t count)
#endif
{
return dio_common_write((php_dio_stream_data*)stream->abstract, buf, count);
}
Expand All @@ -47,15 +43,9 @@ static ssize_t dio_stream_write(php_stream *stream, const char *buf, size_t coun
/* {{{ dio_stream_read
* Read from the stream
*/
#if PHP_VERSION_ID < 70400
static size_t dio_stream_read(php_stream *stream, char *buf, size_t count)
{
size_t bytes;
#else
static ssize_t dio_stream_read(php_stream *stream, char *buf, size_t count)
{
ssize_t bytes;
#endif
php_dio_stream_data* data = (php_dio_stream_data*)stream->abstract;
bytes = dio_common_read(data, buf, count);
stream->eof = data->end_of_file;
Expand Down
24 changes: 0 additions & 24 deletions src/dio_win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,23 +219,15 @@ php_dio_stream_data * dio_create_stream_data(void) {
/* {{{ dio_common_write
* Writes count chars from the buffer to the stream described by the stream data.
*/
#if PHP_VERSION_ID < 70400
size_t dio_common_write(php_dio_stream_data *data, const char *buf, size_t count) {
#else
ssize_t dio_common_write(php_dio_stream_data *data, const char *buf, size_t count) {
#endif
php_dio_win32_stream_data *wdata = (php_dio_win32_stream_data*)data;
DWORD total = 0;

if (WriteFile(wdata->handle, buf, (DWORD)count, &total, NULL)) {
return (size_t)total;
}

#if PHP_VERSION_ID < 70400
return 0;
#else
return -1;
#endif
}
/* }}} */

Expand Down Expand Up @@ -319,11 +311,7 @@ static size_t dio_buffer_read(php_dio_win32_stream_data *wdata, const char *buf,
/* {{{ dio_com_read
* Read chars from the data port.
*/
#if PHP_VERSION_ID < 70400
static size_t dio_com_read(php_dio_stream_data *data, const char *buf, size_t count) {
#else
static ssize_t dio_com_read(php_dio_stream_data *data, const char *buf, size_t count) {
#endif
php_dio_win32_stream_data *wdata = (php_dio_win32_stream_data*)data;
DWORD err, total = 0;

Expand All @@ -344,22 +332,14 @@ static ssize_t dio_com_read(php_dio_stream_data *data, const char *buf, size_t c
}
}

#if PHP_VERSION_ID < 70400
return 0;
#else
return (data->end_of_file ? 0 : -1);
#endif
}

/* {{{ dio_canonical_read
* Reads chars from the input stream until the internal buffer is full or a new
* line is reached.
*/
#if PHP_VERSION_ID < 70400
static size_t dio_canonical_read(php_dio_win32_stream_data *wdata, const char *buf, size_t count) {
#else
static ssize_t dio_canonical_read(php_dio_win32_stream_data *wdata, const char *buf, size_t count) {
#endif
php_dio_win32_canon_data *canon_data = wdata->canon_data;
size_t total = 0;
char ch;
Expand Down Expand Up @@ -403,11 +383,7 @@ static ssize_t dio_canonical_read(php_dio_win32_stream_data *wdata, const char *
/* {{{ dio_common_read
* Reads count chars to the buffer to the stream described by the stream data.
*/
#if PHP_VERSION_ID < 70400
size_t dio_common_read(php_dio_stream_data *data, const char *buf, size_t count) {
#else
ssize_t dio_common_read(php_dio_stream_data *data, const char *buf, size_t count) {
#endif

/* You ask for no bytes you'll get none :-) */
if (!count) {
Expand Down
6 changes: 0 additions & 6 deletions src/php_dio_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,9 @@ void dio_stream_context_get_basic_options(php_stream_context *context, php_dio_s

void dio_stream_context_get_serial_options(php_stream_context *context, php_dio_stream_data *data);

#if PHP_VERSION_ID < 70400
size_t dio_common_write(php_dio_stream_data *data, const char *buf, size_t count);

size_t dio_common_read(php_dio_stream_data *data, const char *buf, size_t count);
#else
ssize_t dio_common_write(php_dio_stream_data *data, const char *buf, size_t count);

ssize_t dio_common_read(php_dio_stream_data *data, const char *buf, size_t count);
#endif

int dio_common_close(php_dio_stream_data *data);

Expand Down
5 changes: 0 additions & 5 deletions src/php_dio_stream_wrappers.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@
#define DIO_SERIAL_STREAM_NAME "dio.serial"
#define DIO_SERIAL_STREAM_PROTOCOL "dio.serial://"

/* To support PHP 5.4 and later */
#if PHP_VERSION_ID < 50399
#define DIO_SAFE_MODE_CHECK(f, m) (PG(safe_mode) && !php_checkuid(f, m, CHECKUID_CHECK_MODE_PARAM))
#else
#define DIO_SAFE_MODE_CHECK(f, m) (0)
#endif

extern php_stream_wrapper php_dio_raw_stream_wrapper;

Expand Down

0 comments on commit fcc7dec

Please sign in to comment.