Skip to content

lowercase-string not correct in templates #12739

@alf4712

Description

@alf4712

Bug report

<?php

declare(strict_types = 1);

/**
* @template TScalar of scalar
*/
abstract class ScalarType {
	/**
     * @return class-string<ScalarType<TScalar>>
     */
    abstract public static function getClassIdentify() : string;
}

/**
* @extends ScalarType<int>
*/
class MyInt extends ScalarType {
	public static function getClassIdentify() : string {
		return MyInt::class;
	}
}

/**
* @extends ScalarType<string>
*/
class MyString extends ScalarType {
	public static function getClassIdentify() : string {
		return MyString::class;
	}
}

/**
* @extends ScalarType<lowercase-string>
*/
class MyLowerString extends ScalarType {
	public static function getClassIdentify() : string {
		return MyLowerString::class;
	}
}

/**
* @extends ScalarType<class-string>
*/
class MyClassString extends ScalarType {
	public static function getClassIdentify() : string {
		return MyClassString::class;
	}
}

Image

Image

Like class-string it should work for lowercase-string.

Code snippet that reproduces the problem

https://phpstan.org/r/65c1fbbb-16e8-468c-beeb-ec5374580347

Expected output

No errors.

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

PHPStan is one of the best tools I ever seen.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions