phpstan: Constant not found

I have fake error https://phpstan.org/r/05b59186b28d090c4d27f859dc106a21

Run

php vendor/bin/phpstan analyse -l max -c phpstan.neon src app

Output:

 201/201 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

 ------ ---------------------------------- 
  Line   app/cron/cron.php                 
 ------ ---------------------------------- 
  14     Constant CONSOLE_PATH not found.  
  23     Constant CONSOLE_PATH not found.  
  32     Constant CONSOLE_PATH not found.  
  41     Constant CONSOLE_PATH not found.  
  50     Constant CONSOLE_PATH not found.  
  60     Constant CONSOLE_PATH not found.  
 ------ ---------------------------------- 

app/cron/cron.php

<?php
require_once __DIR__ . '/../../vendor/autoload.php';

const CONSOLE_PATH = __DIR__ . '/../../bin/console';

$cron = new Jobby\Jobby([
    'output' => 'logs/output.log',
]);

/**
 * Update popular list on main page
 */
$cron->add('UpdatePopularToday', [
    'command'  => CONSOLE_PATH . ' cron:update-popular-today --no-debug',
    'schedule' => '0 */6 * * *',
    'output'   => 'logs/update-popular-today.log',
]);
// ...

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 21 (14 by maintainers)

Commits related to this issue

Most upvoted comments

Unfortunately current Docker image has PHP 7.2 😦

/app # php -v
PHP 7.2.22 (cli) (built: Aug 30 2019 00:11:51) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

It will be fixed with PHPStan 0.12, phpstan/phpstan:nightly has a new base Dockerfile. Feel free to try it out, although the ecosystem (other extensions) aren’t ready yet. But you can build your own image using https://github.com/phpstan/docker-image/blob/master/Dockerfile and 0.11.18 as PHPSTAN_VERSION arg.

Right now you have to define your constants separately in some kind of a bootstrap file loaded by PHPStan. I’m adding this under Static reflection milestone because it might be possible to tackle this there.