@@ -25,8 +25,7 @@ protected function configure(): void
2525 $ this
2626 ->addArgument ('class ' , InputArgument::REQUIRED , 'The fully qualified class name of the tool to migrate ' )
2727 ->addOption ('dry-run ' , null , InputOption::VALUE_NONE , 'Show what would be changed without modifying files ' )
28- ->addOption ('backup ' , null , InputOption::VALUE_NONE , 'Create a backup of the original file ' )
29- ;
28+ ->addOption ('backup ' , null , InputOption::VALUE_NONE , 'Create a backup of the original file ' );
3029 }
3130
3231 protected function execute (InputInterface $ input , OutputInterface $ output ): int
@@ -38,14 +37,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int
3837 $ backup = $ input ->getOption ('backup ' );
3938
4039 // Validate class exists
41- if (!class_exists ($ className )) {
40+ if (! class_exists ($ className )) {
4241 throw new Exception (sprintf ('Class "%s" not found ' , $ className ));
4342 }
4443
4544 $ reflection = new \ReflectionClass ($ className );
4645 $ filePath = $ reflection ->getFileName ();
4746
48- if (!$ filePath ) {
47+ if (! $ filePath ) {
4948 throw new Exception ('Could not determine file path for class ' );
5049 }
5150
@@ -71,7 +70,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7170 $ instance = $ reflection ->newInstance ();
7271 $ currentSchema = $ instance ->getInputSchema ();
7372
74- if (!is_array ($ currentSchema )) {
73+ if (! is_array ($ currentSchema )) {
7574 throw new Exception ('getInputSchema does not return an array. Already migrated? ' );
7675 }
7776
@@ -88,12 +87,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8887
8988 if ($ dryRun ) {
9089 $ io ->success ('Dry run completed. No files were modified. ' );
90+
9191 return Command::SUCCESS ;
9292 }
9393
9494 // Create backup if requested
9595 if ($ backup ) {
96- $ backupPath = $ filePath . '.bak ' ;
96+ $ backupPath = $ filePath. '.bak ' ;
9797 copy ($ filePath , $ backupPath );
9898 $ io ->text (sprintf ('Backup created: %s ' , $ backupPath ));
9999 }
@@ -114,6 +114,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
114114 return Command::SUCCESS ;
115115 } catch (\Throwable $ e ) {
116116 $ io ->error ($ e ->getMessage ());
117+
117118 return Command::FAILURE ;
118119 }
119120 }
@@ -134,7 +135,7 @@ private function generateStructuredSchemaMethod(array $schema): string
134135
135136 $ code .= implode (", \n" , $ propertyLines );
136137 $ code .= "\n ); \n" ;
137- $ code .= " } " ;
138+ $ code .= ' } ' ;
138139
139140 return $ code ;
140141 }
@@ -158,7 +159,7 @@ private function generateSchemaProperty(string $name, array $config, bool $requi
158159 }
159160
160161 $ code .= sprintf (" required: %s \n" , $ required ? 'true ' : 'false ' );
161- $ code .= " ) " ;
162+ $ code .= ' ) ' ;
162163
163164 return $ code ;
164165 }
@@ -177,13 +178,13 @@ private function generateUseStatements(string $content): string
177178 $ statements = [];
178179
179180 // Check if these use statements already exist
180- if (!str_contains ($ content , 'use KLP\KlpMcpServer\Services\ToolService\Schema\StructuredSchema; ' )) {
181+ if (! str_contains ($ content , 'use KLP\KlpMcpServer\Services\ToolService\Schema\StructuredSchema; ' )) {
181182 $ statements [] = 'use KLP\KlpMcpServer\Services\ToolService\Schema\StructuredSchema; ' ;
182183 }
183- if (!str_contains ($ content , 'use KLP\KlpMcpServer\Services\ToolService\Schema\SchemaProperty; ' )) {
184+ if (! str_contains ($ content , 'use KLP\KlpMcpServer\Services\ToolService\Schema\SchemaProperty; ' )) {
184185 $ statements [] = 'use KLP\KlpMcpServer\Services\ToolService\Schema\SchemaProperty; ' ;
185186 }
186- if (!str_contains ($ content , 'use KLP\KlpMcpServer\Services\ToolService\Schema\PropertyType; ' )) {
187+ if (! str_contains ($ content , 'use KLP\KlpMcpServer\Services\ToolService\Schema\PropertyType; ' )) {
187188 $ statements [] = 'use KLP\KlpMcpServer\Services\ToolService\Schema\PropertyType; ' ;
188189 }
189190
@@ -195,16 +196,17 @@ private function migrateContent(string $content, string $useStatements, string $
195196 // Add use statements after namespace
196197 if ($ useStatements ) {
197198 $ pattern = '/(namespace [^;]+;)/ ' ;
198- $ replacement = "$1 \n\n" . $ useStatements ;
199+ $ replacement = "$1 \n\n" . $ useStatements ;
199200 $ content = preg_replace ($ pattern , $ replacement , $ content , 1 );
200201 }
201202
202203 // Replace the getInputSchema method
203204 $ pattern = '/public function getInputSchema\(\):\s*array\s*\{[^}]*\}(\s*\})?/s ' ;
204- $ content = preg_replace_callback ($ pattern , function ($ matches ) use ($ newMethod ) {
205+ $ content = preg_replace_callback ($ pattern , function ($ matches ) use ($ newMethod ) {
205206 // Check if we matched a nested closing brace
206207 $ extraBrace = isset ($ matches [1 ]) ? $ matches [1 ] : '' ;
207- return $ newMethod . $ extraBrace ;
208+
209+ return $ newMethod .$ extraBrace ;
208210 }, $ content );
209211
210212 // Update the return type hint in interface implementations
0 commit comments