Segmentation fault with 0.12.0@dev analyzing use of nesbot\carbon
Analyzing source files with usage of date/time management package nesbot\carbon (2.26 stable) result in segmentation fault and failure to complete scan. This only occurs on current PHPStan master 0.12.0 File analysis runs fine on 0.11.9 against the same source files.
$ vendor/bin/phpstan analyse test.php --debug --memory-limit=64 --level=0
PHPStan crashed in the previous run probably because of excessive memory consumption.
It consumed around 12 MB of memory.
To avoid this issue, allow to use more memory with the --memory-limit option.
[path removed]/test.php
Segmentation fault
Increasing memory does not affect, and the system has GBs free RAM.
Running on Ubuntu 18.04 LTS
PHP 7.3.11-1+ubuntu18.04.1+deb.sury.org+1
Example use of Carbon:
<?php use Carbon\Carbon; require_once dirname(__DIR__) . '/vendor/autoload.php'; $date = Carbon::parse(date(DATE_ATOM)); echo print_r($date);
Alternatively with..
$date = new Carbon(date(DATE_ATOM));
The same result is seen whether instantiating Carbon first, or as a static call, seemingly against all Carbon methods. A couple of examples:
$date = Carbon::now(); $date = Carbon::createSafe((int) $year, (int) $month, (int) $day); $date = Carbon::createFromFormat('Y-m-d', $inputDate)->age; $date = Carbon::parse(date(DATE_ATOM));
Basic composer.json for example:
"type": "project", "license": "proprietary", "minimum-stability": "dev", "require": { "php": "^7.3", "nesbot/carbon": "2.26" }, "config": { "preferred-install": { "*": "dist" }, "sort-packages": true }, "autoload": { "psr-4": { "App\\": "app/" } }, "autoload-dev": { "psr-4": { "App\\Tests\\": "tests/" } }, "require-dev": { "phpstan/phpstan": "^0.12.0@dev" } }