New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory size exhausted for all memory limit #6911
Comments
This bug report is missing a link to reproduction on phpstan.org. It will most likely be closed after manual review. |
Most likely a recursion problem. Can you create a minimal reproducing example and share that? If it would fit in a phpstan.org snippet, that would be perfect. If not, a dedicated public repo would be great. |
Very difficult, I don't kwon, in my code, where it's broken, and my repo can't be public.... |
Might be related to my #6896, I created that snippet by first enabling debug logs to check which file is being scanned and where does it get stuck (running phpstan for one file at a time can also help), then I trimmed the contents of the file until I had a small enough snippet that reproduced the error. |
This class is in error : <?php
namespace App\Controller;
use App\AppException\AppException;
use ReflectionClass;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\FormError;
use Symfony\Component\Form\FormErrorIterator;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Contracts\Translation\TranslatorInterface;
abstract class AbstractSmartController extends AbstractController
{
protected array $viewVars = [];
protected array $jsVars = [];
/** @required */
public TranslatorInterface $translator;
public function getTemplatePath(string $view): string
{
$reflector = new ReflectionClass(get_called_class());
$controllerName = str_replace(
'Controller',
'',
basename($reflector->getFileName(), '.php')
);
$templateDirPath =
str_replace(
$this->getParameter('kernel.project_dir') . '/src/Controller/',
'',
dirname($reflector->getFileName())
) . '/' . $controllerName;
$view = $this->toSnakeCase($view);
return $templateDirPath
. '/' . $view . '.html.twig';
}
protected function renderTemplate(string $view): Response
{
$view = $this->getTemplatePath($view);
$this->viewVars['js'] = json_encode($this->jsVars);
return $this->render($view, $this->viewVars);
}
protected function toSnakeCase($str, $glue = '_')
{
return preg_replace_callback('/[A-Z]/', function ($matches) use ($glue): string {
return $glue . strtolower($matches[0]);
}, $str);
}
protected function createJsonErrorResponse(AppException $exception): JsonResponse
{
return new JsonResponse([
'errors' => [
[
'message' => $exception->getAppMessage($this->translator),
'code' => $exception->getAppCode(),
]
]
]);
}
protected function redirectAfterSubmit(Request $request): ?Response
{
$next = $request->get('goto', null);
if (null !== $next) {
return $this->redirect($next);
}
return null;
}
protected function getErrorOriginIdentifier(FormError $error): string
{
$origins = [$error->getOrigin()->getName()];
$parent = $error->getOrigin()->getParent();
while ($parent !== null) {
$origins[] = $parent->getName();
$parent = $parent->getParent();
}
return join('_', array_reverse($origins));
}
protected function createJsonFormErrorResponse(FormErrorIterator $errorIterator): Response
{
$formErrors = [];
foreach ($errorIterator as $error) {
$fieldIdentifier = $this->getErrorOriginIdentifier($error);
if (!array_key_exists($fieldIdentifier, $formErrors)) {
$formErrors[$fieldIdentifier] = [];
}
$formErrors[$fieldIdentifier][] = [
'message' => $error->getMessage(),
];
}
return new JsonResponse([
'formErrors' => $formErrors
]);
}
} I worked on the getTemplatePath to see if in it, but not... |
I tested on a simple repo with only this code, but it's not in error.... EDIT :
EDIT 2 : parameters:
level: 5
paths:
- src/Controller
excludePaths:
analyse:
- src/Controller/AbstractSmartController*
- src/Controller/Back/Admin/HolidayController*
- src/Controller/ConnectedSpace/CardController*
- src/Controller/ConnectedSpace/CalendarModelController*
- src/Controller/ConnectedSpace/CalendarReservationController*
- src/Controller/ConnectedSpace/API/CalendarModelApiController*
- src/Controller/ConnectedSpace/API/ReservationController*
- src/Controller/ConnectedSpace/API/CalendarReservationApiController*
- src/Controller/Front/PartnerController*
analyseAndScan:
- */Migrations/*
- src/Command/ImportDatabase/*
- */tests/* |
I have the same error using Rector. It's related to |
Then it indeed sounds very related to what @danog reported. I can check this weekend |
Most likely fixed by: phpstan/phpstan-src#1137 |
Is it possible to tag a new version ? |
Try it out ;) https://github.com/phpstan/phpstan/releases/tag/1.5.2 |
Nice, it's working |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Bug report
Hi there, I'm currently using the version 1.5 to PHPStan (I upgrade from
0.12.88
). I tested to use memory size at 1G, 2G, 3G, 4G and 8G. There is an infinite loop ? I can't show you the code and the project is a big projectThe text was updated successfully, but these errors were encountered: