diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 40b87c2..1e78057 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,7 +15,6 @@ jobs: fail-fast: false matrix: include: - - php: 7.1 - php: 7.2 - php: 7.3 - php: 7.4 @@ -60,7 +59,7 @@ jobs: fail-fast: false matrix: include: - - php: 7.1 + - php: 7.2 steps: - name: Checkout diff --git a/.php-version b/.php-version index 37722eb..5904f7a 100644 --- a/.php-version +++ b/.php-version @@ -1 +1 @@ -7.4 +7.2 diff --git a/README.md b/README.md index 5c45a00..3d9cc8a 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,10 @@ Lodash-PHP is a port of the [Lodash JS library](https://lodash.com/) to PHP. It Lodash-PHP tries to mimick lodash.js as close as possible +# Requirements + +Lodash-PHP requires minimum PHP 7.2+, but the latest version of PHP is always recommended. + # Installation Install Lodash-PHP through composer: diff --git a/bin/compile b/bin/compile index 2422749..1018030 100755 --- a/bin/compile +++ b/bin/compile @@ -5,8 +5,6 @@ declare(strict_types=1); -require_once dirname(__DIR__).'/vendor/autoload.php'; - function getCode(SplFileInfo $file): string { $code = php_strip_whitespace($file->getRealPath()); diff --git a/composer.json b/composer.json index 3fb0d3a..35d299e 100644 --- a/composer.json +++ b/composer.json @@ -23,15 +23,15 @@ ] }, "require": { - "php": ">=7.1", - "sebastian/comparator": "^1.2 | ^2.0 | ^2.1 | ^3.0 | ^4.0", - "symfony/property-access": "^2.7 | ^3.0 | ^4.0 | ^5.0" + "php": "^7.2 || ^8.0", + "sebastian/comparator": "^1.2 | ^2.0 | ^2.1 | ^3.0 | ^4.0 | ^5.0 | ^6.0", + "symfony/property-access": "^2.7 | ^3.0 | ^4.0 | ^5.0 | ^6.0" }, "require-dev": { "phpdocumentor/reflection-docblock": "*", "phpstan/phpdoc-parser": "*", "phpunit/phpunit": "^7.3 || ^8.4", - "phpstan/phpstan": "^0.12", + "phpstan/phpstan": "^1.10", "friendsofphp/php-cs-fixer": "^2.12" } } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 233035a..b806197 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,40 +1,5 @@ parameters: ignoreErrors: - - - message: "#^PHPDoc tag @param references unknown parameter\\: \\$iteratee$#" - count: 1 - path: src/Array/differenceBy.php - - - - message: "#^PHPDoc tag @param references unknown parameter\\: \\$comparator$#" - count: 1 - path: src/Array/differenceWith.php - - - - message: "#^PHPDoc tag @param references unknown parameter\\: \\$iteratee$#" - count: 1 - path: src/Array/intersectionBy.php - - - - message: "#^PHPDoc tag @param references unknown parameter\\: \\$comparator$#" - count: 1 - path: src/Array/intersectionWith.php - - - - message: "#^PHPDoc tag @param references unknown parameter\\: \\$iteratee$#" - count: 1 - path: src/Array/unionBy.php - - - - message: "#^PHPDoc tag @param references unknown parameter\\: \\$comparator$#" - count: 1 - path: src/Array/unionWith.php - - - - message: "#^PHPDoc tag @param references unknown parameter\\: \\$iteratee$#" - count: 1 - path: src/Array/zipWith.php - - message: "#^Unreachable statement \\- code above always terminates\\.$#" count: 1 @@ -56,27 +21,12 @@ parameters: path: src/String/startsWith.php - - message: "#^Comparison operation \"\\>\" between int\\<0, max\\> and \\-1 is always true\\.$#" - count: 1 - path: src/String/truncate.php - - - - message: "#^Call to function is_array\\(\\) with object will always evaluate to false\\.$#" + message: "#^Offset mixed on \\*NEVER\\* in isset\\(\\) always exists and is not nullable\\.$#" count: 1 - path: src/internal/isIterateeCall.php - - - - message: "#^Result of \\|\\| is always true\\.$#" - count: 1 - path: src/internal/isIterateeCall.php + path: src/internal/baseIntersection.php - message: "#^Unreachable statement \\- code above always terminates\\.$#" count: 1 path: src/internal/isIterateeCall.php - - - message: "#^Regex pattern is invalid\\: Delimiter must not be alphanumeric or backslash in pattern\\: \\\\x\\{e83c\\}\\[\\\\x\\{effb\\}\\-\\\\x\\{efff\\}\\]\\(\\?\\=\\\\x\\{e83c\\}\\[\\\\x\\{effb\\}\\-\\\\x\\{efff\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x\\{e83c\\}\\[\\\\x\\{effb\\}\\-\\\\x\\{efff\\}\\]\\)\\?\\)\\*$#" - count: 1 - path: src/internal/unicodeSize.php - diff --git a/phpstan.neon b/phpstan.neon index ae2cc00..08970a1 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -4,11 +4,12 @@ includes: parameters: paths: - src - bootstrap: %rootDir%/../../../src/bootstrap.php + bootstrapFiles: + - src/bootstrap.php level: 5 - excludes_analyse: + excludePaths: - src/compiled.php - src/Lodash.php - src/internal/memoizeCapped.php # Exclude internal function due to dynamic class usage ignoreErrors: - - "#Callable '.*internal.*' invoked with \\d+ parameters, [\\d-]+ required.#" + - "#^PHPDoc tag \\@param references unknown parameter\\: \\$[a-zA-Z]+$#" diff --git a/src/Object/get.php b/src/Object/get.php index 84e8268..3a0c66d 100644 --- a/src/Object/get.php +++ b/src/Object/get.php @@ -1,6 +1,6 @@ "; } @@ -145,8 +145,14 @@ function template(string $string, array $options = []): callable return new class($string, $imports) { public $source; + /** + * @var array + */ private $imports; + /** + * @param array $imports + */ public function __construct(string $source, array $imports) { $this->source = $source; diff --git a/src/String/truncate.php b/src/String/truncate.php index 7fc4601..381c0df 100644 --- a/src/String/truncate.php +++ b/src/String/truncate.php @@ -105,7 +105,7 @@ function truncate($string, array $options = []) } } elseif (\strpos($string, $separator) !== $end) { $index = \strrpos($result, $separator); - if (false !== $index && $index > -1) { + if (false !== $index) { $result = \substr($result, 0, $index); } } diff --git a/src/internal/isIterateeCall.php b/src/internal/isIterateeCall.php index 08b13b2..b9c3169 100644 --- a/src/internal/isIterateeCall.php +++ b/src/internal/isIterateeCall.php @@ -24,7 +24,7 @@ */ function isIterateeCall($value, $index = null, $object = null) { - if (!\is_object($object) || !\is_array($object)) { + if (!\is_object($object) && !\is_array($object)) { return false; } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy