rdlowrey / auryn

IoC Dependency Injector
MIT License
722 stars 65 forks source link

Deprecations with php8 #186

Closed WeaponsTheyFear closed 3 years ago

WeaponsTheyFear commented 3 years ago

Not sure if you plan to support php 8, but I am getting deprecation issues in CachingReflector.

Method ReflectionParameter::getClass() is deprecated

        if ($reflectionClass = $param->getClass()) {
            $typeHint = $reflectionClass->getName();
            $classCacheKey = self::CACHE_KEY_CLASSES . strtolower($typeHint);
            $this->cache->store($classCacheKey, $reflectionClass);
        } else {
            $typeHint = null;
        }
trowski commented 3 years ago

Yes, I'm going to upgrade it to PHP 8, add types here and there, and make some API tweaks. This repo will be moved to amphp/auryn.

WeaponsTheyFear commented 3 years ago

This solved my issue in CachingReflector:

       if ($param->getType() && !$param->getType()->isBuiltin()) {
            $typeHint = $param->getType()->getName();
            $classCacheKey = self::CACHE_KEY_CLASSES . strtolower($typeHint);
            $reflectionClass = new \ReflectionClass($param->getType()->getName());
            $this->cache->store($classCacheKey, $reflectionClass);
        } else {
            $typeHint = null;
        }
dlgoodchild commented 3 years ago

Is Auryn effectively unmaintained now? I'm wondering if it should be forked now as it's usable with PHP8.

kelunik commented 3 years ago

No, I'll get it sorted. But the next major will be released under @amphp.

trowski commented 3 years ago

@kelunik I merged the PR to fix the 8 deprecation errors in amphp/auryn if you wanted to tag there and alter the readme here to redirect there.