1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 12:55:26 +01:00

Merge pull request #8465 from kkmuffme/invalid-class-casing-for-native-and-stubbed-classes

report invalidCasing when using a class that is not user defined too
This commit is contained in:
orklah 2022-09-08 19:59:00 +02:00 committed by GitHub
commit 6374a9637e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 16 additions and 27 deletions

View File

@ -6,7 +6,7 @@ use Composer\Autoload\ClassLoader;
use Composer\Semver\Constraint\Constraint;
use Composer\Semver\VersionParser;
use DOMDocument;
use DomElement;
use DOMElement;
use InvalidArgumentException;
use LogicException;
use OutOfBoundsException;
@ -752,7 +752,6 @@ class Config
$psalm_nodes = $dom_document->getElementsByTagName('psalm');
/** @var DomElement|null */
$psalm_node = $psalm_nodes->item(0);
if (!$psalm_node) {

View File

@ -361,7 +361,6 @@ abstract class ClassLikeAnalyzer extends SourceAnalyzer
|| ($interface_exists && !$codebase->interfaceHasCorrectCasing($fq_class_name))
|| ($enum_exists && !$codebase->classlikes->enumHasCorrectCasing($fq_class_name))
) {
if ($codebase->classlikes->isUserDefined(strtolower($aliased_name))) {
IssueBuffer::maybeAdd(
new InvalidClass(
'Class, interface or enum ' . $fq_class_name . ' has wrong casing',
@ -372,7 +371,6 @@ abstract class ClassLikeAnalyzer extends SourceAnalyzer
);
}
}
}
if (!$options->inferred) {
$event = new AfterClassLikeExistenceCheckEvent(

View File

@ -784,14 +784,6 @@ class ClassLikes
return isset($this->existing_traits[$fq_trait_name]);
}
/**
* @param lowercase-string $fq_class_name
*/
public function isUserDefined(string $fq_class_name): bool
{
return $this->classlike_storage_provider->get($fq_class_name)->user_defined;
}
public function getTraitNode(string $fq_trait_name): PhpParser\Node\Stmt\Trait_
{
$fq_trait_name_lc = strtolower($fq_trait_name);

View File

@ -3,7 +3,7 @@
namespace Psalm\Internal\PluginManager;
use DOMDocument;
use DomElement;
use DOMElement;
use Psalm\Config;
use RuntimeException;
@ -51,7 +51,7 @@ class ConfigFile
public function removePlugin(string $plugin_class): void
{
$config_xml = $this->readXml();
/** @var DomElement */
/** @var DOMElement */
$psalm_root = $config_xml->getElementsByTagName('psalm')[0];
$plugins_elements = $psalm_root->getElementsByTagName('plugins');
if (!$plugins_elements->length) {
@ -59,7 +59,7 @@ class ConfigFile
return;
}
/** @var DomElement */
/** @var DOMElement */
$plugins_element = $plugins_elements->item(0);
$plugin_elements = $plugins_element->getElementsByTagName('pluginClass');
@ -82,7 +82,7 @@ class ConfigFile
public function addPlugin(string $plugin_class): void
{
$config_xml = $this->readXml();
/** @var DomElement */
/** @var DOMElement */
$psalm_root = $config_xml->getElementsByTagName('psalm')->item(0);
$plugins_elements = $psalm_root->getElementsByTagName('plugins');
if (!$plugins_elements->length) {
@ -91,7 +91,7 @@ class ConfigFile
$psalm_root->appendChild($plugins_element);
}
} else {
/** @var DomElement */
/** @var DOMElement */
$plugins_element = $plugins_elements->item(0);
}

View File

@ -687,7 +687,7 @@ class IntRangeTest extends TestCase
/** @var string $secret */
$length = strlen($secret);
if ($length > 16) {
throw new exception("");
throw new Exception("");
}
assert($length === 1);

View File

@ -979,7 +979,7 @@ class MethodCallTest extends TestCase
class Datetime extends \DateTime
{
public static function createFromInterface(\DatetimeInterface $datetime): \DateTime
public static function createFromInterface(\DateTimeInterface $datetime): \DateTime
{
return parent::createFromInterface($datetime);
}