Skip to content

Commit

Permalink
Merge pull request #11081 from issidorov/regression-tests-with-undefi…
Browse files Browse the repository at this point in the history
…ned-mixin
  • Loading branch information
weirdan authored Sep 8, 2024
2 parents 8b528ad + 0b83d3f commit 4787eaf
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,7 @@ private static function analyzeAtomicAssignment(
* If we have an explicit list of all allowed magic properties on the class, and we're
* not in that list, fall through
*/
if (!$var_id || !$class_storage->hasSealedProperties($codebase->config)) {
if (!$class_storage->hasSealedProperties($codebase->config)) {
if (!$context->collect_initializations && !$context->collect_mutations) {
self::taintProperty(
$statements_analyzer,
Expand Down
62 changes: 62 additions & 0 deletions tests/MixinAnnotationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,21 @@ class A {}
(new A)->foo;',
'error_message' => 'UndefinedPropertyFetch',
],
'undefinedMixinClassWithPropertyFetch_WithMagicMethod' => [
'code' => '<?php
/**
* @property string $baz
* @mixin B
*/
class A {
public function __get(string $name): string {
return "";
}
}
(new A)->foo;',
'error_message' => 'UndefinedMagicPropertyFetch',
],
'undefinedMixinClassWithPropertyAssignment' => [
'code' => '<?php
/** @mixin B */
Expand All @@ -624,6 +639,19 @@ class A {}
(new A)->foo = "bar";',
'error_message' => 'UndefinedPropertyAssignment',
],
'undefinedMixinClassWithPropertyAssignment_WithMagicMethod' => [
'code' => '<?php
/**
* @property string $baz
* @mixin B
*/
class A {
public function __set(string $name, string $value) {}
}
(new A)->foo = "bar";',
'error_message' => 'UndefinedMagicPropertyAssignment',
],
'undefinedMixinClassWithMethodCall' => [
'code' => '<?php
/** @mixin B */
Expand All @@ -632,6 +660,40 @@ class A {}
(new A)->foo();',
'error_message' => 'UndefinedMethod',
],
'undefinedMixinClassWithMethodCall_WithMagicMethod' => [
'code' => '<?php
/**
* @method baz()
* @mixin B
*/
class A {
public function __call(string $name, array $arguments) {}
}
(new A)->foo();',
'error_message' => 'UndefinedMagicMethod',
],
'undefinedMixinClassWithStaticMethodCall' => [
'code' => '<?php
/** @mixin B */
class A {}
A::foo();',
'error_message' => 'UndefinedMethod',
],
'undefinedMixinClassWithStaticMethodCall_WithMagicMethod' => [
'code' => '<?php
/**
* @method baz()
* @mixin B
*/
class A {
public static function __callStatic(string $name, array $arguments) {}
}
A::foo();',
'error_message' => 'UndefinedMagicMethod',
],
'inheritTemplatedMixinWithSelf' => [
'code' => '<?php
/**
Expand Down

0 comments on commit 4787eaf

Please sign in to comment.