From c6efc30872bd0a26ef07d18d19fb12ca0e54957e Mon Sep 17 00:00:00 2001 From: Meritoo Date: Fri, 26 Feb 2021 15:09:02 +0100 Subject: [PATCH] Fix "Array and string offset access syntax with curly braces is deprecated" error while running tests (using PHP 7.4) --- composer.json | 2 +- src/Utilities/Miscellaneous.php | 2 +- src/Utilities/Reflection.php | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index 90a54b8..89009ba 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "ext-pcre": "*", "ext-simplexml": "*", "doctrine/orm": "^2.6", - "gedmo/doctrine-extensions": "^2.4" + "gedmo/doctrine-extensions": "^3.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "^2.14", diff --git a/src/Utilities/Miscellaneous.php b/src/Utilities/Miscellaneous.php index 6d888b3..39681ed 100644 --- a/src/Utilities/Miscellaneous.php +++ b/src/Utilities/Miscellaneous.php @@ -574,7 +574,7 @@ class Miscellaneous if ($textLength > $maxLength) { $effect = mb_substr($text, 0, $maxLength, 'utf-8'); - $lastSpacePosition = mb_strrpos($effect, ' ', 'utf-8'); + $lastSpacePosition = mb_strrpos($effect, ' ', 0, 'utf-8'); if (false !== $lastSpacePosition) { $effect = mb_substr($effect, 0, $lastSpacePosition, 'utf-8'); diff --git a/src/Utilities/Reflection.php b/src/Utilities/Reflection.php index 9508ba2..e641338 100644 --- a/src/Utilities/Reflection.php +++ b/src/Utilities/Reflection.php @@ -8,8 +8,8 @@ namespace Meritoo\Common\Utilities; -use Doctrine\Common\Inflector\Inflector; -use Doctrine\Common\Persistence\Proxy; +use Doctrine\Inflector\InflectorFactory; +use Doctrine\Persistence\Proxy; use Meritoo\Common\Collection\BaseCollection; use Meritoo\Common\Exception\Reflection\CannotResolveClassNameException; use Meritoo\Common\Exception\Reflection\MissingChildClassesException; @@ -418,8 +418,8 @@ class Reflection * * @param array|object|string $class Class who child classes should be returned. An array of objects, strings, * object or string. - * @throws CannotResolveClassNameException * @return null|array + * @throws CannotResolveClassNameException */ public static function getChildClasses($class): ?array { @@ -471,9 +471,8 @@ class Reflection * * @param array|object|string $parentClass Class who child class should be returned. An array of objects, * namespaces, object or namespace. - * @throws MissingChildClassesException - * @throws TooManyChildClassesException * @return mixed + * @throws TooManyChildClassesException|MissingChildClassesException|CannotResolveClassNameException */ public static function getOneChildClass($parentClass) { @@ -531,8 +530,8 @@ class Reflection * @param array|string $trait An array of strings or string * @param bool $verifyParents If is set to true, parent classes are verified if they use given * trait. Otherwise - not. - * @throws CannotResolveClassNameException * @return null|bool + * @throws CannotResolveClassNameException|ReflectionException */ public static function usesTrait($class, $trait, bool $verifyParents = false): ?bool { @@ -711,7 +710,8 @@ class Reflection $valueFound = false; $reflectionObject = new ReflectionObject($source); - $property = Inflector::classify($property); + $inflector = InflectorFactory::create()->build(); + $property = $inflector->classify($property); $gettersPrefixes = [ 'get',