Skip to content

Commit

Permalink
Fix PHP8 build (#284)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrekelmans committed Aug 6, 2021
1 parent df77f2d commit 56ab933
Show file tree
Hide file tree
Showing 109 changed files with 2,695 additions and 1,699 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/auto-regenerate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
uses: "shivammathur/setup-php@v2"
with:
coverage: "pcov"
php-version: "7.4"
php-version: "8.0"

- name: "Check out salathe/phpdoc-base"
uses: "actions/checkout@v2"
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ jobs:
strategy:
matrix:
php-version:
- "7.2"
- "7.3"
- "7.4"
- "8.0"

dependencies:
- "highest"
Expand Down
12 changes: 5 additions & 7 deletions .github/workflows/rector-continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@ on:
jobs:

rector-continuous-integration:
name: "Check if refactoring can be done with rector/rector:~0.7.0"
name: "Check if refactoring can be done with rector/rector"

runs-on: "ubuntu-latest"

strategy:
matrix:
php-version:
- "7.2"
- "7.3"
- "7.4"
- "8.0"

dependencies:
- "highest"
Expand All @@ -34,13 +32,13 @@ jobs:

- name: "Composer install"
run: "composer install && composer rector && composer test"
working-directory: "generator/tests/rector/0.7"
working-directory: "generator/tests/rector"

- name: "Run rector"
run: "composer rector"
working-directory: "generator/tests/rector/0.7"
working-directory: "generator/tests/rector"

- name: "Run tests"
run: "composer test"
working-directory: "generator/tests/rector/0.7"
working-directory: "generator/tests/rector"

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
/generator/doc/entities/generated.ent
/composer.lock
vendor/
/generator/tests/rector/0.7/composer.lock
/generator/tests/rector/composer.lock
.phpunit.result.cache
68 changes: 0 additions & 68 deletions .travis.yml.old

This file was deleted.

19 changes: 2 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,6 @@
Safe PHP
========

# This project is deprecated



Because of how this project needs to be in sync with the official PHP documentation, maintaining a set of functions for PHP 7 is simply too difficult, which means we have to drop support for versions below PHP 8.

On the other hand, because this project is used in other libraries, I cannot actually change the PHP dependency in composer.json to ^8.0 without risking some huge versions conflicts.

So the only solution I see is to create a new project: [Safe8](https://github.com/thecodingmachine/safe8/).

The old safe library will stay on Packagist, but it won't be updated anymore.


**Work in progress**

A set of core PHP functions rewritten to throw exceptions instead of returning `false` when an error is encountered.

## The problem
Expand Down Expand Up @@ -128,15 +113,15 @@ tool that performs instant refactoring of your application.
Run

```bash
$ composer require --dev rector/rector:^0.7
$ composer require --dev rector/rector
```

to install `rector/rector`.

Run

```bash
vendor/bin/rector process src/ --config vendor/thecodingmachine/safe/rector-migrate-0.7.php
vendor/bin/rector process src/ --config vendor/thecodingmachine/safe/rector-migrate.php
```

to run `rector/rector`.
Expand Down
9 changes: 4 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"generated/curl.php",
"generated/datetime.php",
"generated/dir.php",
"generated/dom.php",
"generated/eio.php",
"generated/errorfunc.php",
"generated/exec.php",
Expand All @@ -36,6 +37,7 @@
"generated/fpm.php",
"generated/ftp.php",
"generated/funchand.php",
"generated/gettext.php",
"generated/gmp.php",
"generated/gnupg.php",
"generated/hash.php",
Expand All @@ -45,7 +47,6 @@
"generated/image.php",
"generated/imap.php",
"generated/info.php",
"generated/ingres-ii.php",
"generated/inotify.php",
"generated/json.php",
"generated/ldap.php",
Expand All @@ -56,8 +57,6 @@
"generated/misc.php",
"generated/mysql.php",
"generated/mysqli.php",
"generated/mysqlndMs.php",
"generated/mysqlndQc.php",
"generated/network.php",
"generated/oci8.php",
"generated/opcache.php",
Expand All @@ -76,8 +75,8 @@
"generated/sem.php",
"generated/session.php",
"generated/shmop.php",
"generated/simplexml.php",
"generated/sockets.php",
"generated/sodium.php",
"generated/solr.php",
"generated/spl.php",
"generated/sqlsrv.php",
Expand All @@ -100,7 +99,7 @@
]
},
"require": {
"php": ">=7.2"
"php": "^8.0"
},
"require-dev": {
"phpstan/phpstan": "^0.12",
Expand Down
1 change: 0 additions & 1 deletion generated/apache.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,3 @@ function virtual(string $uri): void
throw ApacheException::createFromPhpError();
}
}

1 change: 0 additions & 1 deletion generated/apcu.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,3 @@ function apcu_sma_info(bool $limited = false): array
}
return $result;
}

9 changes: 4 additions & 5 deletions generated/array.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function array_replace_recursive(array $array, array ...$replacements): array
error_clear_last();
if ($replacements !== []) {
$result = \array_replace_recursive($array, ...$replacements);
}else {
} else {
$result = \array_replace_recursive($array);
}
if ($result === null) {
Expand Down Expand Up @@ -123,7 +123,7 @@ function array_replace(array $array, array ...$replacements): array
error_clear_last();
if ($replacements !== []) {
$result = \array_replace($array, ...$replacements);
}else {
} else {
$result = \array_replace($array);
}
if ($result === null) {
Expand Down Expand Up @@ -155,12 +155,12 @@ function array_replace(array $array, array ...$replacements): array
* @throws ArrayException
*
*/
function array_walk_recursive(array &$array, callable $callback, $arg = null): void
function array_walk_recursive(array &$array, callable $callback, $arg = null): void
{
error_clear_last();
if ($arg !== null) {
$result = \array_walk_recursive($array, $callback, $arg);
}else {
} else {
$result = \array_walk_recursive($array, $callback);
}
if ($result === false) {
Expand Down Expand Up @@ -633,4 +633,3 @@ function usort(array &$array, callable $callback): void
throw ArrayException::createFromPhpError();
}
}

11 changes: 5 additions & 6 deletions generated/bzip2.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* @throws Bzip2Exception
*
*/
function bzclose( $bz): void
function bzclose($bz): void
{
error_clear_last();
$result = \bzclose($bz);
Expand All @@ -32,7 +32,7 @@ function bzclose( $bz): void
* @throws Bzip2Exception
*
*/
function bzflush( $bz): void
function bzflush($bz): void
{
error_clear_last();
$result = \bzflush($bz);
Expand All @@ -57,7 +57,7 @@ function bzflush( $bz): void
* @throws Bzip2Exception
*
*/
function bzread( $bz, int $length = 1024): string
function bzread($bz, int $length = 1024): string
{
error_clear_last();
$result = \bzread($bz, $length);
Expand All @@ -82,17 +82,16 @@ function bzread( $bz, int $length = 1024): string
* @throws Bzip2Exception
*
*/
function bzwrite( $bz, string $data, int $length = null): int
function bzwrite($bz, string $data, int $length = null): int
{
error_clear_last();
if ($length !== null) {
$result = \bzwrite($bz, $data, $length);
}else {
} else {
$result = \bzwrite($bz, $data);
}
if ($result === false) {
throw Bzip2Exception::createFromPhpError();
}
return $result;
}

3 changes: 1 addition & 2 deletions generated/calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,11 @@ function unixtojd(int $timestamp = null): int
error_clear_last();
if ($timestamp !== null) {
$result = \unixtojd($timestamp);
}else {
} else {
$result = \unixtojd();
}
if ($result === false) {
throw CalendarException::createFromPhpError();
}
return $result;
}

1 change: 0 additions & 1 deletion generated/classobj.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,3 @@ function class_alias(string $class, string $alias, bool $autoload = true): void
throw ClassobjException::createFromPhpError();
}
}

9 changes: 4 additions & 5 deletions generated/com.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ function com_create_guid(): string
* @throws ComException
*
*/
function com_event_sink(object $variant, object $sink_object, $sink_interface = null): void
function com_event_sink(object $variant, object $sink_object, $sink_interface = null): void
{
error_clear_last();
if ($sink_interface !== null) {
$result = \com_event_sink($variant, $sink_object, $sink_interface);
}else {
} else {
$result = \com_event_sink($variant, $sink_object);
}
if ($result === false) {
Expand Down Expand Up @@ -145,7 +145,7 @@ function com_print_typeinfo(object $variant, string $dispatch_interface = null,
$result = \com_print_typeinfo($variant, $dispatch_interface, $display_sink);
} elseif ($dispatch_interface !== null) {
$result = \com_print_typeinfo($variant, $dispatch_interface);
}else {
} else {
$result = \com_print_typeinfo($variant);
}
if ($result === false) {
Expand Down Expand Up @@ -185,7 +185,7 @@ function variant_date_to_timestamp(object $variant): int
* @throws ComException
*
*/
function variant_round( $value, int $decimals)
function variant_round($value, int $decimals)
{
error_clear_last();
$result = \variant_round($value, $decimals);
Expand All @@ -194,4 +194,3 @@ function variant_round( $value, int $decimals)
}
return $result;
}

Loading

0 comments on commit 56ab933

Please sign in to comment.