eventjet / thecodingmachine-safe-meta
Meta Package for installing thecodingmachine/safe in PHP 7 and PHP 8
Installs: 606
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 0
pkg:composer/eventjet/thecodingmachine-safe-meta
Requires
- php: ^8.0
- thecodingmachine/safe8: ^0.1
Provides
- thecodingmachine/safe: ^1.3
README
Abandoned!
As thecodingmachine/safe was
again "un-deprecated"
this meta-package is no longer needed. A big thank you to all involved people! 🙂
What is this?
This package is a small wrapper to allow installing thecodingmachine/safe
on PHP 7 and thecodingmachine/safe8 on PHP 8 automatically, depending on
the used PHP version.
Why do I need this?
thecodingmachine/safe is only available for PHP 7. For PHP 8, thecodingmachine/safe8 was created. That makes it
impossible to have a package using the awesome Safe library while supporting PHP ^7.4 || ^8.0.
How do I use it?
Instead of requiring thecodingmachine/safe directly, use this package in composer.json:
{
"require": {
"php": "^7.4 || ^8.0",
"eventjet/thecodingmachine-safe-meta": "^1.0 || ^2.0"
}
}
Caveats
Requiring a package indirectly introduces a hidden dependency, which is excatly what this package does. Therefore, if you use ComposerRequireChecker, it will complain. As a workaround you have to whitelist every function/class that is used in your code.
Create a require-checker.json file which includes the used Safe functions:
{
"symbol-whitelist": [
"null",
"true",
"false",
"static",
"self",
"parent",
"array",
"string",
"int",
"float",
"bool",
"iterable",
"callable",
"void",
"object",
"mixed",
"Safe\\sprintf"
]
}
And then run the checker with that config: vendor/bin/composer-require-checker --config-file=require-checker.json.
If you know a better workaround for that, please let me know!
Thanks!
Special thanks goes to Kharhamel and all contributors who
created thecodingmachine/safe!
Hopefully, some time this package won't be required anymore if there is some way for Safe
to support PHP 7 and PHP 8 in one package.