%PDF- %PDF-
Server IP : 37.220.80.31 / Your IP : 18.227.81.153 Web Server : Apache/2.4.52 (Ubuntu) System : Linux 3051455-guretool.twc1.net 5.15.0-107-generic #117-Ubuntu SMP Fri Apr 26 12:26:49 UTC 2024 x86_64 User : www-root ( 1010) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/www-root/data/www/dev.artlot24.ru/bitrix/modules/main/lib/annotations/ |
Upload File : |
<?php namespace Bitrix\Main\Annotations; use Bitrix\Main\SystemException; class AnnotationReader { const RULE_FIRST_CAPITAL_LETTER = 0x001; protected $collectRules = self::RULE_FIRST_CAPITAL_LETTER; /** * AnnotationReader constructor. */ public function __construct() { if ( extension_loaded('Zend Optimizer+') && (ini_get('zend_optimizerplus.save_comments') === "0" || ini_get('opcache.save_comments') === "0")) { throw new SystemException( "You have to enable opcache.save_comments=1 or zend_optimizerplus.save_comments=1."); } if (extension_loaded('Zend OPcache') && ini_get('opcache.save_comments') == 0) { throw new SystemException( "You have to enable opcache.save_comments=1 or zend_optimizerplus.save_comments=1."); } } public function getMethodAnnotations(\ReflectionMethod $method) { $doc = $method->getDocComment(); preg_match_all("/@(?=(.*)[ ]*(?:@|\r\n|\n))/U", $doc, $matches); if (!$matches) { return null; } $annotations = array(); foreach ($matches[1] as $match) { if ($this->collectRules & self::RULE_FIRST_CAPITAL_LETTER) { if ($match !== ucfirst($match)) { continue; } } $annotations[] = $match; } $parameters = array(); foreach ($annotations as $annotation) { preg_match("/(\w+)(?:\((.*)\))?/", $annotation, $matches); if ($matches) { $parameters[$matches[1]] = $this->extractParameters($matches[2]); } } return $parameters; } private function extractParameters($string) { if (!$string) { return null; } $parameters = array(); $parts = preg_split("/(\w+)\=([.^\=]*)/", $string, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); for ($i = 0; $i < count($parts); $i++) { //there is key by even number and value is by the next odd number if ($i % 2 === 0) { $rawValue = trim($parts[$i + 1], ', '); $parameters[$parts[$i]] = $rawValue; } } foreach ($parameters as $name => &$rawValue) { $rawValue = trim($rawValue); $rawValue = $this->extractParameter($rawValue); } return $parameters; } private function extractParameter($valueInString) { if (!$valueInString) { return null; } $value = null; if ($valueInString === 'false') { $value = false; } elseif ($valueInString === 'true') { $value = true; } elseif (is_numeric($valueInString)) { if ($valueInString === (string)(int)$valueInString) { $value = (int)$valueInString; } else { $value = (float)$valueInString; } } elseif (mb_substr($valueInString, 0, 1) === '[' && mb_substr($valueInString, -1, 1) === ']') { $list = array(); $valueInString = mb_substr($valueInString, 1, -1); foreach (explode(',', $valueInString) as $listValue) { $listValue = trim($listValue); if (!$listValue) { continue; } $list[] = $this->extractParameter($listValue); } $value = $list; } else { $value = trim($valueInString, '"'); } return $value; } }