Skip to content

Commit d93b789

Browse files
authored
Merge pull request #2112 from nextcloud/feat/polyfills
feat: add polyfills for new PHP versions
2 parents 99ab30d + 7129890 commit d93b789

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1120
-5362
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,22 @@ Some 3rd party libraries that are necessary to run Nextcloud.
1616
8. Commit all changes onto a new branch
1717
9. You might need the following command for pushing if used as submodule: `git push [email protected]:nextcloud/3rdparty.git branchname`
1818

19+
### Updating polyfills
20+
21+
We make use of Symfony polyfills to allow us writing code already using methods from newer PHP version.
22+
This allows cleaner code and once our minimum PHP version is bumped we have no duplicated code for those methods anymore.
23+
24+
To keep the list of polyfills up to date, we need to add new polyfills once a new PHP version was released,
25+
for example with the release of PHP 8.4 we need to add its polyfills by running `composer require symfony/polyfill-php84`.
26+
27+
But we need to also remove unused polyfills to reduce any (minimal) overhead.
28+
Thus once we increase our minimal PHP version we should remove the added polyfills from the list of dependencies.
29+
Moreover also some dependencies require polyfills, to also reduce the list of added polyfills,
30+
we add the unneeded onces to the `replace` section of the `composer.json`.
31+
32+
So all PHP polyfills for already supported versions should be added to that section.
33+
But also polyfills for PHP modules that we require to be installed should be added, one example here is the `mbstring` module.
34+
1935
## Testing your PR with server
2036

2137
1. On https://github.com/nextcloud/server make a new branch `3rdparty/my-dependency`

composer.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
},
1919
"require": {
2020
"php": "^8.1",
21+
"ext-ctype": "*",
22+
"ext-mbstring": "*",
2123
"aws/aws-sdk-php": "^3.349",
2224
"bantu/ini-get-wrapper": "v1.0.1",
2325
"cweagans/composer-patches": "^1.7",
@@ -54,14 +56,22 @@
5456
"symfony/event-dispatcher": "^6.4.8",
5557
"symfony/http-foundation": "^6.4.14",
5658
"symfony/mailer": "^6.4",
57-
"symfony/polyfill-intl-grapheme": "^1.32.0",
58-
"symfony/polyfill-intl-normalizer": "^1.31.0",
59+
"symfony/polyfill-intl-normalizer": "^1.32.0",
60+
"symfony/polyfill-php82": "^1.32.0",
61+
"symfony/polyfill-php83": "^1.32.0",
62+
"symfony/polyfill-php84": "^1.32.0",
5963
"symfony/process": "^6.4.15",
6064
"symfony/routing": "^6.4.12",
6165
"symfony/translation": "^6.4.4",
6266
"wapmorgan/mp3info": "^0.1.1",
6367
"web-auth/webauthn-lib": "^4.9.1"
6468
},
69+
"replace": {
70+
"symfony/polyfill-php80": "*",
71+
"symfony/polyfill-php81": "*",
72+
"symfony/polyfill-ctype": "*",
73+
"symfony/polyfill-mbstring": "*"
74+
},
6575
"scripts": {
6676
"lint": "find . -name \\*.php -print0 | xargs -0 -n1 php -l",
6777
"pre-autoload-dump": "Aws\\Script\\Composer\\Composer::removeUnusedServices"

composer.lock

Lines changed: 39 additions & 125 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)