@@ -162,8 +162,9 @@ private function getLatestLtsNodeVersion(): string
162162 return 'Unknown ' ;
163163 }
164164
165+ /** @var array<int, array<string, mixed>> $nodes */
165166 foreach ($ nodes as $ node ) {
166- if (isset ($ node ['lts ' ]) && $ node ['lts ' ] !== false ) {
167+ if (isset ($ node ['lts ' ]) && $ node ['lts ' ] !== false && isset ( $ node [ ' version ' ]) && is_string ( $ node [ ' version ' ]) ) {
167168 return trim ($ node ['version ' ], 'v ' );
168169 }
169170 }
@@ -407,12 +408,15 @@ private function getSearchEngineFromMagentoConfig(): ?string
407408 private function checkSearchEngineViaDeploymentConfig ($ objectManager ): ?string
408409 {
409410 try {
411+ /** @var \Magento\Framework\App\DeploymentConfig $deploymentConfig */
410412 $ deploymentConfig = $ objectManager ->get (\Magento \Framework \App \DeploymentConfig::class);
411413 $ engineConfig = $ deploymentConfig ->get ('system/search/engine ' );
412414
413- if (!empty ($ engineConfig )) {
414- $ host = $ deploymentConfig ->get ('system/search/engine_host ' ) ?: 'localhost ' ;
415- $ port = $ deploymentConfig ->get ('system/search/engine_port ' ) ?: '9200 ' ;
415+ if (!empty ($ engineConfig ) && is_string ($ engineConfig )) {
416+ $ hostRaw = $ deploymentConfig ->get ('system/search/engine_host ' );
417+ $ portRaw = $ deploymentConfig ->get ('system/search/engine_port ' );
418+ $ host = is_string ($ hostRaw ) ? $ hostRaw : 'localhost ' ;
419+ $ port = is_string ($ portRaw ) ? $ portRaw : '9200 ' ;
416420
417421 $ url = "http:// {$ host }: {$ port }" ;
418422 if ($ this ->testElasticsearchConnection ($ url )) {
@@ -439,12 +443,11 @@ private function checkSearchEngineViaDeploymentConfig($objectManager): ?string
439443 private function checkSearchEngineViaEngineResolver ($ objectManager ): ?string
440444 {
441445 try {
446+ /** @var \Magento\Framework\Search\EngineResolverInterface $engineResolver */
442447 $ engineResolver = $ objectManager ->get (\Magento \Framework \Search \EngineResolverInterface::class);
443- if ($ engineResolver ) {
444- $ currentEngine = $ engineResolver ->getCurrentSearchEngine ();
445- if (!empty ($ currentEngine )) {
446- return ucfirst ($ currentEngine ) . ' (Magento config) ' ;
447- }
448+ $ currentEngine = $ engineResolver ->getCurrentSearchEngine ();
449+ if (!empty ($ currentEngine )) {
450+ return ucfirst ($ currentEngine ) . ' (Magento config) ' ;
448451 }
449452 } catch (\Exception $ e ) {
450453 if ($ this ->io ->isVerbose ()) {
@@ -541,12 +544,16 @@ private function getSearchEngineHosts(): array
541544 */
542545 private function formatSearchEngineVersion (array $ info ): string
543546 {
544- if (isset ($ info ['version ' ]['distribution ' ]) && $ info ['version ' ]['distribution ' ] === 'opensearch ' ) {
545- return 'OpenSearch ' . $ info ['version ' ]['number ' ];
547+ $ version = $ info ['version ' ] ?? null ;
548+ if (!is_array ($ version )) {
549+ return 'Search Engine Available ' ;
550+ }
551+ if (isset ($ version ['distribution ' ]) && $ version ['distribution ' ] === 'opensearch ' ) {
552+ return 'OpenSearch ' . ($ version ['number ' ] ?? '' );
546553 }
547554
548- if (isset ($ info [ ' version ' ] ['number ' ])) {
549- return 'Elasticsearch ' . $ info [ ' version ' ] ['number ' ];
555+ if (isset ($ version ['number ' ])) {
556+ return 'Elasticsearch ' . $ version ['number ' ];
550557 }
551558
552559 return 'Search Engine Available ' ;
@@ -597,6 +604,7 @@ private function tryMagentoHttpClient(string $url): ?array
597604 if ($ status === 200 && !empty ($ response )) {
598605 $ data = json_decode ($ response , true );
599606 if (is_array ($ data )) {
607+ /** @var array<string, mixed> $data */
600608 return $ data ;
601609 }
602610 }
@@ -734,9 +742,10 @@ private function getMagentoEnvironmentValue(string $name): ?string
734742 private function getValueFromDeploymentConfig ($ objectManager , string $ name ): ?string
735743 {
736744 try {
745+ /** @var \Magento\Framework\App\DeploymentConfig $deploymentConfig */
737746 $ deploymentConfig = $ objectManager ->get (\Magento \Framework \App \DeploymentConfig::class);
738747 $ envValue = $ deploymentConfig ->get ('system/default/environment/ ' . $ name );
739- if ($ envValue !== null ) {
748+ if ($ envValue !== null && is_scalar ( $ envValue ) ) {
740749 return (string ) $ envValue ;
741750 }
742751 } catch (\Exception $ e ) {
@@ -760,7 +769,7 @@ private function getValueFromEnvironmentService($objectManager, string $name): ?
760769 try {
761770 $ environmentService = $ objectManager ->get (\Magento \Framework \App \EnvironmentInterface::class);
762771 $ method = 'get ' . str_replace (' ' , '' , ucwords (str_replace ('_ ' , ' ' , strtolower ($ name ))));
763- if (method_exists ($ environmentService , $ method )) {
772+ if (is_object ( $ environmentService ) && method_exists ($ environmentService , $ method )) {
764773 $ value = $ environmentService ->$ method ();
765774 if ($ value !== null ) {
766775 return (string ) $ value ;
0 commit comments