vimeo/psalm

UndefinedConstant for every PHP Consts

Open

#9.142 aberto em 19 de jan. de 2023

Ver no GitHub
 (13 comments) (0 reactions) (0 assignees)PHP (668 forks)batch import
Help wantedbuggood first issueinternal stubs/callmap

Métricas do repositório

Stars
 (5.369 stars)
Métricas de merge de PR
 (Mesclagem média 3d 12h) (5 fundiu PRs em 30d)

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:

Guia do colaborador