+
Skip to content

Check array_diff arguments #11141

@pableu

Description

@pableu

Feature request

This code is invalid in PHP 8.3 and PHPStan does not detect the problem:

<?php declare(strict_types = 1);

enum Language: string
{
	case ENG = 'eng';
	case FRE = 'fre';
	case GER = 'ger';
	case ITA = 'ita';
	case SPA = 'spa';
	case DUT = 'dut';
	case DAN = 'dan';
}

$langs = [
	Language::ENG, 
	Language::GER,
	Language::DAN,
];

$result = array_diff($langs, [Language::DAN]);

(see https://phpstan.org/r/e1eb2d34-a57d-4e3e-b775-d6beca79ff39)

None of the arguments of array_diff may contain arrays of enums.

Somewhat similar to #11111.

Did PHPStan help you today? Did it make you happy in any way?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载