Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop PHP 5.6 #334

Closed
10 tasks
thekid opened this issue Sep 30, 2019 · 10 comments
Closed
10 tasks

Drop PHP 5.6 #334

thekid opened this issue Sep 30, 2019 · 10 comments

Comments

@thekid
Copy link
Member

thekid commented Sep 30, 2019

Scope of Change

This RFC suggests dropping PHP 5.6 support from all libraries.

Rationale

According to https://blog.packagist.com/php-versions-stats-2019-1-edition/ from May 2019, PHP 5 has roughly 10% market share.

Functionality

Dropping PHP 5.6 will be done in conjunction with adding support for XP 10 - see #333

Infrastructure

  • Drop from .travis.yml
  • Bump version in composer.json
  • Remove 6.X versions from dependencies lists in composer.json

Code

Security considerations

PHP 5.6 is EOL

Speed impact

Better, we can start dropping constructs and BC code for PHP 5.

Dependencies

Major release of each and every library

Related documents

@thekid
Copy link
Member Author

thekid commented Sep 30, 2019

Typical diff, clearly showing other libraries will need updates, too:

diff --git a/.travis.yml b/.travis.yml
index 87f5cdb..5ab646d 100755
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,7 +5,6 @@ language: php
 dist: trusty
 
 php:
-  - 5.6
   - 7.0
   - 7.1
   - 7.2
diff --git a/ChangeLog.md b/ChangeLog.md
index 0156cb5..1ba7821 100755
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -3,6 +3,14 @@ Data sequences change log
 
 ## ?.?.? / ????-??-??
 
+## 9.0.0 / ????-??-??
+
+* Added support for XP 10 and newer versions of library dependencies
+  (@thekid)
+* Implemented xp-framework/rfc#334: Drop PHP 5.6. The minimum required
+  PHP version is now 7.0.0!
+  (@thekid)
+
 ## 8.0.3 / 2019-09-29
 
 * Added PHP 7.4 compatibility - @thekid
diff --git a/composer.json b/composer.json
index 60fba7f..b638cd8 100755
--- a/composer.json
+++ b/composer.json
@@ -6,12 +6,12 @@
   "description" : "Data sequences",
   "keywords": ["module", "xp"],
   "require" : {
-    "xp-framework/core": "^9.0 | ^8.0 | ^7.0 | ^6.5",
-    "xp-framework/collections": "^8.0 | ^7.0 | ^6.5",
-    "php" : ">=5.6.0"
+    "xp-framework/core": "^10.0 | ^9.0 | ^8.0 | ^7.0",
+    "xp-framework/collections": "^9.0 | ^8.0 | ^7.0",
+    "php" : ">=7.0.0"
   },
   "require-dev" : {
-    "xp-framework/unittest": "^9.0 | ^8.0 | ^7.0 | ^6.5"
+    "xp-framework/unittest": "^10.0 | ^9.0 | ^8.0 | ^7.0"
   },
   "autoload" : {
     "files" : ["src/main/php/autoload.php"]

@thekid
Copy link
Member Author

thekid commented Sep 30, 2019

Group use statements via script:

<?php namespace rfc334;

use io\collections\iterate\{FilteredIOCollectionIterator, ExtensionEqualsFilter} from 'xp-framework/io-collections';
use io\collections\{FileCollection, FileElement} from 'xp-framework/io-collections';
use io\streams\LinesIn;
use util\cmd\Console;

function rewrite(FileElement $origin, FileElement $target): FileElement {
  $use= [];
  $out= $target->out();
  foreach (new LinesIn($origin->in()) as $line) {
    if (0 === strncmp($line, '<?php', 5)) {
      $out->write($line);
    } else if (0 === strncmp($line, 'use ', 4)) {
      $type= rtrim(substr($line, 4), '; ');
      $p= strrpos($type, '\\');
      $namespace= substr($type, 0, $p);
      if ('{' === $type[$p + 1]) {
        $use[$namespace]= array_merge($use[$namespace] ?? [], preg_split('/, ?/', substr($type, $p + 2, -1)));
      } else {
        $use[$namespace][]= substr($type, $p + 1);
      }
    } else if ($use) {
      ksort($use);
      foreach ($use as $namespace => $classes) {
        if (1 === sizeof($classes)) {
          $out->write(sprintf("\nuse %s\%s;", $namespace, $classes[0]));
        } else {
          sort($classes);
          $out->write(sprintf("\nuse %s\{%s};", $namespace, implode(', ', $classes)));
        }
      }
      $out->write("\n");
      $use= null;
    } else {
      $out->write("\n".$line);
    }
  }
  $out->close();
  return $target;
}

$src= new FilteredIOCollectionIterator(
  new FileCollection($argv[1] ?? 'src'),
  new ExtensionEqualsFilter(\xp::CLASS_FILE_EXT),
  true
);

foreach ($src as $file) {
  Console::write('> ', $file->getURI(), ': ');
  $target= rewrite($file, $file->getOrigin()->newElement('.rewrite'));
  rename($target->getURI(), $file->getURI());
  Console::writeLine('OK');
}

Usage:

$ xp group-use.script.php
> ...\src\main\php\util\data\Aggregations.class.php: OK
> ...\src\main\php\util\data\CannotReset.class.php: OK
# ...

$ git diff
# ...

thekid added a commit to xp-forge/sequence that referenced this issue Sep 30, 2019
thekid added a commit to xp-forge/sequence that referenced this issue Sep 30, 2019
thekid added a commit to xp-framework/compiler that referenced this issue Sep 30, 2019
thekid added a commit to xp-framework/unittest that referenced this issue Sep 30, 2019
@thekid
Copy link
Member Author

thekid commented Nov 30, 2019

✅ XP Unittests https://github.com/xp-framework/unittest

@thekid
Copy link
Member Author

thekid commented Nov 30, 2019

@thekid
Copy link
Member Author

thekid commented Apr 10, 2020

Current state:

$ grep 'xp-framework/rfc#334' */ChangeLog.md | cut -d / -f 1
ast
compiler
credentials
hashing
keepass
marshalling
neo4j
php-compact-methods
php-is-operator
php-switch-expression
redis-sessions
redis
tokenize
unittest
uri
websockets
webtest
xp-enums

@thekid
Copy link
Member Author

thekid commented Apr 10, 2020

TODO

  • address
  • assert
  • collections
  • command
  • csv
  • frontend
  • ftp
  • functions
  • geoip
  • google-authenticator
  • handlebars
  • http
  • ical
  • imaging
  • inject
  • io-collections
  • json-patch
  • json
  • ldap
  • logging
  • mail
  • markdown
  • math
  • measure
  • mirrors
  • mocks
  • mustache
  • networking
  • nsca
  • parse
  • partial
  • patterns
  • pivot
  • ratelimit
  • rdbms
  • rest-api
  • rest-client
  • sequence
  • sessions
  • stomp
  • text-encode
  • web-auth
  • web
  • xml
  • yaml
  • zip

@thekid
Copy link
Member Author

thekid commented Apr 10, 2020

24 libraries left to go

@thekid
Copy link
Member Author

thekid commented Apr 10, 2020

14 libraries left to go

@thekid
Copy link
Member Author

thekid commented Apr 10, 2020

6 libraries left to go

@thekid
Copy link
Member Author

thekid commented Apr 11, 2020

$ grep '>=5.6.0' */composer.json | wc -l
0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant