Skip to content

Conversation

@paulbalandan
Copy link
Member

Description
I'm updating phpstan-codeigniter to cater 4.7 and I'm hitting the following test error:

An error occurred inside PHPUnit.

Message:  Undefined constant "CodeIgniter\Test\SUPPORTPATH"
Location: /Users/paul/Workspace/phpstan-codeigniter/vendor/codeigniter4/codeigniter4/system/Test/CIUnitTestCase.php:127

Upon investigation, I learned that util_bootstrap.php defines SUPPORTPATH if tests/_support/ is an existing directory. Since I'm not using that, consequentially, that constant is not defined. This forces anyone to define a tests/_support/ directory which I find rather unconventional. However, my point is the class should not have a constant expression that relies on a conditionally defined constant.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value (without duplication)
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@neznaika0
Copy link
Contributor

Heh, I also discovered this the other day. I just created a local bootstrap.php . This also affects the project folder for configs. It's the same for the rector.

<?php
// utils/phpstan/phpstan-bootstrap.php

declare(strict_types=1);

defined('CONFIGPATH') || define('CONFIGPATH', realpath(__DIR__ . '/../../new_app/Config') . DIRECTORY_SEPARATOR);
defined('PUBLICPATH') || define('PUBLICPATH', realpath(__DIR__ . '/../../public') . DIRECTORY_SEPARATOR);

require __DIR__ . '/../../vendor/codeigniter4/codeigniter4/system/util_bootstrap.php';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants