Skip to content

fix: properly handle class/enum name in shaped array key #771

fix: properly handle class/enum name in shaped array key

fix: properly handle class/enum name in shaped array key #771

Triggered via push August 13, 2023 16:51
Status Success
Total duration 3m 54s
Artifacts

mutation.yml

on: push
Fit to window
Zoom out
Zoom in

Annotations

10 warnings
Mutation tests: src/Definition/Repository/Reflection/ReflectionClassDefinitionRepository.php#L126
Escaped Mutant for Mutator "UnwrapArrayKeys": --- Original +++ New @@ @@ $localAliases = $this->localTypeAliases($type); $importedAliases = $this->importedTypeAliases($type); $duplicates = []; - $keys = [...array_keys($generics), ...array_keys($localAliases), ...array_keys($importedAliases)]; + $keys = [...array_keys($generics), ...array_keys($localAliases), ...$importedAliases]; foreach ($keys as $key) { $sameKeys = array_filter($keys, fn($value) => $value === $key); if (count($sameKeys) > 1) {
Mutation tests: src/Definition/Repository/Reflection/ReflectionClassDefinitionRepository.php#L126
Escaped Mutant for Mutator "SpreadRemoval": --- Original +++ New @@ @@ $localAliases = $this->localTypeAliases($type); $importedAliases = $this->importedTypeAliases($type); $duplicates = []; - $keys = [...array_keys($generics), ...array_keys($localAliases), ...array_keys($importedAliases)]; + $keys = [...array_keys($generics), ...array_keys($localAliases), array_keys($importedAliases)]; foreach ($keys as $key) { $sameKeys = array_filter($keys, fn($value) => $value === $key); if (count($sameKeys) > 1) {
Mutation tests: src/Definition/Repository/Reflection/ReflectionClassDefinitionRepository.php#L169
Escaped Mutant for Mutator "UnwrapTrim": --- Original +++ New @@ @@ try { $types[$name] = $typeParser->parse($raw); } catch (InvalidType $exception) { - $raw = trim($raw); + $raw = $raw; $types[$name] = UnresolvableType::forLocalAlias($raw, $name, $type, $exception); } }
Mutation tests: src/Definition/Repository/Reflection/ReflectionClassDefinitionRepository.php#L212
Escaped Mutant for Mutator "ArrayOneItem": --- Original +++ New @@ @@ $importedTypes[$importedType] = $localTypes[$importedType]; } } - return $importedTypes; + return count($importedTypes) > 1 ? array_slice($importedTypes, 0, 1, true) : $importedTypes; } private function typeParser(ClassType $type) : TypeParser {
Mutation tests: src/Definition/Repository/Reflection/ReflectionClassDefinitionRepository.php#L217
Escaped Mutant for Mutator "ArrayItemRemoval": --- Original +++ New @@ @@ } private function typeParser(ClassType $type) : TypeParser { - $specs = [new ClassContextSpecification($type->className()), new AliasSpecification(Reflection::class($type->className()))]; + $specs = [new AliasSpecification(Reflection::class($type->className()))]; if ($type instanceof GenericType) { $specs[] = new TypeAliasAssignerSpecification($type->generics()); }
Mutation tests: src/Definition/Repository/Reflection/ReflectionParameterDefinitionBuilder.php#L36
Escaped Mutant for Mutator "InstanceOf_": --- Original +++ New @@ @@ } else { $defaultValue = null; } - if ($isOptional && !$type instanceof UnresolvableType && !$type->accepts($defaultValue)) { + if ($isOptional && !false && !$type->accepts($defaultValue)) { $type = UnresolvableType::forInvalidParameterDefaultValue($signature, $type, $defaultValue); } return new ParameterDefinition($name, $signature, $type, $isOptional, $isVariadic, $defaultValue, $attributes); } }
Mutation tests: src/Definition/Repository/Reflection/ReflectionPropertyDefinitionBuilder.php#L31
Escaped Mutant for Mutator "InstanceOf_": --- Original +++ New @@ @@ $defaultValue = $reflection->getDefaultValue(); $isPublic = $reflection->isPublic(); $attributes = $this->attributesRepository->for($reflection); - if ($hasDefaultValue && !$type instanceof UnresolvableType && !$type->accepts($defaultValue)) { + if ($hasDefaultValue && !false && !$type->accepts($defaultValue)) { $type = UnresolvableType::forInvalidPropertyDefaultValue($signature, $type, $defaultValue); } return new PropertyDefinition($name, $signature, $type, $hasDefaultValue, $defaultValue, $isPublic, $attributes);
Mutation tests: src/Definition/Repository/Reflection/ReflectionTypeResolver.php#L44
Escaped Mutant for Mutator "InstanceOf_": --- Original +++ New @@ @@ if (!$typeFromDocBlock) { return $nativeType; } - if (!$typeFromDocBlock instanceof UnresolvableType && !$nativeType instanceof UnresolvableType && !$typeFromDocBlock->matches($nativeType)) { + if (!false && !$nativeType instanceof UnresolvableType && !$typeFromDocBlock->matches($nativeType)) { throw new TypesDoNotMatch($reflection, $typeFromDocBlock, $nativeType); } return $typeFromDocBlock;
Mutation tests: src/Definition/Repository/Reflection/ReflectionTypeResolver.php#L91
Escaped Mutant for Mutator "UnwrapTrim": --- Original +++ New @@ @@ try { return $parser->parse($raw); } catch (InvalidType $exception) { - $raw = trim($raw); + $raw = $raw; $signature = Reflection::signature($reflection); if ($reflection instanceof ReflectionProperty) { return UnresolvableType::forProperty($raw, $signature, $exception);
Mutation tests: src/Library/Container.php#L134
Escaped Mutant for Mutator "GreaterThan": --- Original +++ New @@ @@ $builder = new InterfaceNodeBuilder($builder, $this->get(ObjectImplementations::class), $this->get(ClassDefinitionRepository::class), $this->get(ObjectBuilderFactory::class), $this->get(ObjectNodeBuilder::class), $settings->enableFlexibleCasting); $builder = new CasterProxyNodeBuilder($builder); $builder = new IterableNodeBuilder($builder); - if (count($settings->valueModifier) > 0) { + if (count($settings->valueModifier) >= 0) { $builder = new ValueAlteringNodeBuilder($builder, new FunctionsContainer($this->get(FunctionDefinitionRepository::class), $settings->valueModifier)); } $builder = new StrictNodeBuilder($builder, $settings->allowPermissiveTypes, $settings->enableFlexibleCasting);