From 1431fd9935713be514b8726ce78f1553ea8cbce3 Mon Sep 17 00:00:00 2001 From: Meritoo Date: Sun, 1 Jul 2018 17:37:51 +0200 Subject: [PATCH 1/7] Composer > require ext-pcre --- CHANGELOG.md | 4 ++++ composer.json | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 14063e4..06ae9b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Meritoo Common Library Common and useful classes, methods, exceptions etc. +# 0.0.21 + +1. Composer > require ext-pcre + # 0.0.20 1. Collection > add() method > treat empty string as not provided index (same as null) diff --git a/composer.json b/composer.json index 8303f1b..8ac9cca 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "meritoo/common-library", "description": "Useful classes, methods, extensions etc.", "license": "MIT", - "version": "0.0.20", + "version": "0.0.21", "authors": [ { "name": "Meritoo.pl", @@ -12,6 +12,7 @@ ], "require": { "php": ">=5.5.9", + "ext-pcre": "*", "doctrine/orm": "^2.5", "gedmo/doctrine-extensions": "^2.4" }, From 848adef015d47fe8919b4c1dccc012070f56d59f Mon Sep 17 00:00:00 2001 From: Meritoo Date: Sun, 1 Jul 2018 17:43:06 +0200 Subject: [PATCH 2/7] Arrays > minor refactoring --- CHANGELOG.md | 1 + src/Utilities/Arrays.php | 98 +++++++++++++++++++++------------------- 2 files changed, 53 insertions(+), 46 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 06ae9b7..7e4a04c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ Common and useful classes, methods, exceptions etc. # 0.0.21 1. Composer > require ext-pcre +2. Arrays > minor refactoring # 0.0.20 diff --git a/src/Utilities/Arrays.php b/src/Utilities/Arrays.php index cb254f8..dde7754 100644 --- a/src/Utilities/Arrays.php +++ b/src/Utilities/Arrays.php @@ -673,7 +673,7 @@ class Arrays return null; } - $effect = $array; + $effect = &$array; ksort($effect, $sortFlags); foreach ($effect as &$value) { @@ -822,60 +822,66 @@ class Arrays */ public static function getLastElementsPaths(array $array, $separator = '.', $parentPath = '', $stopIfMatchedBy = '') { + /* + * No elements? + * Nothing to do + */ + if (empty($array)) { + return []; + } + + if (!empty($stopIfMatchedBy)) { + $stopIfMatchedBy = self::makeArray($stopIfMatchedBy); + } + $paths = []; - if (!empty($array)) { - if (!empty($stopIfMatchedBy)) { - $stopIfMatchedBy = self::makeArray($stopIfMatchedBy); + foreach ($array as $key => $value) { + $path = $key; + $stopRecursion = false; + + /* + * If the path of parent element is delivered, + * I have to use it and build longer path + */ + if (!empty($parentPath)) { + $pathTemplate = '%s%s%s'; + $path = sprintf($pathTemplate, $parentPath, $separator, $key); } - foreach ($array as $key => $value) { - $path = $key; - $stopRecursion = false; + /* + * Check if the key or current path matches one of patterns at which the process should be stopped, + * the recursive not used. It means that I have to pass current value and stop processing of the + * array (don't go to the next step). + */ + if (!empty($stopIfMatchedBy)) { + foreach ($stopIfMatchedBy as $rawPattern) { + $pattern = sprintf('|%s|', $rawPattern); - /* - * If the path of parent element is delivered, - * I have to use it and build longer path - */ - if (!empty($parentPath)) { - $pathTemplate = '%s%s%s'; - $path = sprintf($pathTemplate, $parentPath, $separator, $key); - } - - /* - * Check if the key or current path matches one of patterns at which the process should be stopped, - * the recursive not used. It means that I have to pass current value and stop processing of the - * array (don't go to the next step). - */ - if (!empty($stopIfMatchedBy)) { - foreach ($stopIfMatchedBy as $rawPattern) { - $pattern = sprintf('|%s|', $rawPattern); - - if (preg_match($pattern, $key) || preg_match($pattern, $path)) { - $stopRecursion = true; - break; - } + if (preg_match($pattern, $key) || preg_match($pattern, $path)) { + $stopRecursion = true; + break; } } + } - /* - * The value is passed to the returned array if: - * - it's not an array - * or - * - the process is stopped, recursive is not used - */ - if (!is_array($value) || (is_array($value) && empty($value)) || $stopRecursion) { - $paths[$path] = $value; - continue; - } + /* + * The value is passed to the returned array if: + * - it's not an array + * or + * - the process is stopped, recursive is not used + */ + if (!is_array($value) || (is_array($value) && empty($value)) || $stopRecursion) { + $paths[$path] = $value; + continue; + } - /* - * Let's iterate through the next level, using recursive - */ - if (is_array($value)) { - $recursivePaths = self::getLastElementsPaths($value, $separator, $path, $stopIfMatchedBy); - $paths += $recursivePaths; - } + /* + * Let's iterate through the next level, using recursive + */ + if (is_array($value)) { + $recursivePaths = self::getLastElementsPaths($value, $separator, $path, $stopIfMatchedBy); + $paths += $recursivePaths; } } From 64499b49d32f58d1c9c7e38b2d8d5f799039923e Mon Sep 17 00:00:00 2001 From: Meritoo Date: Sun, 1 Jul 2018 21:07:47 +0200 Subject: [PATCH 3/7] Update @author and @copyright in classes' descriptions --- CHANGELOG.md | 1 + build.xml | 2 +- phing/properties.dist | 4 ++-- phing/tests.xml | 14 +++++++------- src/Collection/Collection.php | 4 ++-- src/Exception/Base/UnknownTypeException.php | 4 ++-- .../Bundle/IncorrectBundleNameException.php | 4 ++-- .../Date/UnknownDatePartTypeException.php | 4 ++-- src/Exception/File/EmptyFileException.php | 4 ++-- src/Exception/File/EmptyFilePathException.php | 4 ++-- src/Exception/File/NotExistingFileException.php | 4 ++-- src/Exception/Method/DisabledMethodException.php | 4 ++-- .../CannotResolveClassNameException.php | 4 ++-- .../Reflection/MissingChildClassesException.php | 4 ++-- .../Reflection/TooManyChildClassesException.php | 4 ++-- .../Regex/IncorrectColorHexLengthException.php | 4 ++-- .../Regex/InvalidColorHexValueException.php | 4 ++-- .../Regex/InvalidHtmlAttributesException.php | 4 ++-- src/Exception/Regex/InvalidUrlException.php | 4 ++-- .../Type/UnknownOopVisibilityTypeException.php | 4 ++-- src/Test/Base/BaseTestCase.php | 4 ++-- src/Test/Base/BaseTypeTestCase.php | 4 ++-- src/Traits/Test/Base/BaseTestCaseTrait.php | 4 ++-- src/Traits/Test/Base/BaseTypeTestCaseTrait.php | 4 ++-- src/Type/Base/BaseType.php | 4 ++-- src/Type/DatePartType.php | 4 ++-- src/Type/DatePeriod.php | 4 ++-- src/Type/OopVisibilityType.php | 4 ++-- src/Utilities/Arrays.php | 4 ++-- src/Utilities/Bundle.php | 4 ++-- src/Utilities/Composer.php | 4 ++-- src/Utilities/Date.php | 4 ++-- src/Utilities/GeneratorUtility.php | 4 ++-- src/Utilities/Locale.php | 4 ++-- src/Utilities/MimeTypes.php | 4 ++-- src/Utilities/Miscellaneous.php | 4 ++-- src/Utilities/QueryBuilderUtility.php | 4 ++-- src/Utilities/Reflection.php | 6 +++--- src/Utilities/Regex.php | 4 ++-- src/Utilities/Repository.php | 4 ++-- src/Utilities/Uri.php | 4 ++-- src/Utilities/Xml.php | 4 ++-- tests/Collection/CollectionTest.php | 4 ++-- .../Exception/Base/UnknownTypeExceptionTest.php | 16 ++++++++-------- .../Date/UnknownDatePartTypeExceptionTest.php | 4 ++-- tests/Exception/File/EmptyFileExceptionTest.php | 4 ++-- .../File/EmptyFilePathExceptionTest.php | 4 ++-- .../File/NotExistingFileExceptionTest.php | 4 ++-- .../Method/DisabledMethodExceptionTest.php | 4 ++-- .../CannotResolveClassNameExceptionTest.php | 4 ++-- .../MissingChildClassesExceptionTest.php | 4 ++-- .../TooManyChildClassesExceptionTest.php | 4 ++-- .../IncorrectColorHexLengthExceptionTest.php | 4 ++-- .../Regex/InvalidColorHexValueExceptionTest.php | 4 ++-- .../Regex/InvalidHtmlAttributesExceptionTest.php | 4 ++-- .../Exception/Regex/InvalidUrlExceptionTest.php | 4 ++-- .../UnknownOopVisibilityTypeExceptionTest.php | 4 ++-- tests/Test/Base/BaseTestCaseTest.php | 8 ++++---- tests/Type/Base/BaseTypeTest.php | 12 ++++++------ tests/Type/DatePartTypeTest.php | 4 ++-- tests/Type/DatePeriodTest.php | 4 ++-- tests/Utilities/ArraysTest.php | 4 ++-- tests/Utilities/BundleTest.php | 4 ++-- tests/Utilities/ComposerTest.php | 4 ++-- tests/Utilities/DateTest.php | 4 ++-- tests/Utilities/GeneratorUtilityTest.php | 4 ++-- tests/Utilities/LocaleTest.php | 4 ++-- tests/Utilities/MimeTypesTest.php | 4 ++-- tests/Utilities/MiscellaneousTest.php | 4 ++-- tests/Utilities/QueryBuilderUtilityTest.php | 4 ++-- tests/Utilities/Reflection/A.php | 4 ++-- tests/Utilities/Reflection/B.php | 4 ++-- tests/Utilities/Reflection/C.php | 4 ++-- tests/Utilities/Reflection/D.php | 4 ++-- tests/Utilities/Reflection/E.php | 4 ++-- tests/Utilities/Reflection/F.php | 4 ++-- tests/Utilities/Reflection/G.php | 4 ++-- tests/Utilities/Reflection/H.php | 4 ++-- tests/Utilities/Reflection/I.php | 4 ++-- tests/Utilities/ReflectionTest.php | 4 ++-- tests/Utilities/RegexTest.php | 4 ++-- tests/Utilities/Repository/Sortable.php | 4 ++-- tests/Utilities/RepositoryTest.php | 4 ++-- tests/Utilities/UriTest.php | 4 ++-- tests/Utilities/XmlTest.php | 4 ++-- 85 files changed, 186 insertions(+), 185 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e4a04c..bdfa192 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ Common and useful classes, methods, exceptions etc. 1. Composer > require ext-pcre 2. Arrays > minor refactoring +3. Update @author and @copyright in classes' descriptions # 0.0.20 diff --git a/build.xml b/build.xml index d23552d..d65367b 100644 --- a/build.xml +++ b/build.xml @@ -29,7 +29,7 @@ Conditional running of tests. Disabled, because not required. - Krzysztof Niziol + Meritoo 2017-02-22 diff --git a/phing/properties.dist b/phing/properties.dist index aaf0ccb..dc0463c 100644 --- a/phing/properties.dist +++ b/phing/properties.dist @@ -31,7 +31,7 @@ assets.installWithSymlink = true # The cache:clear command should always be called with the --no-warmup option. Warmup should be done via the cache:warmup command. # https://github.com/symfony/symfony/blob/master/UPGRADE-3.3.md#frameworkbundle # -# Krzysztof Niziol +# Meritoo # 2017-06-06 # cache.clearWithWarmup = false @@ -81,7 +81,7 @@ dir.reports.coverage = ${dir.reports}/phpunit_coverage # Disabled, because unnecessary right now # phpdocumentor/phpdocumentor cannot be installed via Composer # -# Krzysztof Niziol +# Meritoo # 2017-02-22 # #dir.docs = ${dir.build}/docs diff --git a/phing/tests.xml b/phing/tests.xml index c4e983b..edd288b 100644 --- a/phing/tests.xml +++ b/phing/tests.xml @@ -4,7 +4,7 @@ The AutoloaderTask is required to load binaries installed by Composer. The "autoloaderpath" attribute of this task is not required, because it's default value is: vendor/autoload.php. - Krzysztof Niziol + Meritoo 2017-02-23 --> @@ -48,7 +48,7 @@ a) phpdocumentor/phpdocumentor v2.9.0 requires symfony/validator ~2.2 b) symfony/validator ~2.2 causes to remove symfony/symfony 3.* - Krzysztof Niziol + Meritoo 2017-02-22 --> @@ -73,7 +73,7 @@ a) phpdocumentor/phpdocumentor v2.9.0 requires symfony/validator ~2.2 b) symfony/validator ~2.2 causes to remove symfony/symfony 3.* - Krzysztof Niziol + Meritoo 2017-02-22 --> @@ -113,7 +113,7 @@ a) phpdocumentor/phpdocumentor v2.9.0 requires symfony/validator ~2.2 b) symfony/validator ~2.2 causes to remove symfony/symfony 3.* - Krzysztof Niziol + Meritoo 2017-02-22 @@ -142,7 +142,7 @@ via Composer the Symfony2 standard is not included / available in this package. In this case the PHP Coding Standards Fixer (http://cs.sensiolabs.org) is used. - Krzysztof Niziol + Meritoo 2017-02-22 --> @@ -166,7 +166,7 @@