Skip to content
This repository was archived by the owner on Jul 7, 2018. It is now read-only.

Commit 61c5a4c

Browse files
committed
Drop PHP < 7.2 support
1 parent ca5ddbb commit 61c5a4c

18 files changed

+597
-75
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ dist: trusty
44
language: php
55

66
php:
7-
- 7.1
7+
- 7.2
88
- nightly
99

1010
matrix:

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 3.1)
2-
project(php_ref)
2+
project(php-ref)
33

44
# NOTE: This CMake file is just for syntax highlighting in CLion
55

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This extension adds [Soft Reference](https://en.wikipedia.org/wiki/Soft_referenc
99
data structures that require advanced referencing model.
1010

1111

12-
**PHP >= 7.1 required**
12+
**PHP >= 7.2 required.** The last version that supports PHP 7.1 is `v0.5.0`.
1313

1414
### PLEASE READ:
1515

@@ -162,15 +162,15 @@ to add it to your project.
162162
$ sudo add-apt-repository -y ppa:ondrej/php
163163
$ sudo add-apt-repository -y ppa:pinepain/php
164164
$ sudo apt-get update -y
165-
$ sudo apt-get install -y php7.1 php-ref
165+
$ sudo apt-get install -y php7.2 php-ref
166166
$ php --ri ref
167167

168168
#### OS X (homebrew)
169169

170170
$ brew tap homebrew/devtoo
171171
$ brew tap homebrew/php
172172
$ brew tap pinepain/devtools
173-
$ brew install php71 php71-ref
173+
$ brew install php72 php72-ref
174174
$ php --ri ref
175175

176176
### Windows
@@ -189,12 +189,12 @@ To install extension globally run
189189

190190
# sudo make install
191191

192-
You will need to copy the extension config to your php dir, here is example for Ubuntu with PHP 7.1 from
192+
You will need to copy the extension config to your php dir, here is example for Ubuntu with PHP 7.2 from
193193
[Ondřej Surý's PPA for PHP](https://launchpad.net/~ondrej/+archive/ubuntu/php):
194194

195195
# sudo cp provision/php/ref.ini /etc/php/mods-available/
196196
# sudo phpenmod -v ALL ref
197-
# sudo service php7.1-fpm restart
197+
# sudo service php7.2-fpm restart
198198

199199
You may also want to add php-ref extension as a [composer.json dependency](https://getcomposer.org/doc/02-libraries.md#platform-packages):
200200

config.m4

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ if test "$PHP_REF" != "no"; then
1111
PHP_REF_FOUND_VERSION=`${PHP_CONFIG} --version`
1212
PHP_REF_FOUND_VERNUM=`${PHP_CONFIG} --vernum`
1313

14-
if test "$PHP_REF_FOUND_VERNUM" -lt "70100"; then
15-
AC_MSG_ERROR([not supported. PHP version >= 7.1 required (found $PHP_REF_FOUND_VERSION)])
14+
if test "$PHP_REF_FOUND_VERNUM" -lt "70200"; then
15+
AC_MSG_ERROR([not supported. PHP version >= 7.2 required (found $PHP_REF_FOUND_VERSION)])
1616
else
1717
AC_MSG_RESULT([supported ($PHP_REF_FOUND_VERSION)])
1818
fi

package.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@
155155
<dependencies>
156156
<required>
157157
<php>
158-
<min>7.1.0</min>
158+
<min>7.2.0</min>
159159
</php>
160160
<pearinstaller>
161161
<min>1.4.0</min>

php_ref.h

+2-18
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ extern zend_module_entry php_ref_module_entry;
2626
#define PHP_REF_REVISION "dev"
2727
#endif
2828

29-
#if PHP_VERSION_ID < 70100
29+
#if PHP_VERSION_ID < 70200
3030
// should never get her, but just in case
31-
#error PHP >= 7.1 required
31+
#error PHP >= 7.2 required
3232
#endif
3333

3434
#define PHP_REF_NS "Ref"
@@ -42,22 +42,6 @@ extern zend_module_entry php_ref_module_entry;
4242
#endif
4343

4444

45-
// Add zend_type support (new since PHP 7.2)
46-
#ifdef ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX
47-
#define PHP_REF_ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(name, return_reference, required_num_args, classname, allow_null) \
48-
ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(name, return_reference, required_num_args, classname, allow_null)
49-
50-
#define PHP_REF_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, type, allow_null) \
51-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, type, allow_null)
52-
#else
53-
#define PHP_REF_ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(name, return_reference, required_num_args, classname, allow_null) \
54-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, IS_OBJECT, #classname, allow_null)
55-
56-
#define PHP_REF_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, type, allow_null) \
57-
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, type, NULL, allow_null)
58-
#endif
59-
60-
6145
#ifdef ZTS
6246
#include "TSRM.h"
6347
#endif

php_ref_functions.c

+19-19
Original file line numberDiff line numberDiff line change
@@ -208,44 +208,44 @@ PHP_FUNCTION(is_obj_destructor_called)
208208
}
209209

210210

211-
PHP_REF_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(refcounted_arg, ZEND_RETURN_VALUE, 1, _IS_BOOL, 0)
211+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(refcounted_arg, ZEND_RETURN_VALUE, 1, _IS_BOOL, 0)
212212
ZEND_ARG_INFO(0, value)
213213
ZEND_END_ARG_INFO()
214214

215-
PHP_REF_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(refcount_arg, ZEND_RETURN_VALUE, 1, IS_LONG, 0)
216-
ZEND_ARG_INFO(0, value)
215+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(refcount_arg, ZEND_RETURN_VALUE, 1, IS_LONG, 0)
216+
ZEND_ARG_TYPE_INFO(0, object, IS_OBJECT, 0)
217217
ZEND_END_ARG_INFO()
218218

219-
PHP_REF_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(softrefcounted_arg, ZEND_RETURN_VALUE, 1, _IS_BOOL, 0)
220-
ZEND_ARG_INFO(0, object)
219+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(softrefcounted_arg, ZEND_RETURN_VALUE, 1, _IS_BOOL, 0)
220+
ZEND_ARG_TYPE_INFO(0, object, IS_OBJECT, 0)
221221
ZEND_END_ARG_INFO()
222222

223-
PHP_REF_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(softrefcount_arg, ZEND_RETURN_VALUE, 1, IS_LONG, 0)
224-
ZEND_ARG_INFO(0, object)
223+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(softrefcount_arg, ZEND_RETURN_VALUE, 1, IS_LONG, 0)
224+
ZEND_ARG_TYPE_INFO(0, object, IS_OBJECT, 0)
225225
ZEND_END_ARG_INFO()
226226

227-
PHP_REF_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(softrefs_arg, ZEND_RETURN_VALUE, 1, IS_ARRAY, 0)
228-
ZEND_ARG_INFO(0, object)
227+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(softrefs_arg, ZEND_RETURN_VALUE, 1, IS_ARRAY, 0)
228+
ZEND_ARG_TYPE_INFO(0, object, IS_OBJECT, 0)
229229
ZEND_END_ARG_INFO()
230230

231-
PHP_REF_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(weakrefcounted_arg, ZEND_RETURN_VALUE, 1, _IS_BOOL, 0)
232-
ZEND_ARG_INFO(0, object)
231+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(weakrefcounted_arg, ZEND_RETURN_VALUE, 1, _IS_BOOL, 0)
232+
ZEND_ARG_TYPE_INFO(0, object, IS_OBJECT, 0)
233233
ZEND_END_ARG_INFO()
234234

235-
PHP_REF_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(weakrefcount_arg, ZEND_RETURN_VALUE, 1, IS_LONG, 0)
236-
ZEND_ARG_INFO(0, object)
235+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(weakrefcount_arg, ZEND_RETURN_VALUE, 1, IS_LONG, 0)
236+
ZEND_ARG_TYPE_INFO(0, object, IS_OBJECT, 0)
237237
ZEND_END_ARG_INFO()
238238

239-
PHP_REF_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(weakrefs_arg, ZEND_RETURN_VALUE, 1, IS_ARRAY, 0)
240-
ZEND_ARG_INFO(0, object)
239+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(weakrefs_arg, ZEND_RETURN_VALUE, 1, IS_ARRAY, 0)
240+
ZEND_ARG_TYPE_INFO(0, object, IS_OBJECT, 0)
241241
ZEND_END_ARG_INFO()
242242

243-
PHP_REF_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(object_handle_arg, ZEND_RETURN_VALUE, 1, IS_LONG, 0)
244-
ZEND_ARG_INFO(0, object)
243+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(object_handle_arg, ZEND_RETURN_VALUE, 1, IS_LONG, 0)
244+
ZEND_ARG_TYPE_INFO(0, object, IS_OBJECT, 0)
245245
ZEND_END_ARG_INFO()
246246

247-
PHP_REF_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(is_obj_destructor_called_arg, ZEND_RETURN_VALUE, 1, _IS_BOOL, 0)
248-
ZEND_ARG_INFO(0, object)
247+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(is_obj_destructor_called_arg, ZEND_RETURN_VALUE, 1, _IS_BOOL, 0)
248+
ZEND_ARG_TYPE_INFO(0, object, IS_OBJECT, 0)
249249
ZEND_END_ARG_INFO()
250250

251251
const zend_function_entry php_ref_functions[] = {

php_ref_reference.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -585,17 +585,17 @@ static PHP_METHOD(WeakReference, notifier)
585585

586586

587587
ZEND_BEGIN_ARG_INFO_EX(arginfo_ref_reference___construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
588-
ZEND_ARG_INFO(0, referent)
588+
ZEND_ARG_TYPE_INFO(0, referent, IS_OBJECT, 0)
589589
ZEND_ARG_CALLABLE_INFO(0, notify, 1)
590590
ZEND_END_ARG_INFO()
591591

592592
ZEND_BEGIN_ARG_INFO_EX(arginfo_ref_reference_get, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
593593
ZEND_END_ARG_INFO()
594594

595-
PHP_REF_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ref_reference_valid, ZEND_RETURN_VALUE, 0, _IS_BOOL, 0)
595+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ref_reference_valid, ZEND_RETURN_VALUE, 0, _IS_BOOL, 0)
596596
ZEND_END_ARG_INFO()
597597

598-
PHP_REF_ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ref_reference_notifier, ZEND_SEND_BY_VAL, 0, IS_CALLABLE, 1)
598+
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_ref_reference_notifier, ZEND_SEND_BY_VAL, 0, IS_CALLABLE, 1)
599599
ZEND_ARG_CALLABLE_INFO(0, notify, 1)
600600
ZEND_END_ARG_INFO()
601601

provision/provision.sh

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ sudo apt-get -y autoremove
77
# Make sure these tools installed
88
sudo DEBIAN_FRONTEND=noninteractive apt-get install -y git htop curl tshark pkgconf
99
# Add PPA with fresh PHP 7:
10-
sudo add-apt-repository -u -y ppa:ondrej/php-7.0
10+
sudo add-apt-repository -u -y ppa:ondrej/php
1111

1212
# Install available php from packages
13-
sudo apt-get install -y php7.0 php7.0-dev php7.0-fpm
13+
sudo apt-get install -y php7.2 php7.2-dev php7.2-fpm
1414

1515
# Configure php-fpm
16-
sudo cp ~/php-ref/provision/php/www.conf /etc/php/7.0/fpm/pool.d/www.conf
17-
sudo service php7.0-fpm restart
16+
sudo cp ~/php-ref/provision/php/www.conf /etc/php/7.2/fpm/pool.d/www.conf
17+
sudo service php7.2-fpm restart
1818

1919
# Fix php executable detection with PHP7 (https://github.com/oerdnj/deb.sury.org/issues/142)
2020
sudo sed -i -e 's/^php_cli_binary=NONE$/php_cli_binary="\/usr\/bin\/php"/g' /usr/bin/php-config
@@ -79,7 +79,7 @@ sudo cp -f /usr/share/nginx/html/index.html /var/www/html/index-nginx.html
7979
#phpize --clean && phpize && ./configure && sudo make install
8080
#sudo cp ~/php-ref/provision/php/ref.ini /etc/php/mods-available/
8181
#sudo phpenmod -v ALL ref
82-
#sudo service php7.0-fpm restart
82+
#sudo service php7.2-fpm restart
8383

8484
# For debugging segfault when extension fails in php-fpm mode:
8585
#sudo sh -c "echo '/home/vagrant/php-ref/coredump-%e.%p' > /proc/sys/kernel/core_pattern"
@@ -91,7 +91,7 @@ sudo cp -f /usr/share/nginx/html/index.html /var/www/html/index-nginx.html
9191
sudo apt-get autoremove -y
9292

9393
# This is for the future
94-
# At this point it is good idea to do `phpbrew install 7.1` (or other version you want to test extension with)
94+
# At this point it is good idea to do `phpbrew install 7.2` (or other version you want to test extension with)
9595
# and `phpbrew ext install ~/php-ref/`
9696

9797
date > /home/vagrant/vagrant_provisioned_at

scripts/refresh-package-xml.php

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/usr/bin/env php
2-
<?php
2+
<?php declare(strict_types=1);
33

4-
/*
4+
/**
55
* This file is part of the pinepain/php-ref PHP extension.
66
*
7-
* Copyright (c) 2016-2017 Bogdan Padalko <[email protected]>
7+
* Copyright (c) 2015-2018 Bogdan Padalko <[email protected]>
88
*
99
* Licensed under the MIT license: http://opensource.org/licenses/MIT
1010
*
@@ -13,6 +13,7 @@
1313
* http://opensource.org/licenses/MIT
1414
*/
1515

16+
1617
chdir(__DIR__ . DIRECTORY_SEPARATOR . '..');
1718

1819
$contents = [
@@ -39,6 +40,7 @@
3940
],
4041
];
4142

43+
4244
$files = [];
4345

4446
$files[] = '<!-- begin files list -->';
@@ -103,6 +105,10 @@
103105
$package = preg_replace("/\<date\>.+\<\/date\>/", '<date>' . $datetime->format('Y-m-d') . '</date>', $package);
104106
$package = preg_replace("/\<time\>.+\<\/time\>/", '<time>' . $datetime->format('H:i:s') . '</time>', $package);
105107

108+
$new_package_filename = 'package-new.xml';
109+
if (isset($argv[1]) && '-f' == $argv[1]) {
110+
$new_package_filename = 'package.xml';
111+
}
106112

107113
// Replace version:
108114

@@ -117,9 +123,4 @@
117123
$package = preg_replace("/\<api\>\d+\.\d+.\d+\<\/api\>/", '<api>' . $version . '</api>', $package);
118124

119125

120-
$new_package_filename = 'package-new.xml';
121-
if (isset($argv[1]) && '-f' == $argv[1]) {
122-
$new_package_filename = 'package.xml';
123-
}
124-
125126
file_put_contents($new_package_filename, $package);

scripts/replace_expect.php

+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
#!/usr/bin/env php
2+
<?php declare(strict_types=1);
3+
/**
4+
* This file is part of the pinepain/php-ref PHP extension.
5+
*
6+
* Copyright (c) 2015-2018 Bogdan Padalko <[email protected]>
7+
*
8+
* Licensed under the MIT license: http://opensource.org/licenses/MIT
9+
*
10+
* For the full copyright and license information, please view the
11+
* LICENSE file that was distributed with this source or visit
12+
* http://opensource.org/licenses/MIT
13+
*/
14+
15+
$tests_dir = realpath(__DIR__ . '/../tests');
16+
17+
18+
$mode = 'write';
19+
20+
$args = $argv;
21+
unset($args[0]);
22+
23+
foreach ($argv as $i => $item) {
24+
if ($item == '--pretend') {
25+
$mode = 'pretend';
26+
unset($args[$i]);
27+
}
28+
}
29+
30+
if (count($args) > 1) {
31+
echo 'Invalid options', PHP_EOL;
32+
exit(1);
33+
}
34+
35+
if ($args) {
36+
$mask = str_replace(['tests/', '.phpt', '.diff'], '', array_pop($args));
37+
} else {
38+
$mask = '*';
39+
}
40+
41+
$iterator = new GlobIterator($tests_dir . "/{$mask}.out", FilesystemIterator::KEY_AS_FILENAME);
42+
43+
foreach ($iterator as $item) {
44+
//var_dump($item);
45+
$out_file = $iterator->key();
46+
$base_name = preg_replace('/\.out$/i', '', $iterator->key());
47+
$test_file = $base_name . '.phpt';
48+
49+
$test_content = file_get_contents($tests_dir . '/' . $test_file);
50+
51+
if (false !== ($pos = strpos($test_content, '--EXPECT--'))) {
52+
printf("--EXPECT-- [%s]" . PHP_EOL, $iterator->key());
53+
54+
$test_content = substr($test_content, 0, $pos);
55+
$test_content .= '--EXPECT--' . PHP_EOL;
56+
$test_content .= file_get_contents($tests_dir . '/' . $out_file);
57+
$test_content .= PHP_EOL;
58+
file_put_contents($tests_dir . '/' . $test_file, $test_content);
59+
60+
foreach (['.diff', '.exp', '.log', '.mem', '.out', '.php', '.sh'] as $ext) {
61+
@unlink($tests_dir . '/' . $base_name . $ext);
62+
}
63+
64+
continue;
65+
//} elseif (0) {
66+
} elseif (false !== ($pos = strpos($test_content, '--EXPECTF--'))) {
67+
68+
printf("--EXPECTF-- [%s]" . PHP_EOL, $iterator->key());
69+
70+
// get replacements
71+
72+
$tests = substr($test_content, 0, $pos);
73+
$result = file_get_contents($tests_dir . '/' . $out_file);
74+
75+
preg_match_all('#// EXPECTF: \-\-\-(.+)#', $tests, $expectf_search);
76+
preg_match_all('#// EXPECTF: \+\+\+(.+)#', $tests, $expectf_replace);
77+
78+
if (count($expectf_search) != count($expectf_replace)) {
79+
printf("please, edit manually [%s]: searches and replaces count doesn't match" . PHP_EOL, $iterator->key());
80+
continue;
81+
}
82+
83+
foreach (array_combine($expectf_search[1], $expectf_replace[1]) as $search => $replace) {
84+
$replace = str_replace('\\\\n', '!!(ಠ_ಠ)!!', $replace);
85+
$replace = str_replace('\\n', "\n", $replace);
86+
$replace = str_replace('!!(ಠ_ಠ)!!', '\\\\n', $replace);
87+
88+
$result = preg_replace($search, $replace, $result);
89+
}
90+
91+
$test_content = $tests;
92+
$test_content .= '--EXPECTF--' . PHP_EOL;
93+
$test_content .= $result;
94+
$test_content .= PHP_EOL;
95+
96+
if ($mode == 'pretend') {
97+
echo $result, PHP_EOL;
98+
echo PHP_EOL;
99+
100+
} elseif ($mode = 'write') {
101+
file_put_contents($tests_dir . '/' . $test_file, $test_content);
102+
103+
foreach (['.diff', '.exp', '.log', '.mem', '.out', '.php', '.sh'] as $ext) {
104+
@unlink($tests_dir . '/' . $base_name . $ext);
105+
}
106+
}
107+
108+
continue;
109+
}
110+
111+
printf("please, edit manually [%s]" . PHP_EOL, $iterator->key());
112+
}

0 commit comments

Comments
 (0)