vimeo/psalm

UndefinedConstant for every PHP Consts

Open

#9 142 ouverte le 19 janv. 2023

Voir sur GitHub
 (13 commentaires) (0 réactions) (0 assignés)PHP (668 forks)batch import
Help wantedbuggood first issueinternal stubs/callmap

Métriques du dépôt

Stars
 (5 369 stars)
Métriques de merge PR
 (Merge moyen 3j 12h) (5 PRs mergées en 30 j)

Description

Every usage of PHP SPL constants causes an UndefinedConstant-ERROR in Psalm.

Example

curl_setopt_array($curl, [
				CURLOPT_URL				=> 'https://HIDDEN',
				CURLOPT_RETURNTRANSFER	=> true,
				CURLOPT_ENCODING		=> '',
				CURLOPT_MAXREDIRS		=> 10,
				CURLOPT_TIMEOUT			=> 30,
				CURLOPT_HTTP_VERSION	=> CURL_HTTP_VERSION_1_1,
				CURLOPT_CUSTOMREQUEST	=> 'POST',
				CURLOPT_POSTFIELDS		=> '{HIDDEN}',
		]);

causes

ERROR: UndefinedConstant - src/models/HIDDEN.php:59:5 - Const CURLOPT_URL is not defined (see https://psalm.dev/020) CURLOPT_URL => 'https://HIDDEN',

ERROR: UndefinedConstant - src/models/HIDDEN.php:60:5 - Const CURLOPT_RETURNTRANSFER is not defined (see https://psalm.dev/020) CURLOPT_RETURNTRANSFER => true,

Discussion

These constants are officially maintained by PHP. For OpenSSL, I did not even actively enable it in my PHP.ini, which uses mostly default settings. For LDAP I can understand the missing support, because it needs to be enabled manually. But even when I try to enable e.g. ldap in my Psalm-configuration via , I get an error ("[...]The value 'ldap' is not an element of the set[...]").

Setup

Psalm: Version 5.4.0 PHP: 8.2.1 (Modules: bcmath, calendar, Core, ctype, date, dom, filter, hash, iconv, json, libxml, mbstring, mysqli, mysqlnd, odbc, pcre, PDO, Phar, random, readline, Reflection, session, SimpleXML, SPL, standard, tokenizer, xml, xmlreader, xmlwriter, zlib)

Others

Other constants, which cause an ERROR:

Guide contributeur