Skip to content

Commit 518bfc1

Browse files
committed
Add support for PHP 8/Drop support for PHP 5
1 parent 8460c5b commit 518bfc1

16 files changed

+118
-127
lines changed

.travis.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ language: php
22
sudo: false
33

44
php:
5+
- 8.0
6+
- 7.4
57
- 7.3
68
- 7.2
79
- 7.1
810
- 7.0
9-
- 5.6
10-
- 5.5
11-
- 5.4
1211
- nightly
1312

1413
env:

geospatial.c

Lines changed: 45 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,8 @@ ZEND_BEGIN_ARG_INFO_EX(cartesian_to_polar_args, 0, 0, 4)
122122
ZEND_ARG_INFO(0, reference_ellipsoid)
123123
ZEND_END_ARG_INFO()
124124

125-
ZEND_BEGIN_ARG_INFO_EX(transform_datum_args, 0, 0, 4)
126-
ZEND_ARG_INFO(0, latitude)
127-
ZEND_ARG_INFO(0, longitude)
125+
ZEND_BEGIN_ARG_INFO_EX(transform_datum_args, 0, 0, 3)
126+
ZEND_ARG_INFO(0, GeoJSONPoint)
128127
ZEND_ARG_INFO(0, from_reference_ellipsoid)
129128
ZEND_ARG_INFO(0, to_reference_ellipsoid)
130129
ZEND_END_ARG_INFO()
@@ -156,9 +155,8 @@ ZEND_BEGIN_ARG_INFO_EX(interpolate_polygon_args, 0, 0, 2)
156155
ZEND_ARG_INFO(0, epsilon)
157156
ZEND_END_ARG_INFO()
158157

159-
ZEND_BEGIN_ARG_INFO_EX(geohash_encode_args, 0, 0, 3)
160-
ZEND_ARG_INFO(0, latitude)
161-
ZEND_ARG_INFO(0, longitude)
158+
ZEND_BEGIN_ARG_INFO_EX(geohash_encode_args, 0, 0, 2)
159+
ZEND_ARG_INFO(0, GeoJSONPoint)
162160
ZEND_ARG_INFO(0, precision)
163161
ZEND_END_ARG_INFO()
164162

@@ -275,7 +273,7 @@ void retval_point_from_coordinates(zval *return_value, double lon, double lat)
275273
#endif
276274
}
277275

278-
static int parse_point_pair(zval *coordinates, double *lon, double *lat TSRMLS_DC)
276+
static int parse_point_pair(zval *coordinates, double *lon, double *lat)
279277
{
280278
HashTable *coords;
281279
#if PHP_VERSION_ID >= 70000
@@ -285,7 +283,7 @@ static int parse_point_pair(zval *coordinates, double *lon, double *lat TSRMLS_D
285283
#endif
286284

287285
if (Z_TYPE_P(coordinates) != IS_ARRAY) {
288-
zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "Expected a coordinate pair as an array, but %s given", zend_zval_type_name(coordinates));
286+
zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, "Expected a coordinate pair as an array, but %s given", zend_zval_type_name(coordinates));
289287
return 0;
290288
}
291289

@@ -319,7 +317,7 @@ static int parse_point_pair(zval *coordinates, double *lon, double *lat TSRMLS_D
319317
return 1;
320318
}
321319

322-
int geojson_point_to_lon_lat(zval *point, double *lon, double *lat TSRMLS_DC)
320+
int geojson_point_to_lon_lat(zval *point, double *lon, double *lat)
323321
{
324322
#if PHP_VERSION_ID >= 70000
325323
zval *type, *coordinates;
@@ -336,7 +334,7 @@ int geojson_point_to_lon_lat(zval *point, double *lon, double *lat TSRMLS_DC)
336334
if (Z_TYPE_P(coordinates) != IS_ARRAY) {
337335
return 0;
338336
}
339-
return parse_point_pair(coordinates, lon, lat TSRMLS_CC);
337+
return parse_point_pair(coordinates, lon, lat);
340338
#else
341339
zval **type, **coordinates;
342340

@@ -352,7 +350,7 @@ int geojson_point_to_lon_lat(zval *point, double *lon, double *lat TSRMLS_DC)
352350
if (Z_TYPE_PP(coordinates) != IS_ARRAY) {
353351
return 0;
354352
}
355-
return parse_point_pair(*coordinates, lon, lat TSRMLS_CC);
353+
return parse_point_pair(*coordinates, lon, lat);
356354
#endif
357355
}
358356

@@ -398,7 +396,7 @@ double php_geo_vincenty(double from_lat, double from_long, double to_lat, double
398396
double cosof2sigma, A, B, C, uSq, deltaSigma, s;
399397
int loopLimit = 100;
400398
double precision = 0.000000000001;
401-
399+
402400
U1 = atan((1.0 - eli.f) * tan(from_lat));
403401
U2 = atan((1.0 - eli.f) * tan(to_lat));
404402
L = to_long - from_long;
@@ -410,7 +408,7 @@ double php_geo_vincenty(double from_lat, double from_long, double to_lat, double
410408
do {
411409
sinLambda = sin(lambda);
412410
cosLambda = cos(lambda);
413-
sinSigma = sqrt((cosU2*sinLambda) * (cosU2*sinLambda) +
411+
sinSigma = sqrt((cosU2*sinLambda) * (cosU2*sinLambda) +
414412
(cosU1 * sinU2 - sinU1 * cosU2 * cosLambda) * (cosU1 * sinU2 - sinU1 * cosU2 * cosLambda));
415413
cosSigma = sinU1 * sinU2 + cosU1 * cosU2 * cosLambda;
416414
sigma = atan2(sinSigma, cosSigma);
@@ -530,7 +528,7 @@ PHP_FUNCTION(dms_to_decimal)
530528
int direction_len;
531529
#endif
532530

533-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ddd|s", &degrees, &minutes, &seconds, &direction, &direction_len) == FAILURE) {
531+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ddd|s", &degrees, &minutes, &seconds, &direction, &direction_len) == FAILURE) {
534532
return;
535533
}
536534

@@ -560,7 +558,7 @@ PHP_FUNCTION(decimal_to_dms)
560558
int coordinate_len;
561559
#endif
562560

563-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ds", &decimal, &coordinate, &coordinate_len) == FAILURE) {
561+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ds", &decimal, &coordinate, &coordinate_len) == FAILURE) {
564562
return;
565563
}
566564

@@ -591,7 +589,7 @@ PHP_FUNCTION(helmert)
591589
long from_reference_ellipsoid = 0, to_reference_ellipsoid = 0;
592590
geo_helmert_constants helmert_constants;
593591

594-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ddd|ll", &x, &y, &z, &from_reference_ellipsoid, &to_reference_ellipsoid) == FAILURE) {
592+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ddd|ll", &x, &y, &z, &from_reference_ellipsoid, &to_reference_ellipsoid) == FAILURE) {
595593
return;
596594
}
597595

@@ -612,7 +610,7 @@ PHP_FUNCTION(polar_to_cartesian)
612610
long reference_ellipsoid;
613611
geo_cartesian point;
614612

615-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "dd|l", &latitude, &longitude, &reference_ellipsoid) == FAILURE) {
613+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "dd|l", &latitude, &longitude, &reference_ellipsoid) == FAILURE) {
616614
return;
617615
}
618616

@@ -633,7 +631,7 @@ PHP_FUNCTION(cartesian_to_polar)
633631
long reference_ellipsoid;
634632
geo_lat_long polar;
635633

636-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ddd|l", &x, &y, &z, &reference_ellipsoid) == FAILURE) {
634+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ddd|l", &x, &y, &z, &reference_ellipsoid) == FAILURE) {
637635
return;
638636
}
639637

@@ -658,11 +656,11 @@ PHP_FUNCTION(transform_datum)
658656
geo_lat_long polar;
659657
geo_helmert_constants helmert_constants;
660658

661-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "all", &geojson, &from_reference_ellipsoid, &to_reference_ellipsoid) == FAILURE) {
659+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "all", &geojson, &from_reference_ellipsoid, &to_reference_ellipsoid) == FAILURE) {
662660
return;
663661
}
664662

665-
if (!geojson_point_to_lon_lat(geojson, &longitude, &latitude TSRMLS_CC)) {
663+
if (!geojson_point_to_lon_lat(geojson, &longitude, &latitude)) {
666664
RETURN_FALSE;
667665
}
668666

@@ -690,12 +688,12 @@ PHP_FUNCTION(haversine)
690688
zval *from_geojson, *to_geojson;
691689
double from_lat, from_long, to_lat, to_long;
692690

693-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "aa|d", &from_geojson, &to_geojson, &radius) == FAILURE) {
691+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "aa|d", &from_geojson, &to_geojson, &radius) == FAILURE) {
694692
return;
695693
}
696694

697-
geojson_point_to_lon_lat(from_geojson, &from_long, &from_lat TSRMLS_CC);
698-
geojson_point_to_lon_lat(to_geojson, &to_long, &to_lat TSRMLS_CC);
695+
geojson_point_to_lon_lat(from_geojson, &from_long, &from_lat);
696+
geojson_point_to_lon_lat(to_geojson, &to_long, &to_lat);
699697

700698
RETURN_DOUBLE(php_geo_haversine(from_lat * GEO_DEG_TO_RAD, from_long * GEO_DEG_TO_RAD, to_lat * GEO_DEG_TO_RAD, to_long * GEO_DEG_TO_RAD) * radius);
701699
}
@@ -709,12 +707,12 @@ PHP_FUNCTION(vincenty)
709707
double from_lat, from_long, to_lat, to_long;
710708
long reference_ellipsoid = GEO_WGS84;
711709

712-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "aa|l", &from_geojson, &to_geojson, &reference_ellipsoid) == FAILURE) {
710+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "aa|l", &from_geojson, &to_geojson, &reference_ellipsoid) == FAILURE) {
713711
return;
714712
}
715713

716-
geojson_point_to_lon_lat(from_geojson, &from_long, &from_lat TSRMLS_CC);
717-
geojson_point_to_lon_lat(to_geojson, &to_long, &to_lat TSRMLS_CC);
714+
geojson_point_to_lon_lat(from_geojson, &from_long, &from_lat);
715+
geojson_point_to_lon_lat(to_geojson, &to_long, &to_lat);
718716

719717
geo_ellipsoid eli = get_ellipsoid(reference_ellipsoid);
720718
RETURN_DOUBLE(php_geo_vincenty(from_lat * GEO_DEG_TO_RAD, from_long * GEO_DEG_TO_RAD, to_lat * GEO_DEG_TO_RAD, to_long * GEO_DEG_TO_RAD, eli));
@@ -747,12 +745,12 @@ PHP_FUNCTION(fraction_along_gc_line)
747745
double from_lat, from_long, to_lat, to_long, fraction;
748746
double res_lat, res_long;
749747

750-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "aad", &from_geojson, &to_geojson, &fraction) == FAILURE) {
748+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "aad", &from_geojson, &to_geojson, &fraction) == FAILURE) {
751749
return;
752750
}
753751

754-
geojson_point_to_lon_lat(from_geojson, &from_long, &from_lat TSRMLS_CC);
755-
geojson_point_to_lon_lat(to_geojson, &to_long, &to_lat TSRMLS_CC);
752+
geojson_point_to_lon_lat(from_geojson, &from_long, &from_lat);
753+
geojson_point_to_lon_lat(to_geojson, &to_long, &to_lat);
756754

757755
php_geo_fraction_along_gc_line(
758756
from_lat * GEO_DEG_TO_RAD,
@@ -795,12 +793,12 @@ PHP_FUNCTION(initial_bearing)
795793
zval *from_geojson, *to_geojson;
796794
double from_lat, from_long, to_lat, to_long, bearing;
797795

798-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "aa", &from_geojson, &to_geojson) == FAILURE) {
796+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "aa", &from_geojson, &to_geojson) == FAILURE) {
799797
return;
800798
}
801799

802-
geojson_point_to_lon_lat(from_geojson, &from_long, &from_lat TSRMLS_CC);
803-
geojson_point_to_lon_lat(to_geojson, &to_long, &to_lat TSRMLS_CC);
800+
geojson_point_to_lon_lat(from_geojson, &from_long, &from_lat);
801+
geojson_point_to_lon_lat(to_geojson, &to_long, &to_lat);
804802

805803
bearing = php_initial_bearing(
806804
from_lat * GEO_DEG_TO_RAD,
@@ -813,7 +811,7 @@ PHP_FUNCTION(initial_bearing)
813811
}
814812
/* }}} */
815813

816-
geo_array *geo_hashtable_to_array(zval *array TSRMLS_DC)
814+
geo_array *geo_hashtable_to_array(zval *array)
817815
{
818816
geo_array *tmp;
819817
int element_count;
@@ -832,12 +830,12 @@ geo_array *geo_hashtable_to_array(zval *array TSRMLS_DC)
832830
#if PHP_VERSION_ID >= 70000
833831
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(array), entry) {
834832

835-
if (!parse_point_pair(entry, &lon, &lat TSRMLS_CC)) {
833+
if (!parse_point_pair(entry, &lon, &lat)) {
836834
#else
837835
zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(array), &pos);
838836
while (zend_hash_get_current_data_ex(Z_ARRVAL_P(array), (void **)&entry, &pos) == SUCCESS) {
839837

840-
if (!parse_point_pair(*entry, &lon, &lat TSRMLS_CC)) {
838+
if (!parse_point_pair(*entry, &lon, &lat)) {
841839
#endif
842840

843841
goto failure;
@@ -862,7 +860,7 @@ geo_array *geo_hashtable_to_array(zval *array TSRMLS_DC)
862860
return NULL;
863861
}
864862

865-
int geojson_linestring_to_array(zval *line, geo_array **array TSRMLS_DC)
863+
int geojson_linestring_to_array(zval *line, geo_array **array)
866864
{
867865
geo_array *tmp;
868866
#if PHP_VERSION_ID >= 70000
@@ -885,7 +883,7 @@ int geojson_linestring_to_array(zval *line, geo_array **array TSRMLS_DC)
885883
return 0;
886884
}
887885

888-
tmp = geo_hashtable_to_array(coordinates TSRMLS_CC);
886+
tmp = geo_hashtable_to_array(coordinates);
889887
#else
890888
zval **type, **coordinates;
891889

@@ -906,7 +904,7 @@ int geojson_linestring_to_array(zval *line, geo_array **array TSRMLS_DC)
906904
return 0;
907905
}
908906

909-
tmp = geo_hashtable_to_array(*coordinates TSRMLS_CC);
907+
tmp = geo_hashtable_to_array(*coordinates);
910908
#endif
911909
if (tmp && array) {
912910
*array = tmp;
@@ -980,7 +978,7 @@ PHP_FUNCTION(rdp_simplify)
980978
int i;
981979
zval *pair;
982980

983-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zd", &points_array, &epsilon) == FAILURE) {
981+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "zd", &points_array, &epsilon) == FAILURE) {
984982
return;
985983
}
986984

@@ -990,7 +988,7 @@ PHP_FUNCTION(rdp_simplify)
990988

991989
array_init(return_value);
992990

993-
points = geo_hashtable_to_array(points_array TSRMLS_CC);
991+
points = geo_hashtable_to_array(points_array);
994992
if (!points) {
995993
return;
996994
}
@@ -1057,11 +1055,11 @@ PHP_FUNCTION(interpolate_linestring)
10571055
zval *pair;
10581056
geo_array *new_array;
10591057

1060-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zd", &line, &epsilon) == FAILURE) {
1058+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "zd", &line, &epsilon) == FAILURE) {
10611059
return;
10621060
}
10631061

1064-
if (!geojson_linestring_to_array(line, &points TSRMLS_CC)) {
1062+
if (!geojson_linestring_to_array(line, &points)) {
10651063
RETURN_FALSE;
10661064
}
10671065

@@ -1097,15 +1095,15 @@ PHP_FUNCTION(interpolate_polygon)
10971095
int i;
10981096
zval *pair;
10991097

1100-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zd", &polygon, &epsilon) == FAILURE) {
1098+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "zd", &polygon, &epsilon) == FAILURE) {
11011099
return;
11021100
}
11031101

11041102
if (Z_TYPE_P(polygon) != IS_ARRAY) {
11051103
return;
11061104
}
11071105

1108-
if (!geojson_linestring_to_array(polygon, &points TSRMLS_CC)) {
1106+
if (!geojson_linestring_to_array(polygon, &points)) {
11091107
RETURN_FALSE;
11101108
}
11111109

@@ -1144,11 +1142,11 @@ PHP_FUNCTION(geohash_encode)
11441142
zval *geojson;
11451143
char *hash;
11461144

1147-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "al", &geojson, &precision) == FAILURE) {
1145+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "al", &geojson, &precision) == FAILURE) {
11481146
return;
11491147
}
11501148

1151-
if (!geojson_point_to_lon_lat(geojson, &longitude, &latitude TSRMLS_CC)) {
1149+
if (!geojson_point_to_lon_lat(geojson, &longitude, &latitude)) {
11521150
RETURN_FALSE;
11531151
}
11541152

@@ -1172,7 +1170,7 @@ PHP_FUNCTION(geohash_decode)
11721170
int hash_len;
11731171
#endif
11741172

1175-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &hash, &hash_len) == FAILURE) {
1173+
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &hash, &hash_len) == FAILURE) {
11761174
return;
11771175
}
11781176

package.xml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,20 @@
2727
<active>yes</active>
2828
</lead>
2929

30-
<date>2019-01-08</date>
31-
<time>11:35:54</time>
30+
<date>2021-01-28</date>
31+
<time>11:46:58</time>
3232
<version>
33-
<release>0.2.1</release>
34-
<api>0.2.1</api>
33+
<release>0.3.0</release>
34+
<api>0.3.0</api>
3535
</version>
3636
<stability>
3737
<release>beta</release>
3838
<api>beta</api>
3939
</stability>
4040
<license uri="http://www.php.net/license">PHP 3.01</license>
4141
<notes>
42-
- Fixed issue #22: Compile failure with PHP 5.6 on Windows using VC11
43-
- Fixed issue #26: Initial Bearing Calculation Error
44-
- Fix possible integer overflow in memory allocation with negative precision in
45-
geohash_encode (Emir Beganovic)
42+
- Added support for PHP 8
43+
- Drop support for PHP 5
4644
</notes>
4745

4846
<contents>
@@ -62,7 +60,7 @@
6260
<dependencies>
6361
<required>
6462
<php>
65-
<min>5.4.0</min>
63+
<min>7.0.0</min>
6664
</php>
6765
<pearinstaller>
6866
<min>1.4.0b1</min>

php_geospatial.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#ifndef PHP_GEOSPATIAL_H
2323
#define PHP_GEOSPATIAL_H
2424

25-
#define PHP_GEOSPATIAL_VERSION "0.2.2-dev"
25+
#define PHP_GEOSPATIAL_VERSION "0.3.0-dev"
2626

2727
extern zend_module_entry geospatial_module_entry;
2828
#define phpext_geospatial_ptr &geospatial_module_entry

0 commit comments

Comments
 (0)