Skip to content

Meta Package for installing thecodingmachine/safe in PHP 7 and PHP 8

License

Notifications You must be signed in to change notification settings

eventjet/thecodingmachine-safe-meta

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

thecodingmachine/safe Meta Package

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.

About

Meta Package for installing thecodingmachine/safe in PHP 7 and PHP 8

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published