diff --git a/packages/CodeQuality/src/Rector/For_/ForToForeachRector.php b/packages/CodeQuality/src/Rector/For_/ForToForeachRector.php index 159ee022aa60..ec1e82eb71a8 100644 --- a/packages/CodeQuality/src/Rector/For_/ForToForeachRector.php +++ b/packages/CodeQuality/src/Rector/For_/ForToForeachRector.php @@ -243,7 +243,7 @@ private function isSmallerOrGreater(array $condExprs, string $keyValueName, stri private function useForeachVariableInStmts(Expr $expr, array $stmts): void { if ($this->keyValueName === null) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } $this->traverseNodesWithCallable($stmts, function (Node $node) use ($expr): ?Expr { diff --git a/packages/CodingStyle/src/Naming/ClassNaming.php b/packages/CodingStyle/src/Naming/ClassNaming.php index d662754a1e35..e85a54b88f33 100644 --- a/packages/CodingStyle/src/Naming/ClassNaming.php +++ b/packages/CodingStyle/src/Naming/ClassNaming.php @@ -28,7 +28,7 @@ public function getShortName($name): string if ($name instanceof Name) { $name = $this->nameResolver->getName($name); if ($name === null) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } } diff --git a/packages/CodingStyle/src/Rector/ClassMethod/ReturnArrayClassMethodToYieldRector.php b/packages/CodingStyle/src/Rector/ClassMethod/ReturnArrayClassMethodToYieldRector.php index 49ea9530499b..a1cb4bfb3e71 100644 --- a/packages/CodingStyle/src/Rector/ClassMethod/ReturnArrayClassMethodToYieldRector.php +++ b/packages/CodingStyle/src/Rector/ClassMethod/ReturnArrayClassMethodToYieldRector.php @@ -140,7 +140,7 @@ private function transformArrayToYieldsOnMethodNode(ClassMethod $classMethod, Ar // remove whole return node $parentNode = $arrayNode->getAttribute(AttributeKey::PARENT_NODE); if ($parentNode === null) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } $this->removeNode($parentNode); diff --git a/packages/CodingStyle/src/Rector/Use_/RemoveUnusedAliasRector.php b/packages/CodingStyle/src/Rector/Use_/RemoveUnusedAliasRector.php index 72e1563ea11f..70b9dd53c783 100644 --- a/packages/CodingStyle/src/Rector/Use_/RemoveUnusedAliasRector.php +++ b/packages/CodingStyle/src/Rector/Use_/RemoveUnusedAliasRector.php @@ -263,7 +263,7 @@ private function resolveUsedNames(Node $searchNode): void $parentNode = $nameNode->getAttribute(AttributeKey::PARENT_NODE); if ($parentNode === null) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } $this->resolvedNodeNames[$originalName->toString()][] = [$nameNode, $parentNode]; diff --git a/packages/DeadCode/src/Data/VariableNodeUseInfo.php b/packages/DeadCode/src/Data/VariableNodeUseInfo.php index 480ca9c7f8c7..8fd08cb01036 100644 --- a/packages/DeadCode/src/Data/VariableNodeUseInfo.php +++ b/packages/DeadCode/src/Data/VariableNodeUseInfo.php @@ -82,7 +82,7 @@ public function getParentNode(): Node { $parentNode = $this->variable->getAttribute(AttributeKey::PARENT_NODE); if ($parentNode === null) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } return $parentNode; diff --git a/packages/DeadCode/src/Doctrine/DoctrineEntityManipulator.php b/packages/DeadCode/src/Doctrine/DoctrineEntityManipulator.php index 9447ecb1433d..ad4cff60f101 100644 --- a/packages/DeadCode/src/Doctrine/DoctrineEntityManipulator.php +++ b/packages/DeadCode/src/Doctrine/DoctrineEntityManipulator.php @@ -84,7 +84,7 @@ public function resolveTargetClass(Property $property): ?string $relationTag = $this->docBlockManipulator->getTagByName($property, $relationAnnotation); if (! $relationTag->value instanceof GenericTagValueNode) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } $match = Strings::match($relationTag->value->value, self::TARGET_ENTITY_PATTERN); @@ -118,7 +118,7 @@ public function resolveOtherProperty(Property $property): ?string $relationTag = $this->docBlockManipulator->getTagByName($property, $relationAnnotation); if (! $relationTag->value instanceof GenericTagValueNode) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } $match = Strings::match($relationTag->value->value, self::TARGET_PROPERTY_PATTERN); diff --git a/packages/Laravel/src/Rector/FuncCall/HelperFunctionToConstructorInjectionRector.php b/packages/Laravel/src/Rector/FuncCall/HelperFunctionToConstructorInjectionRector.php index d8714886ef8b..859fb24d05a7 100644 --- a/packages/Laravel/src/Rector/FuncCall/HelperFunctionToConstructorInjectionRector.php +++ b/packages/Laravel/src/Rector/FuncCall/HelperFunctionToConstructorInjectionRector.php @@ -252,7 +252,7 @@ public function refactor(Node $node): ?Node return new MethodCall($propertyFetchNode, $service['non_array_method'], $node->args); } - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } return null; diff --git a/packages/MysqlToMysqli/src/Rector/Assign/MysqlAssignToMysqliRector.php b/packages/MysqlToMysqli/src/Rector/Assign/MysqlAssignToMysqliRector.php index 1835c9eb1cd4..e276e5871e0c 100644 --- a/packages/MysqlToMysqli/src/Rector/Assign/MysqlAssignToMysqliRector.php +++ b/packages/MysqlToMysqli/src/Rector/Assign/MysqlAssignToMysqliRector.php @@ -153,7 +153,7 @@ private function processMysqlFetchField(Assign $assign, FuncCall $funcCall): Ass $previousExpression = $assign->getAttribute(AttributeKey::PREVIOUS_EXPRESSION); if ($previousExpression === null) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } $this->addNodeAfterNode($forNode, $previousExpression); diff --git a/packages/NodeTypeResolver/src/ComplexNodeTypeResolver.php b/packages/NodeTypeResolver/src/ComplexNodeTypeResolver.php index e2a7b97a4a67..6f6ef90cc6b2 100644 --- a/packages/NodeTypeResolver/src/ComplexNodeTypeResolver.php +++ b/packages/NodeTypeResolver/src/ComplexNodeTypeResolver.php @@ -70,7 +70,7 @@ public function resolvePropertyTypeInfo(Property $property): ?VarTypeInfo $classNode = $property->getAttribute(AttributeKey::CLASS_NODE); if (! $classNode instanceof Class_) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } $propertyName = $this->nameResolver->getName($property); diff --git a/packages/NodeTypeResolver/src/PHPStan/Scope/NodeScopeResolver.php b/packages/NodeTypeResolver/src/PHPStan/Scope/NodeScopeResolver.php index 0bcbce38a9d5..c26453e3e981 100644 --- a/packages/NodeTypeResolver/src/PHPStan/Scope/NodeScopeResolver.php +++ b/packages/NodeTypeResolver/src/PHPStan/Scope/NodeScopeResolver.php @@ -126,7 +126,7 @@ private function resolveClassName(ClassLike $classOrInterfaceNode): string } if ($classOrInterfaceNode->name === null) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } return $classOrInterfaceNode->name->toString(); diff --git a/packages/NodeTypeResolver/src/PerNodeTypeResolver/NameTypeResolver.php b/packages/NodeTypeResolver/src/PerNodeTypeResolver/NameTypeResolver.php index f7680755f7d1..9fdf45d375c1 100644 --- a/packages/NodeTypeResolver/src/PerNodeTypeResolver/NameTypeResolver.php +++ b/packages/NodeTypeResolver/src/PerNodeTypeResolver/NameTypeResolver.php @@ -48,7 +48,7 @@ private function resolveFullyQualifiedName(Node $nameNode, string $name): string /** @var string|null $class */ $class = $nameNode->getAttribute(AttributeKey::CLASS_NAME); if ($class === null) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } return $class; @@ -59,7 +59,7 @@ private function resolveFullyQualifiedName(Node $nameNode, string $name): string /** @var string|null $class */ $class = $nameNode->getAttribute(AttributeKey::PARENT_CLASS_NAME); if ($class === null) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } return $class; diff --git a/packages/NodeTypeResolver/src/Php/AbstractTypeInfo.php b/packages/NodeTypeResolver/src/Php/AbstractTypeInfo.php index 5eadefb8c623..81a73854b2c2 100644 --- a/packages/NodeTypeResolver/src/Php/AbstractTypeInfo.php +++ b/packages/NodeTypeResolver/src/Php/AbstractTypeInfo.php @@ -94,7 +94,7 @@ public function getTypeNode(bool $forceFqn = false) $type = $this->resolveTypeForTypehint($forceFqn); if ($type === null) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } // normalize for type-declaration diff --git a/packages/Php/src/Rector/Assign/MysqlAssignToMysqliRector.php b/packages/Php/src/Rector/Assign/MysqlAssignToMysqliRector.php index a0f8cbcd8a24..22dccba27559 100644 --- a/packages/Php/src/Rector/Assign/MysqlAssignToMysqliRector.php +++ b/packages/Php/src/Rector/Assign/MysqlAssignToMysqliRector.php @@ -153,7 +153,7 @@ private function processMysqlFetchField(Assign $assign, FuncCall $funcCall): Ass $previousExpression = $assign->getAttribute(AttributeKey::PREVIOUS_EXPRESSION); if ($previousExpression === null) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } $this->addNodeAfterNode($forNode, $previousExpression); diff --git a/packages/Php/src/Rector/ConstFetch/BarewordStringRector.php b/packages/Php/src/Rector/ConstFetch/BarewordStringRector.php index 24cc48f746e2..b5b68f6a20f5 100644 --- a/packages/Php/src/Rector/ConstFetch/BarewordStringRector.php +++ b/packages/Php/src/Rector/ConstFetch/BarewordStringRector.php @@ -51,7 +51,7 @@ public function refactor(Node $node): ?Node // load the file! $fileInfo = $node->getAttribute(AttributeKey::FILE_INFO); if ($fileInfo === null) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } $this->undefinedConstants = []; diff --git a/packages/Php/src/Rector/FuncCall/PregReplaceEModifierRector.php b/packages/Php/src/Rector/FuncCall/PregReplaceEModifierRector.php index 86d0ca13e3f7..c29085f194e3 100644 --- a/packages/Php/src/Rector/FuncCall/PregReplaceEModifierRector.php +++ b/packages/Php/src/Rector/FuncCall/PregReplaceEModifierRector.php @@ -110,7 +110,7 @@ private function createAnonymousFunctionFromString(Expr $expr): ?Closure { if (! $expr instanceof String_) { // not supported yet - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } $phpCode = 'value . ';'; diff --git a/packages/PhpSpecToPHPUnit/src/Naming/PhpSpecRenaming.php b/packages/PhpSpecToPHPUnit/src/Naming/PhpSpecRenaming.php index 0b4283b543a2..2ebbd09952a5 100644 --- a/packages/PhpSpecToPHPUnit/src/Naming/PhpSpecRenaming.php +++ b/packages/PhpSpecToPHPUnit/src/Naming/PhpSpecRenaming.php @@ -80,7 +80,7 @@ public function renameClass(Class_ $class): void { // anonymous class? if ($class->name === null) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } // 2. change class name @@ -94,7 +94,7 @@ public function resolveObjectPropertyName(Class_ $class): string { // anonymous class? if ($class->name === null) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } $bareClassName = RectorStrings::removeSuffixes($class->name->toString(), ['Spec', 'Test']); diff --git a/packages/PhpSpecToPHPUnit/src/PhpSpecMockCollector.php b/packages/PhpSpecToPHPUnit/src/PhpSpecMockCollector.php index a6b39bdffc41..2c5c2334b16c 100644 --- a/packages/PhpSpecToPHPUnit/src/PhpSpecMockCollector.php +++ b/packages/PhpSpecToPHPUnit/src/PhpSpecMockCollector.php @@ -91,7 +91,7 @@ public function getTypeForClassAndVariable(Class_ $node, string $variable): stri $className = $this->nameResolver->getName($node); if (! isset($this->mocksWithsTypes[$className][$variable])) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } return $this->mocksWithsTypes[$className][$variable]; @@ -112,7 +112,7 @@ private function addMockFromParam(Param $param): void $this->mocks[$class][$variable][] = $param->getAttribute(AttributeKey::METHOD_NAME); if ($param->type === null) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } $paramType = (string) ($param->type->getAttribute('originalName') ?: $param->type); diff --git a/packages/PhpSpecToPHPUnit/src/Rector/MethodCall/PhpSpecMocksToPHPUnitMocksRector.php b/packages/PhpSpecToPHPUnit/src/Rector/MethodCall/PhpSpecMocksToPHPUnitMocksRector.php index ba0436567fe3..90083fd94c39 100644 --- a/packages/PhpSpecToPHPUnit/src/Rector/MethodCall/PhpSpecMocksToPHPUnitMocksRector.php +++ b/packages/PhpSpecToPHPUnit/src/Rector/MethodCall/PhpSpecMocksToPHPUnitMocksRector.php @@ -110,7 +110,7 @@ private function createMockVarDoc(Param $param, Name $name): string $variableName = $this->getName($param->var); if ($variableName === null) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } return sprintf( @@ -127,7 +127,7 @@ private function processMethodParamsToMocks(ClassMethod $classMethod): void $assigns = []; foreach ((array) $classMethod->params as $param) { if (! $param->type instanceof Name) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } $createMockCall = $this->createCreateMockCall($param, $param->type); @@ -146,12 +146,12 @@ private function processMethodCall(MethodCall $methodCall): ?MethodCall { if ($this->isName($methodCall, 'shouldBeCalled')) { if (! $methodCall->var instanceof MethodCall) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } $mockMethodName = $this->getName($methodCall->var); if ($mockMethodName === null) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } $expectedArg = $methodCall->var->args[0]->value ?? null; @@ -218,7 +218,7 @@ private function createPropertyFetchMockVariableAssign(Param $param, Name $name) { $variable = $this->getName($param->var); if ($variable === null) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } $propertyFetch = new PropertyFetch(new Variable('this'), $variable); diff --git a/packages/PhpSpecToPHPUnit/src/Rector/MethodCall/PhpSpecPromisesToPHPUnitAssertRector.php b/packages/PhpSpecToPHPUnit/src/Rector/MethodCall/PhpSpecPromisesToPHPUnitAssertRector.php index dc9323dd92f5..816a5e0fe626 100644 --- a/packages/PhpSpecToPHPUnit/src/Rector/MethodCall/PhpSpecPromisesToPHPUnitAssertRector.php +++ b/packages/PhpSpecToPHPUnit/src/Rector/MethodCall/PhpSpecPromisesToPHPUnitAssertRector.php @@ -354,7 +354,7 @@ private function prepare(Node $node): void private function processDuring(MethodCall $methodCall): MethodCall { if (! isset($methodCall->args[0])) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } $name = $this->getValue($methodCall->args[0]->value); diff --git a/packages/RemovingStatic/src/Printer/FactoryClassPrinter.php b/packages/RemovingStatic/src/Printer/FactoryClassPrinter.php index 2acb23e7b342..eb56aeead54b 100644 --- a/packages/RemovingStatic/src/Printer/FactoryClassPrinter.php +++ b/packages/RemovingStatic/src/Printer/FactoryClassPrinter.php @@ -73,13 +73,13 @@ private function createFactoryClassFilePath(Class_ $oldClass): string /** @var SmartFileInfo|null $classFileInfo */ $classFileInfo = $oldClass->getAttribute(AttributeKey::FILE_INFO); if ($classFileInfo === null) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } $directoryPath = Strings::before($classFileInfo->getRealPath(), DIRECTORY_SEPARATOR, -1); $resolvedOldClass = $this->nameResolver->getName($oldClass); if ($resolvedOldClass === null) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } $bareClassName = Strings::after($resolvedOldClass, '\\', -1) . 'Factory.php'; diff --git a/packages/RemovingStatic/src/Rector/Class_/NewUniqueObjectToEntityFactoryRector.php b/packages/RemovingStatic/src/Rector/Class_/NewUniqueObjectToEntityFactoryRector.php index 07204ae431b8..e0662c90204e 100644 --- a/packages/RemovingStatic/src/Rector/Class_/NewUniqueObjectToEntityFactoryRector.php +++ b/packages/RemovingStatic/src/Rector/Class_/NewUniqueObjectToEntityFactoryRector.php @@ -188,7 +188,7 @@ private function resolveClassesUsingTypes(): array if ($hasTypes) { $name = $this->getName($class); if ($name === null) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } $this->classesUsingTypes[] = $name; } diff --git a/packages/RemovingStatic/src/UniqueObjectFactoryFactory.php b/packages/RemovingStatic/src/UniqueObjectFactoryFactory.php index 0d8b5b3b5a01..bf6d354c646d 100644 --- a/packages/RemovingStatic/src/UniqueObjectFactoryFactory.php +++ b/packages/RemovingStatic/src/UniqueObjectFactoryFactory.php @@ -77,7 +77,7 @@ public function createFactoryClass(Class_ $class, array $staticTypesInClass): Cl $factoryClassBuilder->addStmt($constructMethod); if ($className === null) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } // create diff --git a/packages/Sensio/src/Helper/TemplateGuesser.php b/packages/Sensio/src/Helper/TemplateGuesser.php index 4159b04716b7..92b3f226fbf5 100644 --- a/packages/Sensio/src/Helper/TemplateGuesser.php +++ b/packages/Sensio/src/Helper/TemplateGuesser.php @@ -24,17 +24,17 @@ public function resolveFromClassMethodNode(ClassMethod $classMethod, int $versio { $namespace = $classMethod->getAttribute(AttributeKey::NAMESPACE_NAME); if (! is_string($namespace)) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } $class = $classMethod->getAttribute(AttributeKey::CLASS_NAME); if (! is_string($class)) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } $method = $this->nameResolver->getName($classMethod); if ($method === null) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } if ($version === 3) { diff --git a/packages/Symfony/src/Rector/FrameworkBundle/AbstractToConstructorInjectionRector.php b/packages/Symfony/src/Rector/FrameworkBundle/AbstractToConstructorInjectionRector.php index 974aa4e43370..dcc6f39abe43 100644 --- a/packages/Symfony/src/Rector/FrameworkBundle/AbstractToConstructorInjectionRector.php +++ b/packages/Symfony/src/Rector/FrameworkBundle/AbstractToConstructorInjectionRector.php @@ -47,7 +47,7 @@ protected function processMethodCallNode(MethodCall $methodCall): ?Node $propertyName = $this->propertyNaming->fqnToVariableName($serviceType); $classNode = $methodCall->getAttribute(AttributeKey::CLASS_NODE); if (! $classNode instanceof Class_) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } $this->addPropertyToClass($classNode, $serviceType, $propertyName); diff --git a/packages/Symfony/src/Rector/Yaml/ParseFileRector.php b/packages/Symfony/src/Rector/Yaml/ParseFileRector.php index c13c74ef8410..50a40780b565 100644 --- a/packages/Symfony/src/Rector/Yaml/ParseFileRector.php +++ b/packages/Symfony/src/Rector/Yaml/ParseFileRector.php @@ -75,7 +75,7 @@ private function isArgumentYamlFile(StaticCall $staticCall): bool // try to detect current value $nodeScope = $possibleFileNode->getAttribute(AttributeKey::SCOPE); if ($nodeScope === null) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } $nodeType = $nodeScope->getType($possibleFileNode); diff --git a/packages/TypeDeclaration/src/PhpDocParser/ParamPhpDocNodeFactory.php b/packages/TypeDeclaration/src/PhpDocParser/ParamPhpDocNodeFactory.php index bb003d9d24a0..0d2de5ef4f78 100644 --- a/packages/TypeDeclaration/src/PhpDocParser/ParamPhpDocNodeFactory.php +++ b/packages/TypeDeclaration/src/PhpDocParser/ParamPhpDocNodeFactory.php @@ -38,7 +38,7 @@ public function create(array $types, Param $param): AttributeAwarePhpDocTagNode } elseif (count($types) === 1) { $typeNode = new IdentifierTypeNode($types[0]); } else { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } $arrayTypeNode = new ArrayTypeNode($typeNode); diff --git a/packages/TypeDeclaration/src/Rector/FunctionLike/AbstractTypeDeclarationRector.php b/packages/TypeDeclaration/src/Rector/FunctionLike/AbstractTypeDeclarationRector.php index 16410cc3c5e7..2153b8163ab8 100644 --- a/packages/TypeDeclaration/src/Rector/FunctionLike/AbstractTypeDeclarationRector.php +++ b/packages/TypeDeclaration/src/Rector/FunctionLike/AbstractTypeDeclarationRector.php @@ -184,7 +184,7 @@ protected function resolveChildType( if ($nakedType->toString() === 'self') { $className = $node->getAttribute(AttributeKey::CLASS_NAME); if ($className === null) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } $type = new FullyQualified($className); @@ -195,7 +195,7 @@ protected function resolveChildType( if ($nakedType->toString() === 'parent') { $parentClassName = $node->getAttribute(AttributeKey::PARENT_CLASS_NAME); if ($parentClassName === null) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } $type = new FullyQualified($parentClassName); diff --git a/packages/TypeDeclaration/src/Rector/FunctionLike/ReturnTypeDeclarationRector.php b/packages/TypeDeclaration/src/Rector/FunctionLike/ReturnTypeDeclarationRector.php index 24b3d8e679ee..b30ae7b6891d 100644 --- a/packages/TypeDeclaration/src/Rector/FunctionLike/ReturnTypeDeclarationRector.php +++ b/packages/TypeDeclaration/src/Rector/FunctionLike/ReturnTypeDeclarationRector.php @@ -145,12 +145,12 @@ private function populateChildren(Node $node, ReturnTypeInfo $returnTypeInfo): v $methodName = $this->getName($node); if ($methodName === null) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } $className = $node->getAttribute(AttributeKey::CLASS_NAME); if (! is_string($className)) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } $childrenClassLikes = $this->parsedNodesByType->findClassesAndInterfacesByType($className); diff --git a/src/NodeContainer/ParsedNodesByType.php b/src/NodeContainer/ParsedNodesByType.php index 1a6fb9b384b0..fb5b08e6152b 100644 --- a/src/NodeContainer/ParsedNodesByType.php +++ b/src/NodeContainer/ParsedNodesByType.php @@ -367,7 +367,7 @@ public function collect(Node $node): void if ($node instanceof Interface_ || $node instanceof Trait_ || $node instanceof Function_) { $name = $this->nameResolver->getName($node); if ($name === null) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } $nodeClass = get_class($node); @@ -465,7 +465,7 @@ private function addClass(Class_ $classNode): void $name = $classNode->getAttribute(AttributeKey::CLASS_NAME); if ($name === null) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } $this->classes[$name] = $classNode; @@ -475,7 +475,7 @@ private function addClassConstant(ClassConst $classConst): void { $className = $classConst->getAttribute(AttributeKey::CLASS_NAME); if ($className === null) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } $constantName = $this->nameResolver->getName($classConst); diff --git a/src/PhpParser/Node/Commander/NodeAddingCommander.php b/src/PhpParser/Node/Commander/NodeAddingCommander.php index dd94797a0a61..b9516dfc99cc 100644 --- a/src/PhpParser/Node/Commander/NodeAddingCommander.php +++ b/src/PhpParser/Node/Commander/NodeAddingCommander.php @@ -96,7 +96,7 @@ private function resolveNearestExpressionPosition(Node $node): string if ($parentNode instanceof ClassLike) { $foundNode = $node; } else { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } } diff --git a/src/PhpParser/Node/Manipulator/BinaryOpManipulator.php b/src/PhpParser/Node/Manipulator/BinaryOpManipulator.php index 9bf3356d725b..8477011555a7 100644 --- a/src/PhpParser/Node/Manipulator/BinaryOpManipulator.php +++ b/src/PhpParser/Node/Manipulator/BinaryOpManipulator.php @@ -51,7 +51,7 @@ private function validateCondition($firstCondition): void return; } - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } /** diff --git a/src/PhpParser/Node/Manipulator/ClassManipulator.php b/src/PhpParser/Node/Manipulator/ClassManipulator.php index aac57ae2e00e..6ea9eb8c128a 100644 --- a/src/PhpParser/Node/Manipulator/ClassManipulator.php +++ b/src/PhpParser/Node/Manipulator/ClassManipulator.php @@ -205,7 +205,7 @@ public function getProperty(Class_ $class, string $name): ?Property if (count($stmt->props) > 1) { // usually full property is needed to have all the docs values - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } if ($this->nameResolver->isName($stmt, $name)) { diff --git a/src/PhpParser/Node/Manipulator/ClassMethodManipulator.php b/src/PhpParser/Node/Manipulator/ClassMethodManipulator.php index 39b82c7e2087..145ff85fd8bc 100644 --- a/src/PhpParser/Node/Manipulator/ClassMethodManipulator.php +++ b/src/PhpParser/Node/Manipulator/ClassMethodManipulator.php @@ -170,7 +170,7 @@ public function addMethodParameterIfMissing(Node $node, string $type, array $pos $classMethodNode = $node->getAttribute(AttributeKey::METHOD_NODE); if (! $classMethodNode instanceof ClassMethod) { // or null? - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } foreach ($classMethodNode->params as $paramNode) { @@ -211,7 +211,7 @@ private function resolveName(ClassMethod $classMethod, array $possibleNames): st return $possibleName; } - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } /** diff --git a/src/PhpParser/Node/Manipulator/PropertyFetchManipulator.php b/src/PhpParser/Node/Manipulator/PropertyFetchManipulator.php index 439002113aed..b8654d0d3949 100644 --- a/src/PhpParser/Node/Manipulator/PropertyFetchManipulator.php +++ b/src/PhpParser/Node/Manipulator/PropertyFetchManipulator.php @@ -182,7 +182,7 @@ private function hasPublicProperty(PropertyFetch $propertyFetch, string $propert { $nodeScope = $propertyFetch->getAttribute(AttributeKey::SCOPE); if ($nodeScope === null) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } $propertyFetchType = $nodeScope->getType($propertyFetch->var); diff --git a/src/PhpParser/Node/Value/ValueResolver.php b/src/PhpParser/Node/Value/ValueResolver.php index 6703b92dfac8..dccac109bccd 100644 --- a/src/PhpParser/Node/Value/ValueResolver.php +++ b/src/PhpParser/Node/Value/ValueResolver.php @@ -114,7 +114,7 @@ private function resolveDirConstant(Dir $dir): string { $fileInfo = $dir->getAttribute(AttributeKey::FILE_INFO); if (! $fileInfo instanceof SmartFileInfo) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } return $fileInfo->getPath(); @@ -124,7 +124,7 @@ private function resolveFileConstant(File $file): string { $fileInfo = $file->getAttribute(AttributeKey::FILE_INFO); if (! $fileInfo instanceof SmartFileInfo) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } return $fileInfo->getPathname(); @@ -139,11 +139,11 @@ private function resolveClassConstFetch(ClassConstFetch $classConstFetch) $constant = $this->nameResolver->getName($classConstFetch->name); if ($class === null) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } if ($constant === null) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } if ($class === 'self') { diff --git a/src/Rector/Annotation/RenameAnnotationRector.php b/src/Rector/Annotation/RenameAnnotationRector.php index bb14500508f0..9031fae5ca1a 100644 --- a/src/Rector/Annotation/RenameAnnotationRector.php +++ b/src/Rector/Annotation/RenameAnnotationRector.php @@ -97,7 +97,7 @@ public function refactor(Node $node): ?Node $parentNode = $node->getAttribute(AttributeKey::PARENT_NODE); if ($parentNode === null) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } $parentNodeTypes = $this->getTypes($parentNode); diff --git a/src/Rector/MethodBody/FluentReplaceRector.php b/src/Rector/MethodBody/FluentReplaceRector.php index 40046867e268..29b8d7ce118d 100644 --- a/src/Rector/MethodBody/FluentReplaceRector.php +++ b/src/Rector/MethodBody/FluentReplaceRector.php @@ -132,7 +132,7 @@ private function extractRootVariable(array $methodCalls): Expr } } - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } private function isLastMethodCallInChainCall(MethodCall $methodCall): bool diff --git a/src/Rector/MethodBody/ReturnThisRemoveRector.php b/src/Rector/MethodBody/ReturnThisRemoveRector.php index d8f58a3a3416..e3de4aecfc59 100644 --- a/src/Rector/MethodBody/ReturnThisRemoveRector.php +++ b/src/Rector/MethodBody/ReturnThisRemoveRector.php @@ -99,7 +99,7 @@ public function refactor(Node $node): ?Node $methodNode = $node->getAttribute(AttributeKey::METHOD_NODE); if ($methodNode === null) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } $this->docBlockManipulator->removeTagFromNode($methodNode, 'return'); diff --git a/src/Rector/Property/InjectAnnotationClassRector.php b/src/Rector/Property/InjectAnnotationClassRector.php index 04f80439bc29..2013abae9c2a 100644 --- a/src/Rector/Property/InjectAnnotationClassRector.php +++ b/src/Rector/Property/InjectAnnotationClassRector.php @@ -197,7 +197,7 @@ private function refactorPropertyWithAnnotation(Property $property, string $anno $classNode = $property->getAttribute(AttributeKey::CLASS_NODE); if (! $classNode instanceof Class_) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } $this->addPropertyToClass($classNode, $type, $name); diff --git a/src/Rector/Typehint/ParentTypehintedArgumentRector.php b/src/Rector/Typehint/ParentTypehintedArgumentRector.php index 1cdc46947ed4..e45bb79b92f3 100644 --- a/src/Rector/Typehint/ParentTypehintedArgumentRector.php +++ b/src/Rector/Typehint/ParentTypehintedArgumentRector.php @@ -95,7 +95,7 @@ public function refactor(Node $node): ?Node foreach ($this->typehintForArgumentByMethodAndClass as $type => $methodToArgumentToTypes) { $classNode = $node->getAttribute(AttributeKey::CLASS_NODE); if ($classNode === null) { - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } if (! $this->isType($classNode, $type)) { diff --git a/src/Reflection/FunctionReflectionResolver.php b/src/Reflection/FunctionReflectionResolver.php index da4255ef652e..44b5cd94c3e9 100644 --- a/src/Reflection/FunctionReflectionResolver.php +++ b/src/Reflection/FunctionReflectionResolver.php @@ -61,6 +61,6 @@ private function resolveCoreStubLocation(): string } } - throw new ShouldNotHappenException(); + throw new ShouldNotHappenException(__METHOD__ . '() on line ' . __LINE__); } }