| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace eXpansion\Framework\Core\DataProviders; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use eXpansion\Framework\Core\Helpers\ChatOutput; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use eXpansion\Framework\Core\Model\Helpers\ChatNotificationInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use eXpansion\Framework\Core\Services\ChatCommands; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Symfony\Component\Console\Exception\RuntimeException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * Class ChatCommandDataProvider, provides execution instructions for chat commands. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * @package eXpansion\Framework\Core\DataProviders | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | class ChatCommandDataProvider extends AbstractDataProvider | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |     /** @var ChatCommands  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     protected $chatCommands; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     /** @var ChatCommands  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     protected $chatNotification; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |     /** @var ChatOutput */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     protected $chatOutput; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |      * ChatCommandDataProvider constructor. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |      * @param $chatCommands | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 | 7 |  |     public function __construct( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |         ChatCommands $chatCommands, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |         ChatNotificationInterface $chatNotification, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |         ChatOutput $chatOutput) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 | 7 |  |         $this->chatCommands = $chatCommands; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 | 7 |  |         $this->chatNotification = $chatNotification; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 | 7 |  |         $this->chatOutput = $chatOutput; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 | 7 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |      * @inheritdoc | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 | 1 |  |     public function registerPlugin($pluginId, $pluginService) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 | 1 |  |         parent::registerPlugin($pluginId, $pluginService); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 | 1 |  |         $this->chatCommands->registerPlugin($pluginId, $pluginService); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 | 1 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |      * @inheritdoc | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 | 1 |  |     public function deletePlugin($pluginId) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 | 1 |  |         parent::deletePlugin($pluginId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 | 1 |  |         $this->chatCommands->deletePlugin($pluginId); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 | 1 |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |      * Called when a player chats on the server. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |      * @param int $playerUid | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |      * @param string $login | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |      * @param string $text | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |      * @param bool $isRegisteredCmd | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 67 |  |  |      */ | 
            
                                                        
            
                                    
            
            
                | 68 | 4 |  |     public function onPlayerChat($playerUid, $login, $text, $isRegisteredCmd = false) | 
            
                                                        
            
                                    
            
            
                | 69 |  |  |     { | 
            
                                                        
            
                                    
            
            
                | 70 | 4 |  |         if (!$isRegisteredCmd) { | 
            
                                                        
            
                                    
            
            
                | 71 | 1 |  |             return; | 
            
                                                        
            
                                    
            
            
                | 72 |  |  |         } | 
            
                                                        
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 74 | 3 |  |         $text = substr($text, 1); | 
            
                                                        
            
                                    
            
            
                | 75 | 3 |  |         $cmdAndArgs = explode(' ', $text); | 
            
                                                        
            
                                    
            
            
                | 76 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 77 |  |  |         // Internal dedicated server command to ignore. | 
            
                                                        
            
                                    
            
            
                | 78 | 3 |  |         if ($cmdAndArgs[0] === 'version') { | 
            
                                                        
            
                                    
            
            
                | 79 | 1 |  |             return; | 
            
                                                        
            
                                    
            
            
                | 80 |  |  |         } | 
            
                                                        
            
                                    
            
            
                | 81 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 82 |  |  |         // Internal dedicated server command to ignore. | 
            
                                                        
            
                                    
            
            
                | 83 | 2 |  |         if ($cmdAndArgs[0] === 'serverlogin') { | 
            
                                                        
            
                                    
            
            
                | 84 |  |  |             return; | 
            
                                                        
            
                                    
            
            
                | 85 |  |  |         } | 
            
                                                        
            
                                    
            
            
                | 86 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 87 | 2 |  |         $message = 'expansion_core.chat_commands.wrong_chat'; | 
            
                                                        
            
                                    
            
            
                | 88 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 89 | 2 |  |         list($command, $parameter) = $this->chatCommands->getChatCommand($cmdAndArgs); | 
            
                                                        
            
                                    
            
            
                | 90 | 2 |  |         if ($command) { | 
            
                                                        
            
                                    
            
            
                | 91 | 1 |  |             $parameter = implode(" ", $parameter); | 
            
                                                        
            
                                    
            
            
                | 92 | 1 |  |             $message = $command->validate($login, $parameter); | 
            
                                                        
            
                                    
            
            
                | 93 | 1 |  |             if (empty($message)) { | 
            
                                                        
            
                                    
            
            
                | 94 |  |  |                 try { | 
            
                                                        
            
                                    
            
            
                | 95 | 1 |  |                     $this->chatOutput->setLogin($login); | 
            
                                                        
            
                                    
            
            
                | 96 | 1 |  |                     $message = $command->run($login, $this->chatOutput, $parameter); | 
            
                                                        
            
                                    
            
            
                | 97 |  |  |                 } catch (RuntimeException $e) { | 
            
                                                        
            
                                    
            
            
                | 98 |  |  |                     $this->chatNotification->sendMessage($e->getMessage(), $login); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                        
            
                                    
            
            
                | 99 |  |  |                 } catch (\Exception $e) { | 
            
                                                        
            
                                    
            
            
                | 100 |  |  |                     $this->chatNotification->sendMessage($e->getMessage(), $login); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                        
            
                                    
            
            
                | 101 |  |  |                 } | 
            
                                                        
            
                                    
            
            
                | 102 |  |  |             } | 
            
                                                        
            
                                    
            
            
                | 103 |  |  |         } | 
            
                                                        
            
                                    
            
            
                | 104 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 105 | 2 |  |         if (!empty($message)) { | 
            
                                                        
            
                                    
            
            
                | 106 | 1 |  |             $this->chatNotification->sendMessage($message, $login); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                        
            
                                    
            
            
                | 107 |  |  |         } | 
            
                                                        
            
                                    
            
            
                | 108 | 2 |  |     } | 
            
                                                        
            
                                    
            
            
                | 109 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 110 |  |  |  | 
            
                        
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..