File tree Expand file tree Collapse file tree 3 files changed +65
-0
lines changed
src/Psalm/Internal/Codebase Expand file tree Collapse file tree 3 files changed +65
-0
lines changed Original file line number Diff line number Diff line change @@ -603,6 +603,12 @@ private function populateInterfaceData(
603
603
);
604
604
$ new_parent_interface_storage = $ storage_provider ->get ($ new_parent );
605
605
} catch (InvalidArgumentException ) {
606
+ $ this ->progress ->debug ('Populator could not find dependency ( ' . __LINE__ . ") \n" );
607
+
608
+ $ storage ->invalid_dependencies [$ new_parent ] = true ;
609
+
610
+ $ this ->invalid_class_storages [$ new_parent ][] = $ storage ;
611
+
606
612
continue ;
607
613
}
608
614
@@ -686,6 +692,9 @@ private function populateInterfaceDataFromParentInterface(
686
692
$ this ->progress ->debug ('Populator could not find dependency ( ' . __LINE__ . ") \n" );
687
693
688
694
$ storage ->invalid_dependencies [$ parent_interface_lc ] = true ;
695
+
696
+ $ this ->invalid_class_storages [$ parent_interface_lc ][] = $ storage ;
697
+
689
698
return ;
690
699
}
691
700
@@ -729,6 +738,9 @@ private function populateDataFromImplementedInterface(
729
738
$ this ->progress ->debug ('Populator could not find dependency ( ' . __LINE__ . ") \n" );
730
739
731
740
$ storage ->invalid_dependencies [$ implemented_interface_lc ] = true ;
741
+
742
+ $ this ->invalid_class_storages [$ implemented_interface_lc ][] = $ storage ;
743
+
732
744
return ;
733
745
}
734
746
Original file line number Diff line number Diff line change @@ -1202,6 +1202,49 @@ public function run(): float {
1202
1202
$ this ->analyzeFile ($ file_path , new Context ());
1203
1203
}
1204
1204
1205
+ public function testUseOnlyStubbedInterface (): void
1206
+ {
1207
+ $ this ->project_analyzer = $ this ->getProjectAnalyzerWithConfig (
1208
+ TestConfig::loadFromXML (
1209
+ dirname (__DIR__ ),
1210
+ '<?xml version="1.0"?>
1211
+ <psalm
1212
+ errorLevel="1"
1213
+ >
1214
+ <projectFiles>
1215
+ <directory name="src" />
1216
+ </projectFiles>
1217
+
1218
+ <stubs>
1219
+ <file name="tests/fixtures/stubs/interface.phpstub" />
1220
+ </stubs>
1221
+ </psalm> ' ,
1222
+ ),
1223
+ );
1224
+
1225
+ $ file_path = (string ) getcwd () . '/src/somefile.php ' ;
1226
+
1227
+ $ this ->addFile (
1228
+ $ file_path ,
1229
+ '<?php
1230
+ namespace Foo;
1231
+
1232
+ class A implements StubbedInterface {
1233
+ /**
1234
+ * @param int $x
1235
+ */
1236
+ public function run_stubbed($x): float {
1237
+ return $x . "";
1238
+ }
1239
+ } ' ,
1240
+ );
1241
+
1242
+ $ this ->expectExceptionMessage ('InvalidReturnType ' );
1243
+ $ this ->expectException (CodeException::class);
1244
+
1245
+ $ this ->analyzeFile ($ file_path , new Context ());
1246
+ }
1247
+
1205
1248
public function testStubFileWithExtendedStubbedClass (): void
1206
1249
{
1207
1250
$ this ->project_analyzer = $ this ->getProjectAnalyzerWithConfig (
Original file line number Diff line number Diff line change
1
+ <?php
2
+ namespace Foo;
3
+
4
+ interface StubbedInterface
5
+ {
6
+ /**
7
+ * @param int $x
8
+ */
9
+ public function run_stubbed($x): float;
10
+ }
You can’t perform that action at this time.
0 commit comments