| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * This software package is licensed under AGPL, Commercial license. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * @package maslosoft/addendum | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * @licence AGPL, Commercial | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * @copyright Copyright (c) Piotr Masełkowski <[email protected]> (Meta container, further improvements, bugfixes) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * @copyright Copyright (c) Maslosoft (Meta container, further improvements, bugfixes) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * @copyright Copyright (c) Jan Suchal (Original version, builder, parser) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * @link http://maslosoft.com/addendum/ - maslosoft addendum | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * @link https://code.google.com/p/addendum/ - original addendum project | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | namespace Maslosoft\Addendum\Matcher; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use Maslosoft\Addendum\Exceptions\ClassNotFoundException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use Maslosoft\Addendum\Interfaces\Matcher\MatcherInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | use Maslosoft\Addendum\Matcher\Helpers\Processor; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | use Maslosoft\Addendum\Utilities\ClassChecker; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 21 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 22 |  |  | class StaticConstantMatcher extends RegexMatcher implements MatcherInterface | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 | 39 |  | 	public function __construct() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 | 39 |  | 		parent::__construct('([\w\\\]+::\w+)'); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 28 | 39 |  | 	} | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 | 3 |  | 	protected function process($matches) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 | 3 |  | 		$value = $matches[1]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 | 3 |  | 		$parts = explode('::', $value); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 | 3 |  | 		$className = $parts[0]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 | 3 |  | 		$constName = $parts[1]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 | 3 |  | 		$className = Processor::process($this, $className); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 | 3 |  | 		$value = sprintf('%s::%s', $className, $constName); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 | 3 |  | 		if ($className !== 'self' && $className !== 'static') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 | 3 |  | 			if (!ClassChecker::exists($className)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | 			{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | 				throw new ClassNotFoundException("Class $className not found while parsing annotations"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 | 3 |  | 		if (!defined($value)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | 		{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | 			return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 | 3 |  | 		return constant($value); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 50 |  |  | 	} | 
            
                                                        
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 52 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 53 |  |  |  |