@@ -36,7 +36,7 @@ |
||
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * @param string $file |
| 39 | - * @return bool|string |
|
| 39 | + * @return string|false |
|
| 40 | 40 | */ |
| 41 | 41 | public static function getCompiledFile($file) { |
| 42 | 42 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | $file = GeneralUtility::getFileAbsFileName($file); |
| 44 | 44 | $pathParts = pathinfo($file); |
| 45 | - if ($pathParts['extension'] === 'less') { |
|
| 45 | + if ($pathParts['extension']==='less') { |
|
| 46 | 46 | if (!class_exists('Less_Cache')) { |
| 47 | 47 | $autoload = GeneralUtility::makeInstance('Less_Autoloader'); |
| 48 | 48 | $autoload::register(); |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | $files = array(); |
| 56 | 56 | $files[$file] = ""; |
| 57 | 57 | $compiledFile = \Less_Cache::Get($files, $options, $variables); |
| 58 | - $file = "typo3temp/mooxcore/" . $compiledFile; |
|
| 58 | + $file = "typo3temp/mooxcore/".$compiledFile; |
|
| 59 | 59 | |
| 60 | 60 | return $file; |
| 61 | 61 | } catch (\Exception $e) { |
@@ -72,11 +72,11 @@ discard block |
||
| 72 | 72 | |
| 73 | 73 | $variables = array(); |
| 74 | 74 | $prefix = "plugin.tx_mooxcore.settings.less."; |
| 75 | - if (!isset($GLOBALS['TSFE']->tmpl->flatSetup) || !is_array($GLOBALS['TSFE']->tmpl->flatSetup) || count($GLOBALS['TSFE']->tmpl->flatSetup) === 0) { |
|
| 75 | + if (!isset($GLOBALS['TSFE']->tmpl->flatSetup) || !is_array($GLOBALS['TSFE']->tmpl->flatSetup) || count($GLOBALS['TSFE']->tmpl->flatSetup)===0) { |
|
| 76 | 76 | $GLOBALS['TSFE']->tmpl->generateConfig(); |
| 77 | 77 | } |
| 78 | 78 | foreach ($GLOBALS['TSFE']->tmpl->flatSetup as $constant => $value) { |
| 79 | - if (strpos($constant, $prefix) === 0) { |
|
| 79 | + if (strpos($constant, $prefix)===0) { |
|
| 80 | 80 | $variables[substr($constant, strlen($prefix))] = $value; |
| 81 | 81 | } |
| 82 | 82 | } |
@@ -55,7 +55,6 @@ discard block |
||
| 55 | 55 | /** |
| 56 | 56 | * Creates .htaccess file inside the root directory |
| 57 | 57 | * |
| 58 | - * @param string $htaccessFile Path of .htaccess file |
|
| 59 | 58 | * @return void |
| 60 | 59 | */ |
| 61 | 60 | public function createDefaultHtaccessFile(){
|
@@ -96,7 +95,6 @@ discard block |
||
| 96 | 95 | /** |
| 97 | 96 | * Creates AdditionalConfiguration.php file inside the typo3conf directory |
| 98 | 97 | * |
| 99 | - * @param string $configurationFile Path of AdditionalConfiguration.php file |
|
| 100 | 98 | * @return void |
| 101 | 99 | */ |
| 102 | 100 | public function createDefaultAdditionalConfiguration($extension = NULL){
|
@@ -140,7 +138,6 @@ discard block |
||
| 140 | 138 | /** |
| 141 | 139 | * Creates robots.txt file inside the root directory |
| 142 | 140 | * |
| 143 | - * @param string $robotsFile Path of robots.txt file |
|
| 144 | 141 | * @return void |
| 145 | 142 | */ |
| 146 | 143 | public function createDefaultRobots($extension = NULL){
|
@@ -1,9 +1,9 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace DCNGmbH\MooxCore\Service; |
| 4 | -use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
| 5 | -use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; |
|
| 6 | -use TYPO3\CMS\Core\Messaging\FlashMessage; |
|
| 4 | +use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
| 5 | +use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; |
|
| 6 | +use TYPO3\CMS\Core\Messaging\FlashMessage; |
|
| 7 | 7 | use TYPO3\CMS\Core\Utility\VersionNumberUtility; |
| 8 | 8 | |
| 9 | 9 | class InstallService {
|
@@ -21,10 +21,10 @@ discard block |
||
| 21 | 21 | /** |
| 22 | 22 | * Initializes the install service |
| 23 | 23 | */ |
| 24 | - public function __construct(){
|
|
| 25 | - if(VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) >= 7000000){
|
|
| 24 | + public function __construct() {
|
|
| 25 | + if (VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version)>=7000000) {
|
|
| 26 | 26 | $this->messageQueueByIdentifier = 'extbase.flashmessages.tx_extensionmanager_tools_extensionmanagerextensionmanager'; |
| 27 | - }else{
|
|
| 27 | + }else {
|
|
| 28 | 28 | $this->messageQueueByIdentifier = 'core.template.flashMessages'; |
| 29 | 29 | } |
| 30 | 30 | } |
@@ -32,11 +32,11 @@ discard block |
||
| 32 | 32 | /** |
| 33 | 33 | * @param string $extension |
| 34 | 34 | */ |
| 35 | - public function generateApacheHtaccess($extension = NULL){
|
|
| 36 | - if($extension == $this->extKey){
|
|
| 37 | - if(substr($_SERVER['SERVER_SOFTWARE'], 0, 6) === 'Apache'){
|
|
| 35 | + public function generateApacheHtaccess($extension = NULL) {
|
|
| 36 | + if ($extension==$this->extKey) {
|
|
| 37 | + if (substr($_SERVER['SERVER_SOFTWARE'], 0, 6)==='Apache') {
|
|
| 38 | 38 | $this->createDefaultHtaccessFile(); |
| 39 | - }else{
|
|
| 39 | + }else {
|
|
| 40 | 40 | /** |
| 41 | 41 | * Add Flashmessage that the system it not running on an apache webserver and the url rewritings must be handled manually |
| 42 | 42 | */ |
@@ -58,10 +58,10 @@ discard block |
||
| 58 | 58 | * @param string $htaccessFile Path of .htaccess file |
| 59 | 59 | * @return void |
| 60 | 60 | */ |
| 61 | - public function createDefaultHtaccessFile(){
|
|
| 61 | + public function createDefaultHtaccessFile() {
|
|
| 62 | 62 | $htaccessFile = GeneralUtility::getFileAbsFileName(".htaccess");
|
| 63 | 63 | |
| 64 | - if(file_exists($htaccessFile)){
|
|
| 64 | + if (file_exists($htaccessFile)) {
|
|
| 65 | 65 | |
| 66 | 66 | /** |
| 67 | 67 | * Add Flashmessage that there is already an .htaccess file and we are not going to override this. |
@@ -99,12 +99,12 @@ discard block |
||
| 99 | 99 | * @param string $configurationFile Path of AdditionalConfiguration.php file |
| 100 | 100 | * @return void |
| 101 | 101 | */ |
| 102 | - public function createDefaultAdditionalConfiguration($extension = NULL){
|
|
| 103 | - if($extension == $this->extKey){
|
|
| 102 | + public function createDefaultAdditionalConfiguration($extension = NULL) {
|
|
| 103 | + if ($extension==$this->extKey) {
|
|
| 104 | 104 | |
| 105 | 105 | $configurationFile = GeneralUtility::getFileAbsFileName("typo3conf/AdditionalConfiguration.php");
|
| 106 | 106 | |
| 107 | - if(file_exists($configurationFile)){
|
|
| 107 | + if (file_exists($configurationFile)) {
|
|
| 108 | 108 | |
| 109 | 109 | /** |
| 110 | 110 | * Add Flashmessage that there is already an AdditionalConfiguration.php file and we are not going to override this. |
@@ -143,12 +143,12 @@ discard block |
||
| 143 | 143 | * @param string $robotsFile Path of robots.txt file |
| 144 | 144 | * @return void |
| 145 | 145 | */ |
| 146 | - public function createDefaultRobots($extension = NULL){
|
|
| 147 | - if($extension == $this->extKey){
|
|
| 146 | + public function createDefaultRobots($extension = NULL) {
|
|
| 147 | + if ($extension==$this->extKey) {
|
|
| 148 | 148 | |
| 149 | 149 | $robotsFile = GeneralUtility::getFileAbsFileName("robots.txt");
|
| 150 | 150 | |
| 151 | - if(file_exists($robotsFile)){
|
|
| 151 | + if (file_exists($robotsFile)) {
|
|
| 152 | 152 | |
| 153 | 153 | /** |
| 154 | 154 | * Add Flashmessage that there is already an robots.txt file and we are not going to override this. |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | $robotsContent .= "Disallow: /*?id=* \n"; |
| 174 | 174 | $robotsContent .= "Disallow: /*&type=98 \n"; |
| 175 | 175 | $robotsContent .= " \n"; |
| 176 | - $robotsContent .= "Sitemap: http://" .$_SERVER['HTTP_HOST']. "/sitemap.xml"; |
|
| 176 | + $robotsContent .= "Sitemap: http://".$_SERVER['HTTP_HOST']."/sitemap.xml"; |
|
| 177 | 177 | GeneralUtility::writeFile($robotsFile, $robotsContent, TRUE); |
| 178 | 178 | |
| 179 | 179 | /** |
@@ -195,8 +195,8 @@ discard block |
||
| 195 | 195 | * |
| 196 | 196 | * @param FlashMessage $flashMessage |
| 197 | 197 | */ |
| 198 | - public function addFlashMessage(FlashMessage $flashMessage){
|
|
| 199 | - if($flashMessage){
|
|
| 198 | + public function addFlashMessage(FlashMessage $flashMessage) {
|
|
| 199 | + if ($flashMessage) {
|
|
| 200 | 200 | /** @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */ |
| 201 | 201 | $flashMessageService = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessageService');
|
| 202 | 202 | /** @var $flashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */ |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | public function __construct(){
|
| 25 | 25 | if(VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) >= 7000000){
|
| 26 | 26 | $this->messageQueueByIdentifier = 'extbase.flashmessages.tx_extensionmanager_tools_extensionmanagerextensionmanager'; |
| 27 | - }else{
|
|
| 27 | + } else{
|
|
| 28 | 28 | $this->messageQueueByIdentifier = 'core.template.flashMessages'; |
| 29 | 29 | } |
| 30 | 30 | } |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | if($extension == $this->extKey){
|
| 37 | 37 | if(substr($_SERVER['SERVER_SOFTWARE'], 0, 6) === 'Apache'){
|
| 38 | 38 | $this->createDefaultHtaccessFile(); |
| 39 | - }else{
|
|
| 39 | + } else{
|
|
| 40 | 40 | /** |
| 41 | 41 | * Add Flashmessage that the system it not running on an apache webserver and the url rewritings must be handled manually |
| 42 | 42 | */ |
@@ -8,90 +8,90 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | class InstallService {
|
| 10 | 10 | |
| 11 | - /** |
|
| 12 | - * @var string |
|
| 13 | - */ |
|
| 14 | - protected $extKey = 'moox_core'; |
|
| 11 | + /** |
|
| 12 | + * @var string |
|
| 13 | + */ |
|
| 14 | + protected $extKey = 'moox_core'; |
|
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * @var string |
|
| 18 | - */ |
|
| 19 | - protected $messageQueueByIdentifier = ''; |
|
| 16 | + /** |
|
| 17 | + * @var string |
|
| 18 | + */ |
|
| 19 | + protected $messageQueueByIdentifier = ''; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * Initializes the install service |
|
| 23 | - */ |
|
| 24 | - public function __construct(){
|
|
| 25 | - if(VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) >= 7000000){
|
|
| 26 | - $this->messageQueueByIdentifier = 'extbase.flashmessages.tx_extensionmanager_tools_extensionmanagerextensionmanager'; |
|
| 27 | - }else{
|
|
| 28 | - $this->messageQueueByIdentifier = 'core.template.flashMessages'; |
|
| 29 | - } |
|
| 30 | - } |
|
| 21 | + /** |
|
| 22 | + * Initializes the install service |
|
| 23 | + */ |
|
| 24 | + public function __construct(){
|
|
| 25 | + if(VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) >= 7000000){
|
|
| 26 | + $this->messageQueueByIdentifier = 'extbase.flashmessages.tx_extensionmanager_tools_extensionmanagerextensionmanager'; |
|
| 27 | + }else{
|
|
| 28 | + $this->messageQueueByIdentifier = 'core.template.flashMessages'; |
|
| 29 | + } |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * @param string $extension |
|
| 34 | - */ |
|
| 35 | - public function generateApacheHtaccess($extension = NULL){
|
|
| 36 | - if($extension == $this->extKey){
|
|
| 37 | - if(substr($_SERVER['SERVER_SOFTWARE'], 0, 6) === 'Apache'){
|
|
| 38 | - $this->createDefaultHtaccessFile(); |
|
| 39 | - }else{
|
|
| 40 | - /** |
|
| 41 | - * Add Flashmessage that the system it not running on an apache webserver and the url rewritings must be handled manually |
|
| 42 | - */ |
|
| 43 | - $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
|
|
| 44 | - 'The Bootstrap Package uses RealUrl to generate SEO friendly URLs by default, please take care of the URLs rewriting settings for your environment yourself.<br>' |
|
| 45 | - . 'You can also deactivate RealUrl by changing your TypoScript setup to "<strong>config.tx_realurl_enable = 0</strong>".', |
|
| 46 | - 'TYPO3 is not running on an Apache-Webserver', |
|
| 47 | - FlashMessage::WARNING, |
|
| 48 | - TRUE |
|
| 49 | - ); |
|
| 50 | - $this->addFlashMessage($flashMessage); |
|
| 51 | - return; |
|
| 52 | - } |
|
| 53 | - } |
|
| 54 | - } |
|
| 55 | - /** |
|
| 32 | + /** |
|
| 33 | + * @param string $extension |
|
| 34 | + */ |
|
| 35 | + public function generateApacheHtaccess($extension = NULL){
|
|
| 36 | + if($extension == $this->extKey){
|
|
| 37 | + if(substr($_SERVER['SERVER_SOFTWARE'], 0, 6) === 'Apache'){
|
|
| 38 | + $this->createDefaultHtaccessFile(); |
|
| 39 | + }else{
|
|
| 40 | + /** |
|
| 41 | + * Add Flashmessage that the system it not running on an apache webserver and the url rewritings must be handled manually |
|
| 42 | + */ |
|
| 43 | + $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
|
|
| 44 | + 'The Bootstrap Package uses RealUrl to generate SEO friendly URLs by default, please take care of the URLs rewriting settings for your environment yourself.<br>' |
|
| 45 | + . 'You can also deactivate RealUrl by changing your TypoScript setup to "<strong>config.tx_realurl_enable = 0</strong>".', |
|
| 46 | + 'TYPO3 is not running on an Apache-Webserver', |
|
| 47 | + FlashMessage::WARNING, |
|
| 48 | + TRUE |
|
| 49 | + ); |
|
| 50 | + $this->addFlashMessage($flashMessage); |
|
| 51 | + return; |
|
| 52 | + } |
|
| 53 | + } |
|
| 54 | + } |
|
| 55 | + /** |
|
| 56 | 56 | * Creates .htaccess file inside the root directory |
| 57 | 57 | * |
| 58 | 58 | * @param string $htaccessFile Path of .htaccess file |
| 59 | 59 | * @return void |
| 60 | 60 | */ |
| 61 | - public function createDefaultHtaccessFile(){
|
|
| 62 | - $htaccessFile = GeneralUtility::getFileAbsFileName(".htaccess");
|
|
| 61 | + public function createDefaultHtaccessFile(){
|
|
| 62 | + $htaccessFile = GeneralUtility::getFileAbsFileName(".htaccess");
|
|
| 63 | 63 | |
| 64 | - if(file_exists($htaccessFile)){
|
|
| 64 | + if(file_exists($htaccessFile)){
|
|
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * Add Flashmessage that there is already an .htaccess file and we are not going to override this. |
|
| 68 | - */ |
|
| 69 | - $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
|
|
| 70 | - 'There is already an Apache .htaccess file in the root directory, please make sure that the url rewritings are set properly.<br>' |
|
| 71 | - . 'An example configuration is located at: <strong>typo3conf/ext/moox_core/Configuration/Apache/.htaccess</strong>', |
|
| 72 | - 'Apache .htaccess file already exists', |
|
| 73 | - FlashMessage::NOTICE, |
|
| 74 | - TRUE |
|
| 75 | - ); |
|
| 76 | - $this->addFlashMessage($flashMessage); |
|
| 66 | + /** |
|
| 67 | + * Add Flashmessage that there is already an .htaccess file and we are not going to override this. |
|
| 68 | + */ |
|
| 69 | + $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
|
|
| 70 | + 'There is already an Apache .htaccess file in the root directory, please make sure that the url rewritings are set properly.<br>' |
|
| 71 | + . 'An example configuration is located at: <strong>typo3conf/ext/moox_core/Configuration/Apache/.htaccess</strong>', |
|
| 72 | + 'Apache .htaccess file already exists', |
|
| 73 | + FlashMessage::NOTICE, |
|
| 74 | + TRUE |
|
| 75 | + ); |
|
| 76 | + $this->addFlashMessage($flashMessage); |
|
| 77 | 77 | return; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - $htaccessContent = GeneralUtility::getUrl(ExtensionManagementUtility::extPath($this->extKey).'/Configuration/Apache/.htaccess'); |
|
| 81 | - GeneralUtility::writeFile($htaccessFile, $htaccessContent, TRUE); |
|
| 80 | + $htaccessContent = GeneralUtility::getUrl(ExtensionManagementUtility::extPath($this->extKey).'/Configuration/Apache/.htaccess'); |
|
| 81 | + GeneralUtility::writeFile($htaccessFile, $htaccessContent, TRUE); |
|
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * Add Flashmessage that the example htaccess file was placed in the root directory |
|
| 85 | - */ |
|
| 86 | - $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
|
|
| 87 | - 'For RealURL and optimization purposes an example .htaccess file was placed in your root directory. <br>' |
|
| 88 | - . ' Please check if the RewriteBase correctly set for your environment. ', |
|
| 89 | - 'Apache example .htaccess was placed in the root directory.', |
|
| 90 | - FlashMessage::OK, |
|
| 91 | - TRUE |
|
| 92 | - ); |
|
| 93 | - $this->addFlashMessage($flashMessage); |
|
| 94 | - } |
|
| 83 | + /** |
|
| 84 | + * Add Flashmessage that the example htaccess file was placed in the root directory |
|
| 85 | + */ |
|
| 86 | + $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
|
|
| 87 | + 'For RealURL and optimization purposes an example .htaccess file was placed in your root directory. <br>' |
|
| 88 | + . ' Please check if the RewriteBase correctly set for your environment. ', |
|
| 89 | + 'Apache example .htaccess was placed in the root directory.', |
|
| 90 | + FlashMessage::OK, |
|
| 91 | + TRUE |
|
| 92 | + ); |
|
| 93 | + $this->addFlashMessage($flashMessage); |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | 96 | /** |
| 97 | 97 | * Creates AdditionalConfiguration.php file inside the typo3conf directory |
@@ -143,39 +143,39 @@ discard block |
||
| 143 | 143 | * @param string $robotsFile Path of robots.txt file |
| 144 | 144 | * @return void |
| 145 | 145 | */ |
| 146 | - public function createDefaultRobots($extension = NULL){
|
|
| 146 | + public function createDefaultRobots($extension = NULL){
|
|
| 147 | 147 | if($extension == $this->extKey){
|
| 148 | 148 | |
| 149 | - $robotsFile = GeneralUtility::getFileAbsFileName("robots.txt");
|
|
| 149 | + $robotsFile = GeneralUtility::getFileAbsFileName("robots.txt");
|
|
| 150 | 150 | |
| 151 | - if(file_exists($robotsFile)){
|
|
| 151 | + if(file_exists($robotsFile)){
|
|
| 152 | 152 | |
| 153 | 153 | /** |
| 154 | 154 | * Add Flashmessage that there is already an robots.txt file and we are not going to override this. |
| 155 | 155 | */ |
| 156 | 156 | $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
|
| 157 | - 'There is already an robots.txt file in the root directory.<br>' |
|
| 158 | - . 'An example robots.txt is located at: <strong>typo3conf/ext/moox_core/Configuration/Robots/robots.txt</strong>', |
|
| 159 | - 'robots.txt file already exists', |
|
| 160 | - FlashMessage::NOTICE, |
|
| 161 | - TRUE |
|
| 157 | + 'There is already an robots.txt file in the root directory.<br>' |
|
| 158 | + . 'An example robots.txt is located at: <strong>typo3conf/ext/moox_core/Configuration/Robots/robots.txt</strong>', |
|
| 159 | + 'robots.txt file already exists', |
|
| 160 | + FlashMessage::NOTICE, |
|
| 161 | + TRUE |
|
| 162 | 162 | ); |
| 163 | 163 | $this->addFlashMessage($flashMessage); |
| 164 | - return; |
|
| 165 | - } |
|
| 164 | + return; |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | - $robotsContent .= "User-Agent: * \n"; |
|
| 168 | - $robotsContent .= " \n"; |
|
| 169 | - $robotsContent .= "Allow: / \n"; |
|
| 170 | - $robotsContent .= "Disallow: /typo3/ \n"; |
|
| 171 | - $robotsContent .= " \n"; |
|
| 172 | - $robotsContent .= "Sitemap: http://" .$_SERVER['HTTP_HOST']. "/sitemap.xml"; |
|
| 173 | - GeneralUtility::writeFile($robotsFile, $robotsContent, TRUE); |
|
| 167 | + $robotsContent .= "User-Agent: * \n"; |
|
| 168 | + $robotsContent .= " \n"; |
|
| 169 | + $robotsContent .= "Allow: / \n"; |
|
| 170 | + $robotsContent .= "Disallow: /typo3/ \n"; |
|
| 171 | + $robotsContent .= " \n"; |
|
| 172 | + $robotsContent .= "Sitemap: http://" .$_SERVER['HTTP_HOST']. "/sitemap.xml"; |
|
| 173 | + GeneralUtility::writeFile($robotsFile, $robotsContent, TRUE); |
|
| 174 | 174 | |
| 175 | - /** |
|
| 176 | - * Add Flashmessage that the example AdditionalCOnfiguration.php file was placed in the typo3conf directory |
|
| 177 | - */ |
|
| 178 | - $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
|
|
| 175 | + /** |
|
| 176 | + * Add Flashmessage that the example AdditionalCOnfiguration.php file was placed in the typo3conf directory |
|
| 177 | + */ |
|
| 178 | + $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
|
|
| 179 | 179 | 'robots.txt file was placed in your root directory. <br>', |
| 180 | 180 | 'robots.txt was placed in the root directory.', |
| 181 | 181 | FlashMessage::OK, |
@@ -184,21 +184,21 @@ discard block |
||
| 184 | 184 | $this->addFlashMessage($flashMessage); |
| 185 | 185 | |
| 186 | 186 | } |
| 187 | - } |
|
| 187 | + } |
|
| 188 | 188 | |
| 189 | - /** |
|
| 190 | - * Adds a Flash Message to the Flash Message Queue |
|
| 191 | - * |
|
| 192 | - * @param FlashMessage $flashMessage |
|
| 193 | - */ |
|
| 194 | - public function addFlashMessage(FlashMessage $flashMessage){
|
|
| 195 | - if($flashMessage){
|
|
| 196 | - /** @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */ |
|
| 197 | - $flashMessageService = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessageService');
|
|
| 198 | - /** @var $flashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */ |
|
| 199 | - $flashMessageQueue = $flashMessageService->getMessageQueueByIdentifier($this->messageQueueByIdentifier); |
|
| 200 | - $flashMessageQueue->enqueue($flashMessage); |
|
| 201 | - } |
|
| 202 | - } |
|
| 189 | + /** |
|
| 190 | + * Adds a Flash Message to the Flash Message Queue |
|
| 191 | + * |
|
| 192 | + * @param FlashMessage $flashMessage |
|
| 193 | + */ |
|
| 194 | + public function addFlashMessage(FlashMessage $flashMessage){
|
|
| 195 | + if($flashMessage){
|
|
| 196 | + /** @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */ |
|
| 197 | + $flashMessageService = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessageService');
|
|
| 198 | + /** @var $flashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */ |
|
| 199 | + $flashMessageQueue = $flashMessageService->getMessageQueueByIdentifier($this->messageQueueByIdentifier); |
|
| 200 | + $flashMessageQueue->enqueue($flashMessage); |
|
| 201 | + } |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | 204 | } |
@@ -155,6 +155,9 @@ discard block |
||
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | |
| 158 | + /** |
|
| 159 | + * @param string $compiled_name |
|
| 160 | + */ |
|
| 158 | 161 | private static function OutputFile( $compiled_name, $parser_options ){ |
| 159 | 162 | |
| 160 | 163 | //custom output file |
@@ -184,6 +187,9 @@ discard block |
||
| 184 | 187 | } |
| 185 | 188 | |
| 186 | 189 | |
| 190 | + /** |
|
| 191 | + * @param string $dir |
|
| 192 | + */ |
|
| 187 | 193 | public static function SetCacheDir( $dir ){ |
| 188 | 194 | Less_Cache::$cache_dir = $dir; |
| 189 | 195 | } |
@@ -276,6 +282,7 @@ discard block |
||
| 276 | 282 | /** |
| 277 | 283 | * Get the list of less files and generated css file from a list file |
| 278 | 284 | * |
| 285 | + * @param string $list_file |
|
| 279 | 286 | */ |
| 280 | 287 | static function ListFiles($list_file, &$list, &$css_file_name ){ |
| 281 | 288 | |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -require_once( dirname(__FILE__).'/Version.php'); |
|
| 3 | +require_once(dirname(__FILE__).'/Version.php'); |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * Utility for handling the generation and caching of css files |
@@ -9,13 +9,13 @@ discard block |
||
| 9 | 9 | * @subpackage cache |
| 10 | 10 | * |
| 11 | 11 | */ |
| 12 | -class Less_Cache{ |
|
| 12 | +class Less_Cache { |
|
| 13 | 13 | |
| 14 | 14 | // directory less.php can use for storing data |
| 15 | - public static $cache_dir = false; |
|
| 15 | + public static $cache_dir = false; |
|
| 16 | 16 | |
| 17 | 17 | // specifies the number of seconds after which data created by less.php will be seen as 'garbage' and potentially cleaned up |
| 18 | - public static $gc_lifetime = 604800; |
|
| 18 | + public static $gc_lifetime = 604800; |
|
| 19 | 19 | |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -28,15 +28,15 @@ discard block |
||
| 28 | 28 | * @param array $modify_vars Array of variables |
| 29 | 29 | * @return string Name of the css file |
| 30 | 30 | */ |
| 31 | - public static function Get( $less_files, $parser_options = array(), $modify_vars = array() ){ |
|
| 31 | + public static function Get($less_files, $parser_options = array(), $modify_vars = array()) { |
|
| 32 | 32 | |
| 33 | 33 | |
| 34 | 34 | //check $cache_dir |
| 35 | - if( isset($parser_options['cache_dir']) ){ |
|
| 35 | + if (isset($parser_options['cache_dir'])) { |
|
| 36 | 36 | Less_Cache::$cache_dir = $parser_options['cache_dir']; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - if( empty(Less_Cache::$cache_dir) ){ |
|
| 39 | + if (empty(Less_Cache::$cache_dir)) { |
|
| 40 | 40 | throw new Exception('cache_dir not set'); |
| 41 | 41 | } |
| 42 | 42 | |
@@ -45,11 +45,11 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | |
| 47 | 47 | //create a file for variables |
| 48 | - if( !empty($modify_vars) ){ |
|
| 48 | + if (!empty($modify_vars)) { |
|
| 49 | 49 | $lessvars = Less_Parser::serializeVars($modify_vars); |
| 50 | - $vars_file = Less_Cache::$cache_dir.'lessphpvars_' . sha1($lessvars) . '.less'; |
|
| 50 | + $vars_file = Less_Cache::$cache_dir.'lessphpvars_'.sha1($lessvars).'.less'; |
|
| 51 | 51 | |
| 52 | - if( !file_exists($vars_file) ){ |
|
| 52 | + if (!file_exists($vars_file)) { |
|
| 53 | 53 | file_put_contents($vars_file, $lessvars); |
| 54 | 54 | } |
| 55 | 55 | |
@@ -63,18 +63,18 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | |
| 65 | 65 | // check cached content |
| 66 | - if( !isset($parser_options['use_cache']) || $parser_options['use_cache'] === true ){ |
|
| 67 | - if( file_exists($list_file) ){ |
|
| 66 | + if (!isset($parser_options['use_cache']) || $parser_options['use_cache']===true) { |
|
| 67 | + if (file_exists($list_file)) { |
|
| 68 | 68 | |
| 69 | 69 | self::ListFiles($list_file, $list, $cached_name); |
| 70 | 70 | $compiled_name = self::CompiledName($list); |
| 71 | 71 | |
| 72 | 72 | // if $cached_name != $compiled_name, we know we need to recompile |
| 73 | - if( !$cached_name || $cached_name === $compiled_name ){ |
|
| 73 | + if (!$cached_name || $cached_name===$compiled_name) { |
|
| 74 | 74 | |
| 75 | - $output_file = self::OutputFile($compiled_name, $parser_options ); |
|
| 75 | + $output_file = self::OutputFile($compiled_name, $parser_options); |
|
| 76 | 76 | |
| 77 | - if( $output_file && file_exists($output_file) ){ |
|
| 77 | + if ($output_file && file_exists($output_file)) { |
|
| 78 | 78 | @touch($list_file); |
| 79 | 79 | return basename($output_file); // for backwards compatibility, we just return the name of the file |
| 80 | 80 | } |
@@ -82,24 +82,24 @@ discard block |
||
| 82 | 82 | } |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - $compiled = self::Cache( $less_files, $parser_options ); |
|
| 86 | - if( !$compiled ){ |
|
| 85 | + $compiled = self::Cache($less_files, $parser_options); |
|
| 86 | + if (!$compiled) { |
|
| 87 | 87 | return false; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - $compiled_name = self::CompiledName( $less_files ); |
|
| 91 | - $output_file = self::OutputFile($compiled_name, $parser_options ); |
|
| 90 | + $compiled_name = self::CompiledName($less_files); |
|
| 91 | + $output_file = self::OutputFile($compiled_name, $parser_options); |
|
| 92 | 92 | |
| 93 | 93 | |
| 94 | 94 | //save the file list |
| 95 | 95 | $list = $less_files; |
| 96 | 96 | $list[] = $compiled_name; |
| 97 | - $cache = implode("\n",$list); |
|
| 98 | - file_put_contents( $list_file, $cache ); |
|
| 97 | + $cache = implode("\n", $list); |
|
| 98 | + file_put_contents($list_file, $cache); |
|
| 99 | 99 | |
| 100 | 100 | |
| 101 | 101 | //save the css |
| 102 | - file_put_contents( $output_file, $compiled ); |
|
| 102 | + file_put_contents($output_file, $compiled); |
|
| 103 | 103 | |
| 104 | 104 | |
| 105 | 105 | //clean up |
@@ -116,17 +116,17 @@ discard block |
||
| 116 | 116 | * @param array $modify_vars Array of variables |
| 117 | 117 | * @return string Name of the css file |
| 118 | 118 | */ |
| 119 | - public static function Regen( $less_files, $parser_options = array(), $modify_vars = array() ){ |
|
| 119 | + public static function Regen($less_files, $parser_options = array(), $modify_vars = array()) { |
|
| 120 | 120 | $parser_options['use_cache'] = false; |
| 121 | - return self::Get( $less_files, $parser_options, $modify_vars ); |
|
| 121 | + return self::Get($less_files, $parser_options, $modify_vars); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - public static function Cache( &$less_files, $parser_options = array() ){ |
|
| 124 | + public static function Cache(&$less_files, $parser_options = array()) { |
|
| 125 | 125 | |
| 126 | 126 | |
| 127 | 127 | // get less.php if it exists |
| 128 | - $file = dirname(__FILE__) . '/Less.php'; |
|
| 129 | - if( file_exists($file) && !class_exists('Less_Parser') ){ |
|
| 128 | + $file = dirname(__FILE__).'/Less.php'; |
|
| 129 | + if (file_exists($file) && !class_exists('Less_Parser')) { |
|
| 130 | 130 | require_once($file); |
| 131 | 131 | } |
| 132 | 132 | |
@@ -135,15 +135,15 @@ discard block |
||
| 135 | 135 | |
| 136 | 136 | |
| 137 | 137 | // combine files |
| 138 | - foreach($less_files as $file_path => $uri_or_less ){ |
|
| 138 | + foreach ($less_files as $file_path => $uri_or_less) { |
|
| 139 | 139 | |
| 140 | 140 | //treat as less markup if there are newline characters |
| 141 | - if( strpos($uri_or_less,"\n") !== false ){ |
|
| 142 | - $parser->Parse( $uri_or_less ); |
|
| 141 | + if (strpos($uri_or_less, "\n")!==false) { |
|
| 142 | + $parser->Parse($uri_or_less); |
|
| 143 | 143 | continue; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - $parser->ParseFile( $file_path, $uri_or_less ); |
|
| 146 | + $parser->ParseFile($file_path, $uri_or_less); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | $compiled = $parser->getCss(); |
@@ -155,13 +155,13 @@ discard block |
||
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | |
| 158 | - private static function OutputFile( $compiled_name, $parser_options ){ |
|
| 158 | + private static function OutputFile($compiled_name, $parser_options) { |
|
| 159 | 159 | |
| 160 | 160 | //custom output file |
| 161 | - if( !empty($parser_options['output']) ){ |
|
| 161 | + if (!empty($parser_options['output'])) { |
|
| 162 | 162 | |
| 163 | 163 | //relative to cache directory? |
| 164 | - if( preg_match('#[\\\\/]#',$parser_options['output']) ){ |
|
| 164 | + if (preg_match('#[\\\\/]#', $parser_options['output'])) { |
|
| 165 | 165 | return $parser_options['output']; |
| 166 | 166 | } |
| 167 | 167 | |
@@ -172,11 +172,11 @@ discard block |
||
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | |
| 175 | - private static function CompiledName( $files ){ |
|
| 175 | + private static function CompiledName($files) { |
|
| 176 | 176 | |
| 177 | 177 | //save the file list |
| 178 | 178 | $temp = array(Less_Version::cache_version); |
| 179 | - foreach($files as $file){ |
|
| 179 | + foreach ($files as $file) { |
|
| 180 | 180 | $temp[] = filemtime($file)."\t".filesize($file)."\t".$file; |
| 181 | 181 | } |
| 182 | 182 | |
@@ -184,24 +184,24 @@ discard block |
||
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | |
| 187 | - public static function SetCacheDir( $dir ){ |
|
| 187 | + public static function SetCacheDir($dir) { |
|
| 188 | 188 | Less_Cache::$cache_dir = $dir; |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - public static function CheckCacheDir(){ |
|
| 191 | + public static function CheckCacheDir() { |
|
| 192 | 192 | |
| 193 | - Less_Cache::$cache_dir = str_replace('\\','/',Less_Cache::$cache_dir); |
|
| 194 | - Less_Cache::$cache_dir = rtrim(Less_Cache::$cache_dir,'/').'/'; |
|
| 193 | + Less_Cache::$cache_dir = str_replace('\\', '/', Less_Cache::$cache_dir); |
|
| 194 | + Less_Cache::$cache_dir = rtrim(Less_Cache::$cache_dir, '/').'/'; |
|
| 195 | 195 | |
| 196 | - if( !file_exists(Less_Cache::$cache_dir) ){ |
|
| 197 | - if( !mkdir(Less_Cache::$cache_dir) ){ |
|
| 196 | + if (!file_exists(Less_Cache::$cache_dir)) { |
|
| 197 | + if (!mkdir(Less_Cache::$cache_dir)) { |
|
| 198 | 198 | throw new Less_Exception_Parser('Less.php cache directory couldn\'t be created: '.Less_Cache::$cache_dir); |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - }elseif( !is_dir(Less_Cache::$cache_dir) ){ |
|
| 201 | + }elseif (!is_dir(Less_Cache::$cache_dir)) { |
|
| 202 | 202 | throw new Less_Exception_Parser('Less.php cache directory doesn\'t exist: '.Less_Cache::$cache_dir); |
| 203 | 203 | |
| 204 | - }elseif( !is_writable(Less_Cache::$cache_dir) ){ |
|
| 204 | + }elseif (!is_writable(Less_Cache::$cache_dir)) { |
|
| 205 | 205 | throw new Less_Exception_Parser('Less.php cache directory isn\'t writable: '.Less_Cache::$cache_dir); |
| 206 | 206 | |
| 207 | 207 | } |
@@ -213,20 +213,20 @@ discard block |
||
| 213 | 213 | * Delete unused less.php files |
| 214 | 214 | * |
| 215 | 215 | */ |
| 216 | - public static function CleanCache(){ |
|
| 216 | + public static function CleanCache() { |
|
| 217 | 217 | static $clean = false; |
| 218 | 218 | |
| 219 | - if( $clean ){ |
|
| 219 | + if ($clean) { |
|
| 220 | 220 | return; |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | $files = scandir(Less_Cache::$cache_dir); |
| 224 | - if( $files ){ |
|
| 225 | - $check_time = time() - self::$gc_lifetime; |
|
| 226 | - foreach($files as $file){ |
|
| 224 | + if ($files) { |
|
| 225 | + $check_time = time()-self::$gc_lifetime; |
|
| 226 | + foreach ($files as $file) { |
|
| 227 | 227 | |
| 228 | 228 | // don't delete if the file wasn't created with less.php |
| 229 | - if( strpos($file,'lessphp_') !== 0 ){ |
|
| 229 | + if (strpos($file, 'lessphp_')!==0) { |
|
| 230 | 230 | continue; |
| 231 | 231 | } |
| 232 | 232 | |
@@ -234,32 +234,32 @@ discard block |
||
| 234 | 234 | |
| 235 | 235 | // make sure the file still exists |
| 236 | 236 | // css files may have already been deleted |
| 237 | - if( !file_exists($full_path) ){ |
|
| 237 | + if (!file_exists($full_path)) { |
|
| 238 | 238 | continue; |
| 239 | 239 | } |
| 240 | 240 | $mtime = filemtime($full_path); |
| 241 | 241 | |
| 242 | 242 | // don't delete if it's a relatively new file |
| 243 | - if( $mtime > $check_time ){ |
|
| 243 | + if ($mtime>$check_time) { |
|
| 244 | 244 | continue; |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | - $parts = explode('.',$file); |
|
| 247 | + $parts = explode('.', $file); |
|
| 248 | 248 | $type = array_pop($parts); |
| 249 | 249 | |
| 250 | 250 | |
| 251 | 251 | // delete css files based on the list files |
| 252 | - if( $type === 'css' ){ |
|
| 252 | + if ($type==='css') { |
|
| 253 | 253 | continue; |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | |
| 257 | 257 | // delete the list file and associated css file |
| 258 | - if( $type === 'list' ){ |
|
| 258 | + if ($type==='list') { |
|
| 259 | 259 | self::ListFiles($full_path, $list, $css_file_name); |
| 260 | - if( $css_file_name ){ |
|
| 260 | + if ($css_file_name) { |
|
| 261 | 261 | $css_file = Less_Cache::$cache_dir.'/'.$css_file_name; |
| 262 | - if( file_exists($css_file) ){ |
|
| 262 | + if (file_exists($css_file)) { |
|
| 263 | 263 | unlink($css_file); |
| 264 | 264 | } |
| 265 | 265 | } |
@@ -277,14 +277,14 @@ discard block |
||
| 277 | 277 | * Get the list of less files and generated css file from a list file |
| 278 | 278 | * |
| 279 | 279 | */ |
| 280 | - static function ListFiles($list_file, &$list, &$css_file_name ){ |
|
| 280 | + static function ListFiles($list_file, &$list, &$css_file_name) { |
|
| 281 | 281 | |
| 282 | - $list = explode("\n",file_get_contents($list_file)); |
|
| 282 | + $list = explode("\n", file_get_contents($list_file)); |
|
| 283 | 283 | |
| 284 | 284 | //pop the cached name that should match $compiled_name |
| 285 | 285 | $css_file_name = array_pop($list); |
| 286 | 286 | |
| 287 | - if( !preg_match('/^lessphp_[a-f0-9]+\.css$/',$css_file_name) ){ |
|
| 287 | + if (!preg_match('/^lessphp_[a-f0-9]+\.css$/', $css_file_name)) { |
|
| 288 | 288 | $list[] = $css_file_name; |
| 289 | 289 | $css_file_name = false; |
| 290 | 290 | } |
@@ -198,10 +198,10 @@ |
||
| 198 | 198 | throw new Less_Exception_Parser('Less.php cache directory couldn\'t be created: '.Less_Cache::$cache_dir); |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - }elseif( !is_dir(Less_Cache::$cache_dir) ){ |
|
| 201 | + } elseif( !is_dir(Less_Cache::$cache_dir) ){ |
|
| 202 | 202 | throw new Less_Exception_Parser('Less.php cache directory doesn\'t exist: '.Less_Cache::$cache_dir); |
| 203 | 203 | |
| 204 | - }elseif( !is_writable(Less_Cache::$cache_dir) ){ |
|
| 204 | + } elseif( !is_writable(Less_Cache::$cache_dir) ){ |
|
| 205 | 205 | throw new Less_Exception_Parser('Less.php cache directory isn\'t writable: '.Less_Cache::$cache_dir); |
| 206 | 206 | |
| 207 | 207 | } |
@@ -173,11 +173,17 @@ |
||
| 173 | 173 | //$this->emitChunk(true); |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | + /** |
|
| 177 | + * @param integer $pos |
|
| 178 | + */ |
|
| 176 | 179 | public function CharCode($pos){ |
| 177 | 180 | return ord($this->input[$pos]); |
| 178 | 181 | } |
| 179 | 182 | |
| 180 | 183 | |
| 184 | + /** |
|
| 185 | + * @param integer $index |
|
| 186 | + */ |
|
| 181 | 187 | public function fail( $msg, $index = null ){ |
| 182 | 188 | |
| 183 | 189 | if( !$index ){ |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * @package Less |
| 7 | 7 | * @subpackage exception |
| 8 | 8 | */ |
| 9 | -class Less_Exception_Chunk extends Less_Exception_Parser{ |
|
| 9 | +class Less_Exception_Chunk extends Less_Exception_Parser { |
|
| 10 | 10 | |
| 11 | 11 | |
| 12 | 12 | protected $parserCurrentIndex = 0; |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | * @param Less_FileInfo|string $currentFile The file |
| 26 | 26 | * @param integer $code The exception code |
| 27 | 27 | */ |
| 28 | - public function __construct($input, Exception $previous = null, $index = null, $currentFile = null, $code = 0){ |
|
| 28 | + public function __construct($input, Exception $previous = null, $index = null, $currentFile = null, $code = 0) { |
|
| 29 | 29 | |
| 30 | 30 | $this->message = 'ParseError: Unexpected input'; //default message |
| 31 | 31 | |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | * We don't actually need the chunks |
| 47 | 47 | * |
| 48 | 48 | */ |
| 49 | - protected function Chunks(){ |
|
| 49 | + protected function Chunks() { |
|
| 50 | 50 | $level = 0; |
| 51 | 51 | $parenLevel = 0; |
| 52 | 52 | $lastMultiCommentEndBrace = null; |
@@ -54,9 +54,9 @@ discard block |
||
| 54 | 54 | $lastMultiComment = null; |
| 55 | 55 | $lastParen = null; |
| 56 | 56 | |
| 57 | - for( $this->parserCurrentIndex = 0; $this->parserCurrentIndex < $this->input_len; $this->parserCurrentIndex++ ){ |
|
| 57 | + for ($this->parserCurrentIndex = 0; $this->parserCurrentIndex<$this->input_len; $this->parserCurrentIndex++) { |
|
| 58 | 58 | $cc = $this->CharCode($this->parserCurrentIndex); |
| 59 | - if ((($cc >= 97) && ($cc <= 122)) || ($cc < 34)) { |
|
| 59 | + if ((($cc>=97) && ($cc<=122)) || ($cc<34)) { |
|
| 60 | 60 | // a-z or whitespace |
| 61 | 61 | continue; |
| 62 | 62 | } |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | // ) |
| 73 | 73 | case 41: |
| 74 | 74 | $parenLevel--; |
| 75 | - if( $parenLevel < 0 ){ |
|
| 75 | + if ($parenLevel<0) { |
|
| 76 | 76 | return $this->fail("missing opening `(`"); |
| 77 | 77 | } |
| 78 | 78 | continue; |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | // } |
| 92 | 92 | case 125: |
| 93 | 93 | $level--; |
| 94 | - if( $level < 0 ){ |
|
| 94 | + if ($level<0) { |
|
| 95 | 95 | return $this->fail("missing opening `{`"); |
| 96 | 96 | |
| 97 | 97 | } |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | continue; |
| 100 | 100 | // \ |
| 101 | 101 | case 92: |
| 102 | - if ($this->parserCurrentIndex < $this->input_len - 1) { $this->parserCurrentIndex++; continue; } |
|
| 102 | + if ($this->parserCurrentIndex<$this->input_len-1) { $this->parserCurrentIndex++; continue; } |
|
| 103 | 103 | return $this->fail("unescaped `\\`"); |
| 104 | 104 | |
| 105 | 105 | // ", ' and ` |
@@ -108,40 +108,40 @@ discard block |
||
| 108 | 108 | case 96: |
| 109 | 109 | $matched = 0; |
| 110 | 110 | $currentChunkStartIndex = $this->parserCurrentIndex; |
| 111 | - for ($this->parserCurrentIndex = $this->parserCurrentIndex + 1; $this->parserCurrentIndex < $this->input_len; $this->parserCurrentIndex++) { |
|
| 111 | + for ($this->parserCurrentIndex = $this->parserCurrentIndex+1; $this->parserCurrentIndex<$this->input_len; $this->parserCurrentIndex++) { |
|
| 112 | 112 | $cc2 = $this->CharCode($this->parserCurrentIndex); |
| 113 | - if ($cc2 > 96) { continue; } |
|
| 114 | - if ($cc2 == $cc) { $matched = 1; break; } |
|
| 115 | - if ($cc2 == 92) { // \ |
|
| 116 | - if ($this->parserCurrentIndex == $this->input_len - 1) { |
|
| 113 | + if ($cc2>96) { continue; } |
|
| 114 | + if ($cc2==$cc) { $matched = 1; break; } |
|
| 115 | + if ($cc2==92) { // \ |
|
| 116 | + if ($this->parserCurrentIndex==$this->input_len-1) { |
|
| 117 | 117 | return $this->fail("unescaped `\\`"); |
| 118 | 118 | } |
| 119 | 119 | $this->parserCurrentIndex++; |
| 120 | 120 | } |
| 121 | 121 | } |
| 122 | 122 | if ($matched) { continue; } |
| 123 | - return $this->fail("unmatched `" + chr($cc) + "`", $currentChunkStartIndex); |
|
| 123 | + return $this->fail("unmatched `" +chr($cc)+"`", $currentChunkStartIndex); |
|
| 124 | 124 | |
| 125 | 125 | // /, check for comment |
| 126 | 126 | case 47: |
| 127 | - if ($parenLevel || ($this->parserCurrentIndex == $this->input_len - 1)) { continue; } |
|
| 127 | + if ($parenLevel || ($this->parserCurrentIndex==$this->input_len-1)) { continue; } |
|
| 128 | 128 | $cc2 = $this->CharCode($this->parserCurrentIndex+1); |
| 129 | - if ($cc2 == 47) { |
|
| 129 | + if ($cc2==47) { |
|
| 130 | 130 | // //, find lnfeed |
| 131 | - for ($this->parserCurrentIndex = $this->parserCurrentIndex + 2; $this->parserCurrentIndex < $this->input_len; $this->parserCurrentIndex++) { |
|
| 131 | + for ($this->parserCurrentIndex = $this->parserCurrentIndex+2; $this->parserCurrentIndex<$this->input_len; $this->parserCurrentIndex++) { |
|
| 132 | 132 | $cc2 = $this->CharCode($this->parserCurrentIndex); |
| 133 | - if (($cc2 <= 13) && (($cc2 == 10) || ($cc2 == 13))) { break; } |
|
| 133 | + if (($cc2<=13) && (($cc2==10) || ($cc2==13))) { break; } |
|
| 134 | 134 | } |
| 135 | - } else if ($cc2 == 42) { |
|
| 135 | + }else if ($cc2==42) { |
|
| 136 | 136 | // /*, find */ |
| 137 | 137 | $lastMultiComment = $currentChunkStartIndex = $this->parserCurrentIndex; |
| 138 | - for ($this->parserCurrentIndex = $this->parserCurrentIndex + 2; $this->parserCurrentIndex < $this->input_len - 1; $this->parserCurrentIndex++) { |
|
| 138 | + for ($this->parserCurrentIndex = $this->parserCurrentIndex+2; $this->parserCurrentIndex<$this->input_len-1; $this->parserCurrentIndex++) { |
|
| 139 | 139 | $cc2 = $this->CharCode($this->parserCurrentIndex); |
| 140 | - if ($cc2 == 125) { $lastMultiCommentEndBrace = $this->parserCurrentIndex; } |
|
| 141 | - if ($cc2 != 42) { continue; } |
|
| 142 | - if ($this->CharCode($this->parserCurrentIndex+1) == 47) { break; } |
|
| 140 | + if ($cc2==125) { $lastMultiCommentEndBrace = $this->parserCurrentIndex; } |
|
| 141 | + if ($cc2!=42) { continue; } |
|
| 142 | + if ($this->CharCode($this->parserCurrentIndex+1)==47) { break; } |
|
| 143 | 143 | } |
| 144 | - if ($this->parserCurrentIndex == $this->input_len - 1) { |
|
| 144 | + if ($this->parserCurrentIndex==$this->input_len-1) { |
|
| 145 | 145 | return $this->fail("missing closing `*/`", $currentChunkStartIndex); |
| 146 | 146 | } |
| 147 | 147 | } |
@@ -149,20 +149,20 @@ discard block |
||
| 149 | 149 | |
| 150 | 150 | // *, check for unmatched */ |
| 151 | 151 | case 42: |
| 152 | - if (($this->parserCurrentIndex < $this->input_len - 1) && ($this->CharCode($this->parserCurrentIndex+1) == 47)) { |
|
| 152 | + if (($this->parserCurrentIndex<$this->input_len-1) && ($this->CharCode($this->parserCurrentIndex+1)==47)) { |
|
| 153 | 153 | return $this->fail("unmatched `/*`"); |
| 154 | 154 | } |
| 155 | 155 | continue; |
| 156 | 156 | } |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - if( $level !== 0 ){ |
|
| 160 | - if( ($lastMultiComment > $lastOpening) && ($lastMultiCommentEndBrace > $lastMultiComment) ){ |
|
| 159 | + if ($level!==0) { |
|
| 160 | + if (($lastMultiComment>$lastOpening) && ($lastMultiCommentEndBrace>$lastMultiComment)) { |
|
| 161 | 161 | return $this->fail("missing closing `}` or `*/`", $lastOpening); |
| 162 | - } else { |
|
| 162 | + }else { |
|
| 163 | 163 | return $this->fail("missing closing `}`", $lastOpening); |
| 164 | 164 | } |
| 165 | - } else if ( $parenLevel !== 0 ){ |
|
| 165 | + }else if ($parenLevel!==0) { |
|
| 166 | 166 | return $this->fail("missing closing `)`", $lastParen); |
| 167 | 167 | } |
| 168 | 168 | |
@@ -173,16 +173,16 @@ discard block |
||
| 173 | 173 | //$this->emitChunk(true); |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - public function CharCode($pos){ |
|
| 176 | + public function CharCode($pos) { |
|
| 177 | 177 | return ord($this->input[$pos]); |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | |
| 181 | - public function fail( $msg, $index = null ){ |
|
| 181 | + public function fail($msg, $index = null) { |
|
| 182 | 182 | |
| 183 | - if( !$index ){ |
|
| 183 | + if (!$index) { |
|
| 184 | 184 | $this->index = $this->parserCurrentIndex; |
| 185 | - }else{ |
|
| 185 | + }else { |
|
| 186 | 186 | $this->index = $index; |
| 187 | 187 | } |
| 188 | 188 | $this->message = 'ParseError: '.$msg; |
@@ -33,7 +33,7 @@ |
||
| 33 | 33 | $this->$funcName( $node ); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - }else{ |
|
| 36 | + } else{ |
|
| 37 | 37 | $node->accept($this); |
| 38 | 38 | } |
| 39 | 39 | |
@@ -66,6 +66,11 @@ |
||
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | + /** |
|
| 70 | + * @param integer $r |
|
| 71 | + * @param integer $g |
|
| 72 | + * @param integer $b |
|
| 73 | + */ |
|
| 69 | 74 | public function rgb ($r, $g, $b){ |
| 70 | 75 | return $this->rgba($r, $g, $b, 1.0); |
| 71 | 76 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | /** |
| 22 | 22 | * @param string $op |
| 23 | 23 | */ |
| 24 | - public static function operate( $op, $a, $b ){ |
|
| 24 | + public static function operate( $op, $a, $b ){ |
|
| 25 | 25 | switch ($op) { |
| 26 | 26 | case '+': return $a + $b; |
| 27 | 27 | case '-': return $a - $b; |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | return $value; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - public static function number($n){ |
|
| 50 | + public static function number($n){ |
|
| 51 | 51 | |
| 52 | 52 | if ($n instanceof Less_Tree_Dimension) { |
| 53 | 53 | return floatval( $n->unit->is('%') ? $n->value / 100 : $n->value); |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - public static function scaled($n, $size = 255 ){ |
|
| 61 | + public static function scaled($n, $size = 255 ){ |
|
| 62 | 62 | if( $n instanceof Less_Tree_Dimension && $n->unit->is('%') ){ |
| 63 | 63 | return (float)$n->value * $size / 100; |
| 64 | 64 | } else { |
@@ -430,7 +430,7 @@ discard block |
||
| 430 | 430 | return new Less_Tree_Quoted( $string->quote , $result, $string->escaped); |
| 431 | 431 | } |
| 432 | 432 | |
| 433 | - public function unit( $val, $unit = null) { |
|
| 433 | + public function unit( $val, $unit = null) { |
|
| 434 | 434 | if( !($val instanceof Less_Tree_Dimension) ){ |
| 435 | 435 | throw new Less_Exception_Compiler('The first argument to unit must be a number' . ($val instanceof Less_Tree_Operation ? '. Have you forgotten parenthesis?' : '.') ); |
| 436 | 436 | } |
@@ -445,7 +445,7 @@ discard block |
||
| 445 | 445 | $unit = ""; |
| 446 | 446 | } |
| 447 | 447 | return new Less_Tree_Dimension($val->value, $unit ); |
| 448 | - } |
|
| 448 | + } |
|
| 449 | 449 | |
| 450 | 450 | public function convert($val, $unit){ |
| 451 | 451 | return $val->convertTo($unit->value); |
@@ -7,12 +7,12 @@ discard block |
||
| 7 | 7 | * @subpackage function |
| 8 | 8 | * @see http://lesscss.org/functions/ |
| 9 | 9 | */ |
| 10 | -class Less_Functions{ |
|
| 10 | +class Less_Functions { |
|
| 11 | 11 | |
| 12 | 12 | public $env; |
| 13 | 13 | public $currentFileInfo; |
| 14 | 14 | |
| 15 | - function __construct($env, $currentFileInfo = null ){ |
|
| 15 | + function __construct($env, $currentFileInfo = null) { |
|
| 16 | 16 | $this->env = $env; |
| 17 | 17 | $this->currentFileInfo = $currentFileInfo; |
| 18 | 18 | } |
@@ -21,92 +21,92 @@ discard block |
||
| 21 | 21 | /** |
| 22 | 22 | * @param string $op |
| 23 | 23 | */ |
| 24 | - public static function operate( $op, $a, $b ){ |
|
| 24 | + public static function operate($op, $a, $b) { |
|
| 25 | 25 | switch ($op) { |
| 26 | - case '+': return $a + $b; |
|
| 27 | - case '-': return $a - $b; |
|
| 26 | + case '+': return $a+$b; |
|
| 27 | + case '-': return $a-$b; |
|
| 28 | 28 | case '*': return $a * $b; |
| 29 | 29 | case '/': return $a / $b; |
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - public static function clamp($val, $max = 1){ |
|
| 34 | - return min( max($val, 0), $max); |
|
| 33 | + public static function clamp($val, $max = 1) { |
|
| 34 | + return min(max($val, 0), $max); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - public static function fround( $value ){ |
|
| 37 | + public static function fround($value) { |
|
| 38 | 38 | |
| 39 | - if( $value === 0 ){ |
|
| 39 | + if ($value===0) { |
|
| 40 | 40 | return $value; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - if( Less_Parser::$options['numPrecision'] ){ |
|
| 43 | + if (Less_Parser::$options['numPrecision']) { |
|
| 44 | 44 | $p = pow(10, Less_Parser::$options['numPrecision']); |
| 45 | - return round( $value * $p) / $p; |
|
| 45 | + return round($value * $p) / $p; |
|
| 46 | 46 | } |
| 47 | 47 | return $value; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - public static function number($n){ |
|
| 50 | + public static function number($n) { |
|
| 51 | 51 | |
| 52 | 52 | if ($n instanceof Less_Tree_Dimension) { |
| 53 | - return floatval( $n->unit->is('%') ? $n->value / 100 : $n->value); |
|
| 54 | - } else if (is_numeric($n)) { |
|
| 53 | + return floatval($n->unit->is('%') ? $n->value / 100 : $n->value); |
|
| 54 | + }else if (is_numeric($n)) { |
|
| 55 | 55 | return $n; |
| 56 | - } else { |
|
| 56 | + }else { |
|
| 57 | 57 | throw new Less_Exception_Compiler("color functions take numbers as parameters"); |
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - public static function scaled($n, $size = 255 ){ |
|
| 62 | - if( $n instanceof Less_Tree_Dimension && $n->unit->is('%') ){ |
|
| 61 | + public static function scaled($n, $size = 255) { |
|
| 62 | + if ($n instanceof Less_Tree_Dimension && $n->unit->is('%')) { |
|
| 63 | 63 | return (float)$n->value * $size / 100; |
| 64 | - } else { |
|
| 64 | + }else { |
|
| 65 | 65 | return Less_Functions::number($n); |
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - public function rgb ($r, $g, $b){ |
|
| 69 | + public function rgb($r, $g, $b) { |
|
| 70 | 70 | return $this->rgba($r, $g, $b, 1.0); |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - public function rgba($r, $g, $b, $a){ |
|
| 73 | + public function rgba($r, $g, $b, $a) { |
|
| 74 | 74 | $rgb = array($r, $g, $b); |
| 75 | - $rgb = array_map(array('Less_Functions','scaled'),$rgb); |
|
| 75 | + $rgb = array_map(array('Less_Functions', 'scaled'), $rgb); |
|
| 76 | 76 | |
| 77 | 77 | $a = self::number($a); |
| 78 | 78 | return new Less_Tree_Color($rgb, $a); |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - public function hsl($h, $s, $l){ |
|
| 81 | + public function hsl($h, $s, $l) { |
|
| 82 | 82 | return $this->hsla($h, $s, $l, 1.0); |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - public function hsla($h, $s, $l, $a){ |
|
| 85 | + public function hsla($h, $s, $l, $a) { |
|
| 86 | 86 | |
| 87 | 87 | $h = fmod(self::number($h), 360) / 360; // Classic % operator will change float to int |
| 88 | 88 | $s = self::clamp(self::number($s)); |
| 89 | 89 | $l = self::clamp(self::number($l)); |
| 90 | 90 | $a = self::clamp(self::number($a)); |
| 91 | 91 | |
| 92 | - $m2 = $l <= 0.5 ? $l * ($s + 1) : $l + $s - $l * $s; |
|
| 92 | + $m2 = $l<=0.5 ? $l * ($s+1) : $l+$s-$l * $s; |
|
| 93 | 93 | |
| 94 | - $m1 = $l * 2 - $m2; |
|
| 94 | + $m1 = $l * 2-$m2; |
|
| 95 | 95 | |
| 96 | - return $this->rgba( self::hsla_hue($h + 1/3, $m1, $m2) * 255, |
|
| 96 | + return $this->rgba(self::hsla_hue($h+1 / 3, $m1, $m2) * 255, |
|
| 97 | 97 | self::hsla_hue($h, $m1, $m2) * 255, |
| 98 | - self::hsla_hue($h - 1/3, $m1, $m2) * 255, |
|
| 98 | + self::hsla_hue($h-1 / 3, $m1, $m2) * 255, |
|
| 99 | 99 | $a); |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
| 103 | 103 | * @param double $h |
| 104 | 104 | */ |
| 105 | - public function hsla_hue($h, $m1, $m2){ |
|
| 106 | - $h = $h < 0 ? $h + 1 : ($h > 1 ? $h - 1 : $h); |
|
| 107 | - if ($h * 6 < 1) return $m1 + ($m2 - $m1) * $h * 6; |
|
| 108 | - else if ($h * 2 < 1) return $m2; |
|
| 109 | - else if ($h * 3 < 2) return $m1 + ($m2 - $m1) * (2/3 - $h) * 6; |
|
| 105 | + public function hsla_hue($h, $m1, $m2) { |
|
| 106 | + $h = $h<0 ? $h+1 : ($h>1 ? $h-1 : $h); |
|
| 107 | + if ($h * 6<1) return $m1+($m2-$m1) * $h * 6; |
|
| 108 | + else if ($h * 2<1) return $m2; |
|
| 109 | + else if ($h * 3<2) return $m1+($m2-$m1) * (2 / 3-$h) * 6; |
|
| 110 | 110 | else return $m1; |
| 111 | 111 | } |
| 112 | 112 | |
@@ -118,18 +118,18 @@ discard block |
||
| 118 | 118 | * @param double $a |
| 119 | 119 | */ |
| 120 | 120 | public function hsva($h, $s, $v, $a) { |
| 121 | - $h = ((Less_Functions::number($h) % 360) / 360 ) * 360; |
|
| 121 | + $h = ((Less_Functions::number($h) % 360) / 360) * 360; |
|
| 122 | 122 | $s = Less_Functions::number($s); |
| 123 | 123 | $v = Less_Functions::number($v); |
| 124 | 124 | $a = Less_Functions::number($a); |
| 125 | 125 | |
| 126 | 126 | $i = floor(($h / 60) % 6); |
| 127 | - $f = ($h / 60) - $i; |
|
| 127 | + $f = ($h / 60)-$i; |
|
| 128 | 128 | |
| 129 | - $vs = array( $v, |
|
| 130 | - $v * (1 - $s), |
|
| 131 | - $v * (1 - $f * $s), |
|
| 132 | - $v * (1 - (1 - $f) * $s)); |
|
| 129 | + $vs = array($v, |
|
| 130 | + $v * (1-$s), |
|
| 131 | + $v * (1-$f * $s), |
|
| 132 | + $v * (1-(1-$f) * $s)); |
|
| 133 | 133 | |
| 134 | 134 | $perm = array(array(0, 3, 1), |
| 135 | 135 | array(2, 0, 1), |
@@ -144,71 +144,71 @@ discard block |
||
| 144 | 144 | $a); |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - public function hue($color){ |
|
| 147 | + public function hue($color) { |
|
| 148 | 148 | $c = $color->toHSL(); |
| 149 | 149 | return new Less_Tree_Dimension(Less_Parser::round($c['h'])); |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - public function saturation($color){ |
|
| 152 | + public function saturation($color) { |
|
| 153 | 153 | $c = $color->toHSL(); |
| 154 | 154 | return new Less_Tree_Dimension(Less_Parser::round($c['s'] * 100), '%'); |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - public function lightness($color){ |
|
| 157 | + public function lightness($color) { |
|
| 158 | 158 | $c = $color->toHSL(); |
| 159 | 159 | return new Less_Tree_Dimension(Less_Parser::round($c['l'] * 100), '%'); |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - public function hsvhue( $color ){ |
|
| 162 | + public function hsvhue($color) { |
|
| 163 | 163 | $hsv = $color->toHSV(); |
| 164 | - return new Less_Tree_Dimension( Less_Parser::round($hsv['h']) ); |
|
| 164 | + return new Less_Tree_Dimension(Less_Parser::round($hsv['h'])); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | |
| 168 | - public function hsvsaturation( $color ){ |
|
| 168 | + public function hsvsaturation($color) { |
|
| 169 | 169 | $hsv = $color->toHSV(); |
| 170 | - return new Less_Tree_Dimension( Less_Parser::round($hsv['s'] * 100), '%' ); |
|
| 170 | + return new Less_Tree_Dimension(Less_Parser::round($hsv['s'] * 100), '%'); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - public function hsvvalue( $color ){ |
|
| 173 | + public function hsvvalue($color) { |
|
| 174 | 174 | $hsv = $color->toHSV(); |
| 175 | - return new Less_Tree_Dimension( Less_Parser::round($hsv['v'] * 100), '%' ); |
|
| 175 | + return new Less_Tree_Dimension(Less_Parser::round($hsv['v'] * 100), '%'); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | public function red($color) { |
| 179 | - return new Less_Tree_Dimension( $color->rgb[0] ); |
|
| 179 | + return new Less_Tree_Dimension($color->rgb[0]); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | public function green($color) { |
| 183 | - return new Less_Tree_Dimension( $color->rgb[1] ); |
|
| 183 | + return new Less_Tree_Dimension($color->rgb[1]); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | public function blue($color) { |
| 187 | - return new Less_Tree_Dimension( $color->rgb[2] ); |
|
| 187 | + return new Less_Tree_Dimension($color->rgb[2]); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - public function alpha($color){ |
|
| 190 | + public function alpha($color) { |
|
| 191 | 191 | $c = $color->toHSL(); |
| 192 | 192 | return new Less_Tree_Dimension($c['a']); |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - public function luma ($color) { |
|
| 196 | - return new Less_Tree_Dimension(Less_Parser::round( $color->luma() * $color->alpha * 100), '%'); |
|
| 195 | + public function luma($color) { |
|
| 196 | + return new Less_Tree_Dimension(Less_Parser::round($color->luma() * $color->alpha * 100), '%'); |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | - public function luminance( $color ){ |
|
| 199 | + public function luminance($color) { |
|
| 200 | 200 | $luminance = |
| 201 | 201 | (0.2126 * $color->rgb[0] / 255) |
| 202 | 202 | + (0.7152 * $color->rgb[1] / 255) |
| 203 | 203 | + (0.0722 * $color->rgb[2] / 255); |
| 204 | 204 | |
| 205 | - return new Less_Tree_Dimension(Less_Parser::round( $luminance * $color->alpha * 100), '%'); |
|
| 205 | + return new Less_Tree_Dimension(Less_Parser::round($luminance * $color->alpha * 100), '%'); |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - public function saturate($color, $amount = null){ |
|
| 208 | + public function saturate($color, $amount = null) { |
|
| 209 | 209 | // filter: saturate(3.2); |
| 210 | 210 | // should be kept as is, so check for color |
| 211 | - if( !property_exists($color,'rgb') ){ |
|
| 211 | + if (!property_exists($color, 'rgb')) { |
|
| 212 | 212 | return null; |
| 213 | 213 | } |
| 214 | 214 | $hsl = $color->toHSL(); |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | /** |
| 223 | 223 | * @param Less_Tree_Dimension $amount |
| 224 | 224 | */ |
| 225 | - public function desaturate($color, $amount){ |
|
| 225 | + public function desaturate($color, $amount) { |
|
| 226 | 226 | $hsl = $color->toHSL(); |
| 227 | 227 | |
| 228 | 228 | $hsl['s'] -= $amount->value / 100; |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | |
| 234 | 234 | |
| 235 | 235 | |
| 236 | - public function lighten($color, $amount){ |
|
| 236 | + public function lighten($color, $amount) { |
|
| 237 | 237 | $hsl = $color->toHSL(); |
| 238 | 238 | |
| 239 | 239 | $hsl['l'] += $amount->value / 100; |
@@ -242,9 +242,9 @@ discard block |
||
| 242 | 242 | return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']); |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | - public function darken($color, $amount){ |
|
| 245 | + public function darken($color, $amount) { |
|
| 246 | 246 | |
| 247 | - if( $color instanceof Less_Tree_Color ){ |
|
| 247 | + if ($color instanceof Less_Tree_Color) { |
|
| 248 | 248 | $hsl = $color->toHSL(); |
| 249 | 249 | $hsl['l'] -= $amount->value / 100; |
| 250 | 250 | $hsl['l'] = self::clamp($hsl['l']); |
@@ -252,24 +252,24 @@ discard block |
||
| 252 | 252 | return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']); |
| 253 | 253 | } |
| 254 | 254 | |
| 255 | - Less_Functions::Expected('color',$color); |
|
| 255 | + Less_Functions::Expected('color', $color); |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | - public function fadein($color, $amount){ |
|
| 258 | + public function fadein($color, $amount) { |
|
| 259 | 259 | $hsl = $color->toHSL(); |
| 260 | 260 | $hsl['a'] += $amount->value / 100; |
| 261 | 261 | $hsl['a'] = self::clamp($hsl['a']); |
| 262 | 262 | return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']); |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | - public function fadeout($color, $amount){ |
|
| 265 | + public function fadeout($color, $amount) { |
|
| 266 | 266 | $hsl = $color->toHSL(); |
| 267 | 267 | $hsl['a'] -= $amount->value / 100; |
| 268 | 268 | $hsl['a'] = self::clamp($hsl['a']); |
| 269 | 269 | return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']); |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | - public function fade($color, $amount){ |
|
| 272 | + public function fade($color, $amount) { |
|
| 273 | 273 | $hsl = $color->toHSL(); |
| 274 | 274 | |
| 275 | 275 | $hsl['a'] = $amount->value / 100; |
@@ -279,11 +279,11 @@ discard block |
||
| 279 | 279 | |
| 280 | 280 | |
| 281 | 281 | |
| 282 | - public function spin($color, $amount){ |
|
| 282 | + public function spin($color, $amount) { |
|
| 283 | 283 | $hsl = $color->toHSL(); |
| 284 | - $hue = fmod($hsl['h'] + $amount->value, 360); |
|
| 284 | + $hue = fmod($hsl['h']+$amount->value, 360); |
|
| 285 | 285 | |
| 286 | - $hsl['h'] = $hue < 0 ? 360 + $hue : $hue; |
|
| 286 | + $hsl['h'] = $hue<0 ? 360+$hue : $hue; |
|
| 287 | 287 | |
| 288 | 288 | return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']); |
| 289 | 289 | } |
@@ -296,75 +296,75 @@ discard block |
||
| 296 | 296 | /** |
| 297 | 297 | * @param Less_Tree_Color $color1 |
| 298 | 298 | */ |
| 299 | - public function mix($color1, $color2, $weight = null){ |
|
| 299 | + public function mix($color1, $color2, $weight = null) { |
|
| 300 | 300 | if (!$weight) { |
| 301 | 301 | $weight = new Less_Tree_Dimension('50', '%'); |
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | $p = $weight->value / 100.0; |
| 305 | - $w = $p * 2 - 1; |
|
| 305 | + $w = $p * 2-1; |
|
| 306 | 306 | $hsl1 = $color1->toHSL(); |
| 307 | 307 | $hsl2 = $color2->toHSL(); |
| 308 | - $a = $hsl1['a'] - $hsl2['a']; |
|
| 308 | + $a = $hsl1['a']-$hsl2['a']; |
|
| 309 | 309 | |
| 310 | - $w1 = (((($w * $a) == -1) ? $w : ($w + $a) / (1 + $w * $a)) + 1) / 2; |
|
| 311 | - $w2 = 1 - $w1; |
|
| 310 | + $w1 = (((($w * $a)==-1) ? $w : ($w+$a) / (1+$w * $a))+1) / 2; |
|
| 311 | + $w2 = 1-$w1; |
|
| 312 | 312 | |
| 313 | - $rgb = array($color1->rgb[0] * $w1 + $color2->rgb[0] * $w2, |
|
| 314 | - $color1->rgb[1] * $w1 + $color2->rgb[1] * $w2, |
|
| 315 | - $color1->rgb[2] * $w1 + $color2->rgb[2] * $w2); |
|
| 313 | + $rgb = array($color1->rgb[0] * $w1+$color2->rgb[0] * $w2, |
|
| 314 | + $color1->rgb[1] * $w1+$color2->rgb[1] * $w2, |
|
| 315 | + $color1->rgb[2] * $w1+$color2->rgb[2] * $w2); |
|
| 316 | 316 | |
| 317 | - $alpha = $color1->alpha * $p + $color2->alpha * (1 - $p); |
|
| 317 | + $alpha = $color1->alpha * $p+$color2->alpha * (1-$p); |
|
| 318 | 318 | |
| 319 | 319 | return new Less_Tree_Color($rgb, $alpha); |
| 320 | 320 | } |
| 321 | 321 | |
| 322 | - public function greyscale($color){ |
|
| 322 | + public function greyscale($color) { |
|
| 323 | 323 | return $this->desaturate($color, new Less_Tree_Dimension(100)); |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | |
| 327 | - public function contrast( $color, $dark = null, $light = null, $threshold = null){ |
|
| 327 | + public function contrast($color, $dark = null, $light = null, $threshold = null) { |
|
| 328 | 328 | // filter: contrast(3.2); |
| 329 | 329 | // should be kept as is, so check for color |
| 330 | - if( !property_exists($color,'rgb') ){ |
|
| 330 | + if (!property_exists($color, 'rgb')) { |
|
| 331 | 331 | return null; |
| 332 | 332 | } |
| 333 | - if( !$light ){ |
|
| 333 | + if (!$light) { |
|
| 334 | 334 | $light = $this->rgba(255, 255, 255, 1.0); |
| 335 | 335 | } |
| 336 | - if( !$dark ){ |
|
| 336 | + if (!$dark) { |
|
| 337 | 337 | $dark = $this->rgba(0, 0, 0, 1.0); |
| 338 | 338 | } |
| 339 | 339 | //Figure out which is actually light and dark! |
| 340 | - if( $dark->luma() > $light->luma() ){ |
|
| 340 | + if ($dark->luma()>$light->luma()) { |
|
| 341 | 341 | $t = $light; |
| 342 | 342 | $light = $dark; |
| 343 | 343 | $dark = $t; |
| 344 | 344 | } |
| 345 | - if( !$threshold ){ |
|
| 345 | + if (!$threshold) { |
|
| 346 | 346 | $threshold = 0.43; |
| 347 | - } else { |
|
| 347 | + }else { |
|
| 348 | 348 | $threshold = Less_Functions::number($threshold); |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | - if( $color->luma() < $threshold ){ |
|
| 351 | + if ($color->luma()<$threshold) { |
|
| 352 | 352 | return $light; |
| 353 | - } else { |
|
| 353 | + }else { |
|
| 354 | 354 | return $dark; |
| 355 | 355 | } |
| 356 | 356 | } |
| 357 | 357 | |
| 358 | - public function e ($str){ |
|
| 359 | - if( is_string($str) ){ |
|
| 358 | + public function e($str) { |
|
| 359 | + if (is_string($str)) { |
|
| 360 | 360 | return new Less_Tree_Anonymous($str); |
| 361 | 361 | } |
| 362 | 362 | return new Less_Tree_Anonymous($str instanceof Less_Tree_JavaScript ? $str->expression : $str->value); |
| 363 | 363 | } |
| 364 | 364 | |
| 365 | - public function escape ($str){ |
|
| 365 | + public function escape($str) { |
|
| 366 | 366 | |
| 367 | - $revert = array('%21'=>'!', '%2A'=>'*', '%27'=>"'",'%3F'=>'?','%26'=>'&','%2C'=>',','%2F'=>'/','%40'=>'@','%2B'=>'+','%24'=>'$'); |
|
| 367 | + $revert = array('%21'=>'!', '%2A'=>'*', '%27'=>"'", '%3F'=>'?', '%26'=>'&', '%2C'=>',', '%2F'=>'/', '%40'=>'@', '%2B'=>'+', '%24'=>'$'); |
|
| 368 | 368 | |
| 369 | 369 | return new Less_Tree_Anonymous(strtr(rawurlencode($str->value), $revert)); |
| 370 | 370 | } |
@@ -374,29 +374,29 @@ discard block |
||
| 374 | 374 | * todo: This function will need some additional work to make it work the same as less.js |
| 375 | 375 | * |
| 376 | 376 | */ |
| 377 | - public function replace( $string, $pattern, $replacement, $flags = null ){ |
|
| 377 | + public function replace($string, $pattern, $replacement, $flags = null) { |
|
| 378 | 378 | $result = $string->value; |
| 379 | 379 | |
| 380 | - $expr = '/'.str_replace('/','\\/',$pattern->value).'/'; |
|
| 381 | - if( $flags && $flags->value){ |
|
| 380 | + $expr = '/'.str_replace('/', '\\/', $pattern->value).'/'; |
|
| 381 | + if ($flags && $flags->value) { |
|
| 382 | 382 | $expr .= self::replace_flags($flags->value); |
| 383 | 383 | } |
| 384 | 384 | |
| 385 | - $result = preg_replace($expr,$replacement->value,$result); |
|
| 385 | + $result = preg_replace($expr, $replacement->value, $result); |
|
| 386 | 386 | |
| 387 | 387 | |
| 388 | - if( property_exists($string,'quote') ){ |
|
| 389 | - return new Less_Tree_Quoted( $string->quote, $result, $string->escaped); |
|
| 388 | + if (property_exists($string, 'quote')) { |
|
| 389 | + return new Less_Tree_Quoted($string->quote, $result, $string->escaped); |
|
| 390 | 390 | } |
| 391 | - return new Less_Tree_Quoted( '', $result ); |
|
| 391 | + return new Less_Tree_Quoted('', $result); |
|
| 392 | 392 | } |
| 393 | 393 | |
| 394 | - public static function replace_flags($flags){ |
|
| 395 | - $flags = str_split($flags,1); |
|
| 394 | + public static function replace_flags($flags) { |
|
| 395 | + $flags = str_split($flags, 1); |
|
| 396 | 396 | $new_flags = ''; |
| 397 | 397 | |
| 398 | - foreach($flags as $flag){ |
|
| 399 | - switch($flag){ |
|
| 398 | + foreach ($flags as $flag) { |
|
| 399 | + switch ($flag) { |
|
| 400 | 400 | case 'e': |
| 401 | 401 | case 'g': |
| 402 | 402 | break; |
@@ -410,91 +410,91 @@ discard block |
||
| 410 | 410 | return $new_flags; |
| 411 | 411 | } |
| 412 | 412 | |
| 413 | - public function _percent(){ |
|
| 413 | + public function _percent() { |
|
| 414 | 414 | $string = func_get_arg(0); |
| 415 | 415 | |
| 416 | 416 | $args = func_get_args(); |
| 417 | 417 | array_shift($args); |
| 418 | 418 | $result = $string->value; |
| 419 | 419 | |
| 420 | - foreach($args as $arg){ |
|
| 421 | - if( preg_match('/%[sda]/i',$result, $token) ){ |
|
| 420 | + foreach ($args as $arg) { |
|
| 421 | + if (preg_match('/%[sda]/i', $result, $token)) { |
|
| 422 | 422 | $token = $token[0]; |
| 423 | 423 | $value = stristr($token, 's') ? $arg->value : $arg->toCSS(); |
| 424 | 424 | $value = preg_match('/[A-Z]$/', $token) ? urlencode($value) : $value; |
| 425 | - $result = preg_replace('/%[sda]/i',$value, $result, 1); |
|
| 425 | + $result = preg_replace('/%[sda]/i', $value, $result, 1); |
|
| 426 | 426 | } |
| 427 | 427 | } |
| 428 | 428 | $result = str_replace('%%', '%', $result); |
| 429 | 429 | |
| 430 | - return new Less_Tree_Quoted( $string->quote , $result, $string->escaped); |
|
| 430 | + return new Less_Tree_Quoted($string->quote, $result, $string->escaped); |
|
| 431 | 431 | } |
| 432 | 432 | |
| 433 | - public function unit( $val, $unit = null) { |
|
| 434 | - if( !($val instanceof Less_Tree_Dimension) ){ |
|
| 435 | - throw new Less_Exception_Compiler('The first argument to unit must be a number' . ($val instanceof Less_Tree_Operation ? '. Have you forgotten parenthesis?' : '.') ); |
|
| 433 | + public function unit($val, $unit = null) { |
|
| 434 | + if (!($val instanceof Less_Tree_Dimension)) { |
|
| 435 | + throw new Less_Exception_Compiler('The first argument to unit must be a number'.($val instanceof Less_Tree_Operation ? '. Have you forgotten parenthesis?' : '.')); |
|
| 436 | 436 | } |
| 437 | 437 | |
| 438 | - if( $unit ){ |
|
| 439 | - if( $unit instanceof Less_Tree_Keyword ){ |
|
| 438 | + if ($unit) { |
|
| 439 | + if ($unit instanceof Less_Tree_Keyword) { |
|
| 440 | 440 | $unit = $unit->value; |
| 441 | - } else { |
|
| 441 | + }else { |
|
| 442 | 442 | $unit = $unit->toCSS(); |
| 443 | 443 | } |
| 444 | - } else { |
|
| 444 | + }else { |
|
| 445 | 445 | $unit = ""; |
| 446 | 446 | } |
| 447 | - return new Less_Tree_Dimension($val->value, $unit ); |
|
| 447 | + return new Less_Tree_Dimension($val->value, $unit); |
|
| 448 | 448 | } |
| 449 | 449 | |
| 450 | - public function convert($val, $unit){ |
|
| 450 | + public function convert($val, $unit) { |
|
| 451 | 451 | return $val->convertTo($unit->value); |
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | public function round($n, $f = false) { |
| 455 | 455 | |
| 456 | 456 | $fraction = 0; |
| 457 | - if( $f !== false ){ |
|
| 457 | + if ($f!==false) { |
|
| 458 | 458 | $fraction = $f->value; |
| 459 | 459 | } |
| 460 | 460 | |
| 461 | - return $this->_math('Less_Parser::round',null, $n, $fraction); |
|
| 461 | + return $this->_math('Less_Parser::round', null, $n, $fraction); |
|
| 462 | 462 | } |
| 463 | 463 | |
| 464 | - public function pi(){ |
|
| 464 | + public function pi() { |
|
| 465 | 465 | return new Less_Tree_Dimension(M_PI); |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | 468 | public function mod($a, $b) { |
| 469 | - return new Less_Tree_Dimension( $a->value % $b->value, $a->unit); |
|
| 469 | + return new Less_Tree_Dimension($a->value % $b->value, $a->unit); |
|
| 470 | 470 | } |
| 471 | 471 | |
| 472 | 472 | |
| 473 | 473 | |
| 474 | 474 | public function pow($x, $y) { |
| 475 | - if( is_numeric($x) && is_numeric($y) ){ |
|
| 475 | + if (is_numeric($x) && is_numeric($y)) { |
|
| 476 | 476 | $x = new Less_Tree_Dimension($x); |
| 477 | 477 | $y = new Less_Tree_Dimension($y); |
| 478 | - }elseif( !($x instanceof Less_Tree_Dimension) || !($y instanceof Less_Tree_Dimension) ){ |
|
| 478 | + }elseif (!($x instanceof Less_Tree_Dimension) || !($y instanceof Less_Tree_Dimension)) { |
|
| 479 | 479 | throw new Less_Exception_Compiler('Arguments must be numbers'); |
| 480 | 480 | } |
| 481 | 481 | |
| 482 | - return new Less_Tree_Dimension( pow($x->value, $y->value), $x->unit ); |
|
| 482 | + return new Less_Tree_Dimension(pow($x->value, $y->value), $x->unit); |
|
| 483 | 483 | } |
| 484 | 484 | |
| 485 | 485 | // var mathFunctions = [{name:"ce ... |
| 486 | - public function ceil( $n ){ return $this->_math('ceil', null, $n); } |
|
| 487 | - public function floor( $n ){ return $this->_math('floor', null, $n); } |
|
| 488 | - public function sqrt( $n ){ return $this->_math('sqrt', null, $n); } |
|
| 489 | - public function abs( $n ){ return $this->_math('abs', null, $n); } |
|
| 486 | + public function ceil($n) { return $this->_math('ceil', null, $n); } |
|
| 487 | + public function floor($n) { return $this->_math('floor', null, $n); } |
|
| 488 | + public function sqrt($n) { return $this->_math('sqrt', null, $n); } |
|
| 489 | + public function abs($n) { return $this->_math('abs', null, $n); } |
|
| 490 | 490 | |
| 491 | - public function tan( $n ){ return $this->_math('tan', '', $n); } |
|
| 492 | - public function sin( $n ){ return $this->_math('sin', '', $n); } |
|
| 493 | - public function cos( $n ){ return $this->_math('cos', '', $n); } |
|
| 491 | + public function tan($n) { return $this->_math('tan', '', $n); } |
|
| 492 | + public function sin($n) { return $this->_math('sin', '', $n); } |
|
| 493 | + public function cos($n) { return $this->_math('cos', '', $n); } |
|
| 494 | 494 | |
| 495 | - public function atan( $n ){ return $this->_math('atan', 'rad', $n); } |
|
| 496 | - public function asin( $n ){ return $this->_math('asin', 'rad', $n); } |
|
| 497 | - public function acos( $n ){ return $this->_math('acos', 'rad', $n); } |
|
| 495 | + public function atan($n) { return $this->_math('atan', 'rad', $n); } |
|
| 496 | + public function asin($n) { return $this->_math('asin', 'rad', $n); } |
|
| 497 | + public function acos($n) { return $this->_math('acos', 'rad', $n); } |
|
| 498 | 498 | |
| 499 | 499 | private function _math() { |
| 500 | 500 | $args = func_get_args(); |
@@ -503,16 +503,16 @@ discard block |
||
| 503 | 503 | |
| 504 | 504 | if ($args[0] instanceof Less_Tree_Dimension) { |
| 505 | 505 | |
| 506 | - if( $unit === null ){ |
|
| 506 | + if ($unit===null) { |
|
| 507 | 507 | $unit = $args[0]->unit; |
| 508 | - }else{ |
|
| 508 | + }else { |
|
| 509 | 509 | $args[0] = $args[0]->unify(); |
| 510 | 510 | } |
| 511 | 511 | $args[0] = (float)$args[0]->value; |
| 512 | - return new Less_Tree_Dimension( call_user_func_array($fn, $args), $unit); |
|
| 513 | - } else if (is_numeric($args[0])) { |
|
| 514 | - return call_user_func_array($fn,$args); |
|
| 515 | - } else { |
|
| 512 | + return new Less_Tree_Dimension(call_user_func_array($fn, $args), $unit); |
|
| 513 | + }else if (is_numeric($args[0])) { |
|
| 514 | + return call_user_func_array($fn, $args); |
|
| 515 | + }else { |
|
| 516 | 516 | throw new Less_Exception_Compiler("math functions take numbers as parameters"); |
| 517 | 517 | } |
| 518 | 518 | } |
@@ -520,12 +520,12 @@ discard block |
||
| 520 | 520 | /** |
| 521 | 521 | * @param boolean $isMin |
| 522 | 522 | */ |
| 523 | - private function _minmax( $isMin, $args ){ |
|
| 523 | + private function _minmax($isMin, $args) { |
|
| 524 | 524 | |
| 525 | 525 | $arg_count = count($args); |
| 526 | 526 | |
| 527 | - if( $arg_count < 1 ){ |
|
| 528 | - throw new Less_Exception_Compiler( 'one or more arguments required'); |
|
| 527 | + if ($arg_count<1) { |
|
| 528 | + throw new Less_Exception_Compiler('one or more arguments required'); |
|
| 529 | 529 | } |
| 530 | 530 | |
| 531 | 531 | $j = null; |
@@ -533,49 +533,49 @@ discard block |
||
| 533 | 533 | $unitStatic = null; |
| 534 | 534 | |
| 535 | 535 | |
| 536 | - $order = array(); // elems only contains original argument values. |
|
| 537 | - $values = array(); // key is the unit.toString() for unified tree.Dimension values, |
|
| 536 | + $order = array(); // elems only contains original argument values. |
|
| 537 | + $values = array(); // key is the unit.toString() for unified tree.Dimension values, |
|
| 538 | 538 | // value is the index into the order array. |
| 539 | 539 | |
| 540 | 540 | |
| 541 | - for( $i = 0; $i < $arg_count; $i++ ){ |
|
| 541 | + for ($i = 0; $i<$arg_count; $i++) { |
|
| 542 | 542 | $current = $args[$i]; |
| 543 | - if( !($current instanceof Less_Tree_Dimension) ){ |
|
| 544 | - if( is_array($args[$i]->value) ){ |
|
| 543 | + if (!($current instanceof Less_Tree_Dimension)) { |
|
| 544 | + if (is_array($args[$i]->value)) { |
|
| 545 | 545 | $args[] = $args[$i]->value; |
| 546 | 546 | } |
| 547 | 547 | continue; |
| 548 | 548 | } |
| 549 | 549 | |
| 550 | - if( $current->unit->toString() === '' && !$unitClone ){ |
|
| 550 | + if ($current->unit->toString()==='' && !$unitClone) { |
|
| 551 | 551 | $temp = new Less_Tree_Dimension($current->value, $unitClone); |
| 552 | 552 | $currentUnified = $temp->unify(); |
| 553 | - }else{ |
|
| 553 | + }else { |
|
| 554 | 554 | $currentUnified = $current->unify(); |
| 555 | 555 | } |
| 556 | 556 | |
| 557 | - if( $currentUnified->unit->toString() === "" && !$unitStatic ){ |
|
| 557 | + if ($currentUnified->unit->toString()==="" && !$unitStatic) { |
|
| 558 | 558 | $unit = $unitStatic; |
| 559 | - }else{ |
|
| 559 | + }else { |
|
| 560 | 560 | $unit = $currentUnified->unit->toString(); |
| 561 | 561 | } |
| 562 | 562 | |
| 563 | - if( $unit !== '' && !$unitStatic || $unit !== '' && $order[0]->unify()->unit->toString() === "" ){ |
|
| 563 | + if ($unit!=='' && !$unitStatic || $unit!=='' && $order[0]->unify()->unit->toString()==="") { |
|
| 564 | 564 | $unitStatic = $unit; |
| 565 | 565 | } |
| 566 | 566 | |
| 567 | - if( $unit != '' && !$unitClone ){ |
|
| 567 | + if ($unit!='' && !$unitClone) { |
|
| 568 | 568 | $unitClone = $current->unit->toString(); |
| 569 | 569 | } |
| 570 | 570 | |
| 571 | - if( isset($values['']) && $unit !== '' && $unit === $unitStatic ){ |
|
| 571 | + if (isset($values['']) && $unit!=='' && $unit===$unitStatic) { |
|
| 572 | 572 | $j = $values['']; |
| 573 | - }elseif( isset($values[$unit]) ){ |
|
| 573 | + }elseif (isset($values[$unit])) { |
|
| 574 | 574 | $j = $values[$unit]; |
| 575 | - }else{ |
|
| 575 | + }else { |
|
| 576 | 576 | |
| 577 | - if( $unitStatic && $unit !== $unitStatic ){ |
|
| 578 | - throw new Less_Exception_Compiler( 'incompatible types'); |
|
| 577 | + if ($unitStatic && $unit!==$unitStatic) { |
|
| 578 | + throw new Less_Exception_Compiler('incompatible types'); |
|
| 579 | 579 | } |
| 580 | 580 | $values[$unit] = count($order); |
| 581 | 581 | $order[] = $current; |
@@ -583,38 +583,38 @@ discard block |
||
| 583 | 583 | } |
| 584 | 584 | |
| 585 | 585 | |
| 586 | - if( $order[$j]->unit->toString() === "" && $unitClone ){ |
|
| 587 | - $temp = new Less_Tree_Dimension( $order[$j]->value, $unitClone); |
|
| 586 | + if ($order[$j]->unit->toString()==="" && $unitClone) { |
|
| 587 | + $temp = new Less_Tree_Dimension($order[$j]->value, $unitClone); |
|
| 588 | 588 | $referenceUnified = $temp->unifiy(); |
| 589 | - }else{ |
|
| 589 | + }else { |
|
| 590 | 590 | $referenceUnified = $order[$j]->unify(); |
| 591 | 591 | } |
| 592 | - if( ($isMin && $currentUnified->value < $referenceUnified->value) || (!$isMin && $currentUnified->value > $referenceUnified->value) ){ |
|
| 592 | + if (($isMin && $currentUnified->value<$referenceUnified->value) || (!$isMin && $currentUnified->value>$referenceUnified->value)) { |
|
| 593 | 593 | $order[$j] = $current; |
| 594 | 594 | } |
| 595 | 595 | } |
| 596 | 596 | |
| 597 | - if( count($order) == 1 ){ |
|
| 597 | + if (count($order)==1) { |
|
| 598 | 598 | return $order[0]; |
| 599 | 599 | } |
| 600 | 600 | $args = array(); |
| 601 | - foreach($order as $a){ |
|
| 601 | + foreach ($order as $a) { |
|
| 602 | 602 | $args[] = $a->toCSS($this->env); |
| 603 | 603 | } |
| 604 | - return new Less_Tree_Anonymous( ($isMin?'min(':'max(') . implode(Less_Environment::$_outputMap[','],$args).')'); |
|
| 604 | + return new Less_Tree_Anonymous(($isMin ? 'min(' : 'max(').implode(Less_Environment::$_outputMap[','], $args).')'); |
|
| 605 | 605 | } |
| 606 | 606 | |
| 607 | - public function min(){ |
|
| 607 | + public function min() { |
|
| 608 | 608 | $args = func_get_args(); |
| 609 | - return $this->_minmax( true, $args ); |
|
| 609 | + return $this->_minmax(true, $args); |
|
| 610 | 610 | } |
| 611 | 611 | |
| 612 | - public function max(){ |
|
| 612 | + public function max() { |
|
| 613 | 613 | $args = func_get_args(); |
| 614 | - return $this->_minmax( false, $args ); |
|
| 614 | + return $this->_minmax(false, $args); |
|
| 615 | 615 | } |
| 616 | 616 | |
| 617 | - public function getunit($n){ |
|
| 617 | + public function getunit($n) { |
|
| 618 | 618 | return new Less_Tree_Anonymous($n->unit); |
| 619 | 619 | } |
| 620 | 620 | |
@@ -628,17 +628,17 @@ discard block |
||
| 628 | 628 | |
| 629 | 629 | public function color($n) { |
| 630 | 630 | |
| 631 | - if( $n instanceof Less_Tree_Quoted ){ |
|
| 631 | + if ($n instanceof Less_Tree_Quoted) { |
|
| 632 | 632 | $colorCandidate = $n->value; |
| 633 | 633 | $returnColor = Less_Tree_Color::fromKeyword($colorCandidate); |
| 634 | - if( $returnColor ){ |
|
| 634 | + if ($returnColor) { |
|
| 635 | 635 | return $returnColor; |
| 636 | 636 | } |
| 637 | - if( preg_match('/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})/',$colorCandidate) ){ |
|
| 637 | + if (preg_match('/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})/', $colorCandidate)) { |
|
| 638 | 638 | return new Less_Tree_Color(substr($colorCandidate, 1)); |
| 639 | 639 | } |
| 640 | 640 | throw new Less_Exception_Compiler("argument must be a color keyword or 3/6 digit hex e.g. #FFF"); |
| 641 | - } else { |
|
| 641 | + }else { |
|
| 642 | 642 | throw new Less_Exception_Compiler("argument must be a string"); |
| 643 | 643 | } |
| 644 | 644 | } |
@@ -679,8 +679,8 @@ discard block |
||
| 679 | 679 | /** |
| 680 | 680 | * @param string $unit |
| 681 | 681 | */ |
| 682 | - public function isunit( $n, $unit ){ |
|
| 683 | - return ($n instanceof Less_Tree_Dimension) && $n->unit->is( ( property_exists($unit,'value') ? $unit->value : $unit) ) ? new Less_Tree_Keyword('true') : new Less_Tree_Keyword('false'); |
|
| 682 | + public function isunit($n, $unit) { |
|
| 683 | + return ($n instanceof Less_Tree_Dimension) && $n->unit->is((property_exists($unit, 'value') ? $unit->value : $unit)) ? new Less_Tree_Keyword('true') : new Less_Tree_Keyword('false'); |
|
| 684 | 684 | } |
| 685 | 685 | |
| 686 | 686 | /** |
@@ -691,64 +691,64 @@ discard block |
||
| 691 | 691 | } |
| 692 | 692 | |
| 693 | 693 | public function tint($color, $amount) { |
| 694 | - return $this->mix( $this->rgb(255,255,255), $color, $amount); |
|
| 694 | + return $this->mix($this->rgb(255, 255, 255), $color, $amount); |
|
| 695 | 695 | } |
| 696 | 696 | |
| 697 | 697 | public function shade($color, $amount) { |
| 698 | 698 | return $this->mix($this->rgb(0, 0, 0), $color, $amount); |
| 699 | 699 | } |
| 700 | 700 | |
| 701 | - public function extract($values, $index ){ |
|
| 702 | - $index = (int)$index->value - 1; // (1-based index) |
|
| 701 | + public function extract($values, $index) { |
|
| 702 | + $index = (int)$index->value-1; // (1-based index) |
|
| 703 | 703 | // handle non-array values as an array of length 1 |
| 704 | 704 | // return 'undefined' if index is invalid |
| 705 | - if( property_exists($values,'value') && is_array($values->value) ){ |
|
| 706 | - if( isset($values->value[$index]) ){ |
|
| 705 | + if (property_exists($values, 'value') && is_array($values->value)) { |
|
| 706 | + if (isset($values->value[$index])) { |
|
| 707 | 707 | return $values->value[$index]; |
| 708 | 708 | } |
| 709 | 709 | return null; |
| 710 | 710 | |
| 711 | - }elseif( (int)$index === 0 ){ |
|
| 711 | + }elseif ((int)$index===0) { |
|
| 712 | 712 | return $values; |
| 713 | 713 | } |
| 714 | 714 | |
| 715 | 715 | return null; |
| 716 | 716 | } |
| 717 | 717 | |
| 718 | - public function length($values){ |
|
| 719 | - $n = (property_exists($values,'value') && is_array($values->value)) ? count($values->value) : 1; |
|
| 718 | + public function length($values) { |
|
| 719 | + $n = (property_exists($values, 'value') && is_array($values->value)) ? count($values->value) : 1; |
|
| 720 | 720 | return new Less_Tree_Dimension($n); |
| 721 | 721 | } |
| 722 | 722 | |
| 723 | - public function datauri($mimetypeNode, $filePathNode = null ) { |
|
| 723 | + public function datauri($mimetypeNode, $filePathNode = null) { |
|
| 724 | 724 | |
| 725 | - $filePath = ( $filePathNode ? $filePathNode->value : null ); |
|
| 725 | + $filePath = ($filePathNode ? $filePathNode->value : null); |
|
| 726 | 726 | $mimetype = $mimetypeNode->value; |
| 727 | 727 | |
| 728 | 728 | $args = 2; |
| 729 | - if( !$filePath ){ |
|
| 729 | + if (!$filePath) { |
|
| 730 | 730 | $filePath = $mimetype; |
| 731 | 731 | $args = 1; |
| 732 | 732 | } |
| 733 | 733 | |
| 734 | - $filePath = str_replace('\\','/',$filePath); |
|
| 735 | - if( Less_Environment::isPathRelative($filePath) ){ |
|
| 734 | + $filePath = str_replace('\\', '/', $filePath); |
|
| 735 | + if (Less_Environment::isPathRelative($filePath)) { |
|
| 736 | 736 | |
| 737 | - if( Less_Parser::$options['relativeUrls'] ){ |
|
| 737 | + if (Less_Parser::$options['relativeUrls']) { |
|
| 738 | 738 | $temp = $this->currentFileInfo['currentDirectory']; |
| 739 | - } else { |
|
| 739 | + }else { |
|
| 740 | 740 | $temp = $this->currentFileInfo['entryPath']; |
| 741 | 741 | } |
| 742 | 742 | |
| 743 | - if( !empty($temp) ){ |
|
| 744 | - $filePath = Less_Environment::normalizePath(rtrim($temp,'/').'/'.$filePath); |
|
| 743 | + if (!empty($temp)) { |
|
| 744 | + $filePath = Less_Environment::normalizePath(rtrim($temp, '/').'/'.$filePath); |
|
| 745 | 745 | } |
| 746 | 746 | |
| 747 | 747 | } |
| 748 | 748 | |
| 749 | 749 | |
| 750 | 750 | // detect the mimetype if not given |
| 751 | - if( $args < 2 ){ |
|
| 751 | + if ($args<2) { |
|
| 752 | 752 | |
| 753 | 753 | /* incomplete |
| 754 | 754 | $mime = require('mime'); |
@@ -763,17 +763,17 @@ discard block |
||
| 763 | 763 | $mimetype = Less_Mime::lookup($filePath); |
| 764 | 764 | |
| 765 | 765 | $charset = Less_Mime::charsets_lookup($mimetype); |
| 766 | - $useBase64 = !in_array($charset,array('US-ASCII', 'UTF-8')); |
|
| 767 | - if( $useBase64 ){ $mimetype .= ';base64'; } |
|
| 766 | + $useBase64 = !in_array($charset, array('US-ASCII', 'UTF-8')); |
|
| 767 | + if ($useBase64) { $mimetype .= ';base64'; } |
|
| 768 | 768 | |
| 769 | - }else{ |
|
| 770 | - $useBase64 = preg_match('/;base64$/',$mimetype); |
|
| 769 | + }else { |
|
| 770 | + $useBase64 = preg_match('/;base64$/', $mimetype); |
|
| 771 | 771 | } |
| 772 | 772 | |
| 773 | 773 | |
| 774 | - if( file_exists($filePath) ){ |
|
| 774 | + if (file_exists($filePath)) { |
|
| 775 | 775 | $buf = @file_get_contents($filePath); |
| 776 | - }else{ |
|
| 776 | + }else { |
|
| 777 | 777 | $buf = false; |
| 778 | 778 | } |
| 779 | 779 | |
@@ -781,38 +781,38 @@ discard block |
||
| 781 | 781 | // IE8 cannot handle a data-uri larger than 32KB. If this is exceeded |
| 782 | 782 | // and the --ieCompat flag is enabled, return a normal url() instead. |
| 783 | 783 | $DATA_URI_MAX_KB = 32; |
| 784 | - $fileSizeInKB = round( strlen($buf) / 1024 ); |
|
| 785 | - if( $fileSizeInKB >= $DATA_URI_MAX_KB ){ |
|
| 786 | - $url = new Less_Tree_Url( ($filePathNode ? $filePathNode : $mimetypeNode), $this->currentFileInfo); |
|
| 784 | + $fileSizeInKB = round(strlen($buf) / 1024); |
|
| 785 | + if ($fileSizeInKB>=$DATA_URI_MAX_KB) { |
|
| 786 | + $url = new Less_Tree_Url(($filePathNode ? $filePathNode : $mimetypeNode), $this->currentFileInfo); |
|
| 787 | 787 | return $url->compile($this); |
| 788 | 788 | } |
| 789 | 789 | |
| 790 | - if( $buf ){ |
|
| 790 | + if ($buf) { |
|
| 791 | 791 | $buf = $useBase64 ? base64_encode($buf) : rawurlencode($buf); |
| 792 | - $filePath = '"data:' . $mimetype . ',' . $buf . '"'; |
|
| 792 | + $filePath = '"data:'.$mimetype.','.$buf.'"'; |
|
| 793 | 793 | } |
| 794 | 794 | |
| 795 | - return new Less_Tree_Url( new Less_Tree_Anonymous($filePath) ); |
|
| 795 | + return new Less_Tree_Url(new Less_Tree_Anonymous($filePath)); |
|
| 796 | 796 | } |
| 797 | 797 | |
| 798 | 798 | //svg-gradient |
| 799 | - public function svggradient( $direction ){ |
|
| 799 | + public function svggradient($direction) { |
|
| 800 | 800 | |
| 801 | 801 | $throw_message = 'svg-gradient expects direction, start_color [start_position], [color position,]..., end_color [end_position]'; |
| 802 | 802 | $arguments = func_get_args(); |
| 803 | 803 | |
| 804 | - if( count($arguments) < 3 ){ |
|
| 805 | - throw new Less_Exception_Compiler( $throw_message ); |
|
| 804 | + if (count($arguments)<3) { |
|
| 805 | + throw new Less_Exception_Compiler($throw_message); |
|
| 806 | 806 | } |
| 807 | 807 | |
| 808 | - $stops = array_slice($arguments,1); |
|
| 808 | + $stops = array_slice($arguments, 1); |
|
| 809 | 809 | $gradientType = 'linear'; |
| 810 | 810 | $rectangleDimension = 'x="0" y="0" width="1" height="1"'; |
| 811 | 811 | $useBase64 = true; |
| 812 | 812 | $directionValue = $direction->toCSS(); |
| 813 | 813 | |
| 814 | 814 | |
| 815 | - switch( $directionValue ){ |
|
| 815 | + switch ($directionValue) { |
|
| 816 | 816 | case "to bottom": |
| 817 | 817 | $gradientDirectionSvg = 'x1="0%" y1="0%" x2="0%" y2="100%"'; |
| 818 | 818 | break; |
@@ -832,60 +832,60 @@ discard block |
||
| 832 | 832 | $rectangleDimension = 'x="-50" y="-50" width="101" height="101"'; |
| 833 | 833 | break; |
| 834 | 834 | default: |
| 835 | - throw new Less_Exception_Compiler( "svg-gradient direction must be 'to bottom', 'to right', 'to bottom right', 'to top right' or 'ellipse at center'" ); |
|
| 835 | + throw new Less_Exception_Compiler("svg-gradient direction must be 'to bottom', 'to right', 'to bottom right', 'to top right' or 'ellipse at center'"); |
|
| 836 | 836 | } |
| 837 | 837 | |
| 838 | - $returner = '<?xml version="1.0" ?>' . |
|
| 839 | - '<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="100%" height="100%" viewBox="0 0 1 1" preserveAspectRatio="none">' . |
|
| 840 | - '<' . $gradientType . 'Gradient id="gradient" gradientUnits="userSpaceOnUse" ' . $gradientDirectionSvg . '>'; |
|
| 838 | + $returner = '<?xml version="1.0" ?>'. |
|
| 839 | + '<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="100%" height="100%" viewBox="0 0 1 1" preserveAspectRatio="none">'. |
|
| 840 | + '<'.$gradientType.'Gradient id="gradient" gradientUnits="userSpaceOnUse" '.$gradientDirectionSvg.'>'; |
|
| 841 | 841 | |
| 842 | - for( $i = 0; $i < count($stops); $i++ ){ |
|
| 843 | - if( is_object($stops[$i]) && property_exists($stops[$i],'value') ){ |
|
| 842 | + for ($i = 0; $i<count($stops); $i++) { |
|
| 843 | + if (is_object($stops[$i]) && property_exists($stops[$i], 'value')) { |
|
| 844 | 844 | $color = $stops[$i]->value[0]; |
| 845 | 845 | $position = $stops[$i]->value[1]; |
| 846 | - }else{ |
|
| 846 | + }else { |
|
| 847 | 847 | $color = $stops[$i]; |
| 848 | 848 | $position = null; |
| 849 | 849 | } |
| 850 | 850 | |
| 851 | - if( !($color instanceof Less_Tree_Color) || (!(($i === 0 || $i+1 === count($stops)) && $position === null) && !($position instanceof Less_Tree_Dimension)) ){ |
|
| 852 | - throw new Less_Exception_Compiler( $throw_message ); |
|
| 851 | + if (!($color instanceof Less_Tree_Color) || (!(($i===0 || $i+1===count($stops)) && $position===null) && !($position instanceof Less_Tree_Dimension))) { |
|
| 852 | + throw new Less_Exception_Compiler($throw_message); |
|
| 853 | 853 | } |
| 854 | - if( $position ){ |
|
| 854 | + if ($position) { |
|
| 855 | 855 | $positionValue = $position->toCSS(); |
| 856 | - }elseif( $i === 0 ){ |
|
| 856 | + }elseif ($i===0) { |
|
| 857 | 857 | $positionValue = '0%'; |
| 858 | - }else{ |
|
| 858 | + }else { |
|
| 859 | 859 | $positionValue = '100%'; |
| 860 | 860 | } |
| 861 | 861 | $alpha = $color->alpha; |
| 862 | - $returner .= '<stop offset="' . $positionValue . '" stop-color="' . $color->toRGB() . '"' . ($alpha < 1 ? ' stop-opacity="' . $alpha . '"' : '') . '/>'; |
|
| 862 | + $returner .= '<stop offset="'.$positionValue.'" stop-color="'.$color->toRGB().'"'.($alpha<1 ? ' stop-opacity="'.$alpha.'"' : '').'/>'; |
|
| 863 | 863 | } |
| 864 | 864 | |
| 865 | - $returner .= '</' . $gradientType . 'Gradient><rect ' . $rectangleDimension . ' fill="url(#gradient)" /></svg>'; |
|
| 865 | + $returner .= '</'.$gradientType.'Gradient><rect '.$rectangleDimension.' fill="url(#gradient)" /></svg>'; |
|
| 866 | 866 | |
| 867 | 867 | |
| 868 | - if( $useBase64 ){ |
|
| 868 | + if ($useBase64) { |
|
| 869 | 869 | $returner = "'data:image/svg+xml;base64,".base64_encode($returner)."'"; |
| 870 | - }else{ |
|
| 870 | + }else { |
|
| 871 | 871 | $returner = "'data:image/svg+xml,".$returner."'"; |
| 872 | 872 | } |
| 873 | 873 | |
| 874 | - return new Less_Tree_URL( new Less_Tree_Anonymous( $returner ) ); |
|
| 874 | + return new Less_Tree_URL(new Less_Tree_Anonymous($returner)); |
|
| 875 | 875 | } |
| 876 | 876 | |
| 877 | 877 | |
| 878 | 878 | /** |
| 879 | 879 | * @param string $type |
| 880 | 880 | */ |
| 881 | - private static function Expected( $type, $arg ){ |
|
| 881 | + private static function Expected($type, $arg) { |
|
| 882 | 882 | |
| 883 | 883 | $debug = debug_backtrace(); |
| 884 | 884 | array_shift($debug); |
| 885 | 885 | $last = array_shift($debug); |
| 886 | - $last = array_intersect_key($last,array('function'=>'','class'=>'','line'=>'')); |
|
| 886 | + $last = array_intersect_key($last, array('function'=>'', 'class'=>'', 'line'=>'')); |
|
| 887 | 887 | |
| 888 | - $message = 'Object of type '.get_class($arg).' passed to darken function. Expecting `'.$type.'`. '.$arg->toCSS().'. '.print_r($last,true); |
|
| 888 | + $message = 'Object of type '.get_class($arg).' passed to darken function. Expecting `'.$type.'`. '.$arg->toCSS().'. '.print_r($last, true); |
|
| 889 | 889 | throw new Less_Exception_Compiler($message); |
| 890 | 890 | |
| 891 | 891 | } |
@@ -896,7 +896,7 @@ discard block |
||
| 896 | 896 | * @param string $string The string to encode |
| 897 | 897 | * @return string The encoded string |
| 898 | 898 | */ |
| 899 | - public static function encodeURIComponent($string){ |
|
| 899 | + public static function encodeURIComponent($string) { |
|
| 900 | 900 | $revert = array('%21' => '!', '%2A' => '*', '%27' => "'", '%28' => '(', '%29' => ')'); |
| 901 | 901 | return strtr(rawurlencode($string), $revert); |
| 902 | 902 | } |
@@ -905,18 +905,18 @@ discard block |
||
| 905 | 905 | // Color Blending |
| 906 | 906 | // ref: http://www.w3.org/TR/compositing-1 |
| 907 | 907 | |
| 908 | - public function colorBlend( $mode, $color1, $color2 ){ |
|
| 909 | - $ab = $color1->alpha; // backdrop |
|
| 910 | - $as = $color2->alpha; // source |
|
| 911 | - $r = array(); // result |
|
| 908 | + public function colorBlend($mode, $color1, $color2) { |
|
| 909 | + $ab = $color1->alpha; // backdrop |
|
| 910 | + $as = $color2->alpha; // source |
|
| 911 | + $r = array(); // result |
|
| 912 | 912 | |
| 913 | - $ar = $as + $ab * (1 - $as); |
|
| 914 | - for( $i = 0; $i < 3; $i++ ){ |
|
| 913 | + $ar = $as+$ab * (1-$as); |
|
| 914 | + for ($i = 0; $i<3; $i++) { |
|
| 915 | 915 | $cb = $color1->rgb[$i] / 255; |
| 916 | 916 | $cs = $color2->rgb[$i] / 255; |
| 917 | - $cr = call_user_func( $mode, $cb, $cs ); |
|
| 918 | - if( $ar ){ |
|
| 919 | - $cr = ($as * $cs + $ab * ($cb - $as * ($cb + $cs - $cr))) / $ar; |
|
| 917 | + $cr = call_user_func($mode, $cb, $cs); |
|
| 918 | + if ($ar) { |
|
| 919 | + $cr = ($as * $cs+$ab * ($cb-$as * ($cb+$cs-$cr))) / $ar; |
|
| 920 | 920 | } |
| 921 | 921 | $r[$i] = $cr * 255; |
| 922 | 922 | } |
@@ -924,87 +924,87 @@ discard block |
||
| 924 | 924 | return new Less_Tree_Color($r, $ar); |
| 925 | 925 | } |
| 926 | 926 | |
| 927 | - public function multiply($color1, $color2 ){ |
|
| 928 | - return $this->colorBlend( array($this,'colorBlendMultiply'), $color1, $color2 ); |
|
| 927 | + public function multiply($color1, $color2) { |
|
| 928 | + return $this->colorBlend(array($this, 'colorBlendMultiply'), $color1, $color2); |
|
| 929 | 929 | } |
| 930 | 930 | |
| 931 | - private function colorBlendMultiply($cb, $cs){ |
|
| 931 | + private function colorBlendMultiply($cb, $cs) { |
|
| 932 | 932 | return $cb * $cs; |
| 933 | 933 | } |
| 934 | 934 | |
| 935 | - public function screen($color1, $color2 ){ |
|
| 936 | - return $this->colorBlend( array($this,'colorBlendScreen'), $color1, $color2 ); |
|
| 935 | + public function screen($color1, $color2) { |
|
| 936 | + return $this->colorBlend(array($this, 'colorBlendScreen'), $color1, $color2); |
|
| 937 | 937 | } |
| 938 | 938 | |
| 939 | - private function colorBlendScreen( $cb, $cs){ |
|
| 940 | - return $cb + $cs - $cb * $cs; |
|
| 939 | + private function colorBlendScreen($cb, $cs) { |
|
| 940 | + return $cb+$cs-$cb * $cs; |
|
| 941 | 941 | } |
| 942 | 942 | |
| 943 | - public function overlay($color1, $color2){ |
|
| 944 | - return $this->colorBlend( array($this,'colorBlendOverlay'), $color1, $color2 ); |
|
| 943 | + public function overlay($color1, $color2) { |
|
| 944 | + return $this->colorBlend(array($this, 'colorBlendOverlay'), $color1, $color2); |
|
| 945 | 945 | } |
| 946 | 946 | |
| 947 | - private function colorBlendOverlay($cb, $cs ){ |
|
| 947 | + private function colorBlendOverlay($cb, $cs) { |
|
| 948 | 948 | $cb *= 2; |
| 949 | - return ($cb <= 1) |
|
| 949 | + return ($cb<=1) |
|
| 950 | 950 | ? $this->colorBlendMultiply($cb, $cs) |
| 951 | - : $this->colorBlendScreen($cb - 1, $cs); |
|
| 951 | + : $this->colorBlendScreen($cb-1, $cs); |
|
| 952 | 952 | } |
| 953 | 953 | |
| 954 | - public function softlight($color1, $color2){ |
|
| 955 | - return $this->colorBlend( array($this,'colorBlendSoftlight'), $color1, $color2 ); |
|
| 954 | + public function softlight($color1, $color2) { |
|
| 955 | + return $this->colorBlend(array($this, 'colorBlendSoftlight'), $color1, $color2); |
|
| 956 | 956 | } |
| 957 | 957 | |
| 958 | - private function colorBlendSoftlight($cb, $cs ){ |
|
| 958 | + private function colorBlendSoftlight($cb, $cs) { |
|
| 959 | 959 | $d = 1; |
| 960 | 960 | $e = $cb; |
| 961 | - if( $cs > 0.5 ){ |
|
| 961 | + if ($cs>0.5) { |
|
| 962 | 962 | $e = 1; |
| 963 | - $d = ($cb > 0.25) ? sqrt($cb) |
|
| 964 | - : ((16 * $cb - 12) * $cb + 4) * $cb; |
|
| 963 | + $d = ($cb>0.25) ? sqrt($cb) |
|
| 964 | + : ((16 * $cb-12) * $cb+4) * $cb; |
|
| 965 | 965 | } |
| 966 | - return $cb - (1 - 2 * $cs) * $e * ($d - $cb); |
|
| 966 | + return $cb-(1-2 * $cs) * $e * ($d-$cb); |
|
| 967 | 967 | } |
| 968 | 968 | |
| 969 | - public function hardlight($color1, $color2){ |
|
| 970 | - return $this->colorBlend( array($this,'colorBlendHardlight'), $color1, $color2 ); |
|
| 969 | + public function hardlight($color1, $color2) { |
|
| 970 | + return $this->colorBlend(array($this, 'colorBlendHardlight'), $color1, $color2); |
|
| 971 | 971 | } |
| 972 | 972 | |
| 973 | - private function colorBlendHardlight( $cb, $cs ){ |
|
| 973 | + private function colorBlendHardlight($cb, $cs) { |
|
| 974 | 974 | return $this->colorBlendOverlay($cs, $cb); |
| 975 | 975 | } |
| 976 | 976 | |
| 977 | 977 | public function difference($color1, $color2) { |
| 978 | - return $this->colorBlend( array($this,'colorBlendDifference'), $color1, $color2 ); |
|
| 978 | + return $this->colorBlend(array($this, 'colorBlendDifference'), $color1, $color2); |
|
| 979 | 979 | } |
| 980 | 980 | |
| 981 | - private function colorBlendDifference( $cb, $cs ){ |
|
| 982 | - return abs($cb - $cs); |
|
| 981 | + private function colorBlendDifference($cb, $cs) { |
|
| 982 | + return abs($cb-$cs); |
|
| 983 | 983 | } |
| 984 | 984 | |
| 985 | - public function exclusion( $color1, $color2 ){ |
|
| 986 | - return $this->colorBlend( array($this,'colorBlendExclusion'), $color1, $color2 ); |
|
| 985 | + public function exclusion($color1, $color2) { |
|
| 986 | + return $this->colorBlend(array($this, 'colorBlendExclusion'), $color1, $color2); |
|
| 987 | 987 | } |
| 988 | 988 | |
| 989 | - private function colorBlendExclusion( $cb, $cs ){ |
|
| 990 | - return $cb + $cs - 2 * $cb * $cs; |
|
| 989 | + private function colorBlendExclusion($cb, $cs) { |
|
| 990 | + return $cb+$cs-2 * $cb * $cs; |
|
| 991 | 991 | } |
| 992 | 992 | |
| 993 | - public function average($color1, $color2){ |
|
| 994 | - return $this->colorBlend( array($this,'colorBlendAverage'), $color1, $color2 ); |
|
| 993 | + public function average($color1, $color2) { |
|
| 994 | + return $this->colorBlend(array($this, 'colorBlendAverage'), $color1, $color2); |
|
| 995 | 995 | } |
| 996 | 996 | |
| 997 | 997 | // non-w3c functions: |
| 998 | - public function colorBlendAverage($cb, $cs ){ |
|
| 999 | - return ($cb + $cs) / 2; |
|
| 998 | + public function colorBlendAverage($cb, $cs) { |
|
| 999 | + return ($cb+$cs) / 2; |
|
| 1000 | 1000 | } |
| 1001 | 1001 | |
| 1002 | - public function negation($color1, $color2 ){ |
|
| 1003 | - return $this->colorBlend( array($this,'colorBlendNegation'), $color1, $color2 ); |
|
| 1002 | + public function negation($color1, $color2) { |
|
| 1003 | + return $this->colorBlend(array($this, 'colorBlendNegation'), $color1, $color2); |
|
| 1004 | 1004 | } |
| 1005 | 1005 | |
| 1006 | - public function colorBlendNegation($cb, $cs){ |
|
| 1007 | - return 1 - abs($cb + $cs - 1); |
|
| 1006 | + public function colorBlendNegation($cb, $cs) { |
|
| 1007 | + return 1-abs($cb+$cs-1); |
|
| 1008 | 1008 | } |
| 1009 | 1009 | |
| 1010 | 1010 | // ~ End of Color Blending |
@@ -104,10 +104,15 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | public function hsla_hue($h, $m1, $m2){ |
| 106 | 106 | $h = $h < 0 ? $h + 1 : ($h > 1 ? $h - 1 : $h); |
| 107 | - if ($h * 6 < 1) return $m1 + ($m2 - $m1) * $h * 6; |
|
| 108 | - else if ($h * 2 < 1) return $m2; |
|
| 109 | - else if ($h * 3 < 2) return $m1 + ($m2 - $m1) * (2/3 - $h) * 6; |
|
| 110 | - else return $m1; |
|
| 107 | + if ($h * 6 < 1) { |
|
| 108 | + return $m1 + ($m2 - $m1) * $h * 6; |
|
| 109 | + } else if ($h * 2 < 1) { |
|
| 110 | + return $m2; |
|
| 111 | + } else if ($h * 3 < 2) { |
|
| 112 | + return $m1 + ($m2 - $m1) * (2/3 - $h) * 6; |
|
| 113 | + } else { |
|
| 114 | + return $m1; |
|
| 115 | + } |
|
| 111 | 116 | } |
| 112 | 117 | |
| 113 | 118 | public function hsv($h, $s, $v) { |
@@ -475,7 +480,7 @@ discard block |
||
| 475 | 480 | if( is_numeric($x) && is_numeric($y) ){ |
| 476 | 481 | $x = new Less_Tree_Dimension($x); |
| 477 | 482 | $y = new Less_Tree_Dimension($y); |
| 478 | - }elseif( !($x instanceof Less_Tree_Dimension) || !($y instanceof Less_Tree_Dimension) ){ |
|
| 483 | + } elseif( !($x instanceof Less_Tree_Dimension) || !($y instanceof Less_Tree_Dimension) ){ |
|
| 479 | 484 | throw new Less_Exception_Compiler('Arguments must be numbers'); |
| 480 | 485 | } |
| 481 | 486 | |
@@ -505,7 +510,7 @@ discard block |
||
| 505 | 510 | |
| 506 | 511 | if( $unit === null ){ |
| 507 | 512 | $unit = $args[0]->unit; |
| 508 | - }else{ |
|
| 513 | + } else{ |
|
| 509 | 514 | $args[0] = $args[0]->unify(); |
| 510 | 515 | } |
| 511 | 516 | $args[0] = (float)$args[0]->value; |
@@ -550,13 +555,13 @@ discard block |
||
| 550 | 555 | if( $current->unit->toString() === '' && !$unitClone ){ |
| 551 | 556 | $temp = new Less_Tree_Dimension($current->value, $unitClone); |
| 552 | 557 | $currentUnified = $temp->unify(); |
| 553 | - }else{ |
|
| 558 | + } else{ |
|
| 554 | 559 | $currentUnified = $current->unify(); |
| 555 | 560 | } |
| 556 | 561 | |
| 557 | 562 | if( $currentUnified->unit->toString() === "" && !$unitStatic ){ |
| 558 | 563 | $unit = $unitStatic; |
| 559 | - }else{ |
|
| 564 | + } else{ |
|
| 560 | 565 | $unit = $currentUnified->unit->toString(); |
| 561 | 566 | } |
| 562 | 567 | |
@@ -570,9 +575,9 @@ discard block |
||
| 570 | 575 | |
| 571 | 576 | if( isset($values['']) && $unit !== '' && $unit === $unitStatic ){ |
| 572 | 577 | $j = $values['']; |
| 573 | - }elseif( isset($values[$unit]) ){ |
|
| 578 | + } elseif( isset($values[$unit]) ){ |
|
| 574 | 579 | $j = $values[$unit]; |
| 575 | - }else{ |
|
| 580 | + } else{ |
|
| 576 | 581 | |
| 577 | 582 | if( $unitStatic && $unit !== $unitStatic ){ |
| 578 | 583 | throw new Less_Exception_Compiler( 'incompatible types'); |
@@ -586,7 +591,7 @@ discard block |
||
| 586 | 591 | if( $order[$j]->unit->toString() === "" && $unitClone ){ |
| 587 | 592 | $temp = new Less_Tree_Dimension( $order[$j]->value, $unitClone); |
| 588 | 593 | $referenceUnified = $temp->unifiy(); |
| 589 | - }else{ |
|
| 594 | + } else{ |
|
| 590 | 595 | $referenceUnified = $order[$j]->unify(); |
| 591 | 596 | } |
| 592 | 597 | if( ($isMin && $currentUnified->value < $referenceUnified->value) || (!$isMin && $currentUnified->value > $referenceUnified->value) ){ |
@@ -708,7 +713,7 @@ discard block |
||
| 708 | 713 | } |
| 709 | 714 | return null; |
| 710 | 715 | |
| 711 | - }elseif( (int)$index === 0 ){ |
|
| 716 | + } elseif( (int)$index === 0 ){ |
|
| 712 | 717 | return $values; |
| 713 | 718 | } |
| 714 | 719 | |
@@ -766,14 +771,14 @@ discard block |
||
| 766 | 771 | $useBase64 = !in_array($charset,array('US-ASCII', 'UTF-8')); |
| 767 | 772 | if( $useBase64 ){ $mimetype .= ';base64'; } |
| 768 | 773 | |
| 769 | - }else{ |
|
| 774 | + } else{ |
|
| 770 | 775 | $useBase64 = preg_match('/;base64$/',$mimetype); |
| 771 | 776 | } |
| 772 | 777 | |
| 773 | 778 | |
| 774 | 779 | if( file_exists($filePath) ){ |
| 775 | 780 | $buf = @file_get_contents($filePath); |
| 776 | - }else{ |
|
| 781 | + } else{ |
|
| 777 | 782 | $buf = false; |
| 778 | 783 | } |
| 779 | 784 | |
@@ -843,7 +848,7 @@ discard block |
||
| 843 | 848 | if( is_object($stops[$i]) && property_exists($stops[$i],'value') ){ |
| 844 | 849 | $color = $stops[$i]->value[0]; |
| 845 | 850 | $position = $stops[$i]->value[1]; |
| 846 | - }else{ |
|
| 851 | + } else{ |
|
| 847 | 852 | $color = $stops[$i]; |
| 848 | 853 | $position = null; |
| 849 | 854 | } |
@@ -853,9 +858,9 @@ discard block |
||
| 853 | 858 | } |
| 854 | 859 | if( $position ){ |
| 855 | 860 | $positionValue = $position->toCSS(); |
| 856 | - }elseif( $i === 0 ){ |
|
| 861 | + } elseif( $i === 0 ){ |
|
| 857 | 862 | $positionValue = '0%'; |
| 858 | - }else{ |
|
| 863 | + } else{ |
|
| 859 | 864 | $positionValue = '100%'; |
| 860 | 865 | } |
| 861 | 866 | $alpha = $color->alpha; |
@@ -867,7 +872,7 @@ discard block |
||
| 867 | 872 | |
| 868 | 873 | if( $useBase64 ){ |
| 869 | 874 | $returner = "'data:image/svg+xml;base64,".base64_encode($returner)."'"; |
| 870 | - }else{ |
|
| 875 | + } else{ |
|
| 871 | 876 | $returner = "'data:image/svg+xml,".$returner."'"; |
| 872 | 877 | } |
| 873 | 878 | |
@@ -211,6 +211,7 @@ discard block |
||
| 211 | 211 | /** |
| 212 | 212 | * Run pre-compile visitors |
| 213 | 213 | * |
| 214 | + * @param Less_Tree_Ruleset $root |
|
| 214 | 215 | */ |
| 215 | 216 | private function PreVisitors($root){ |
| 216 | 217 | |
@@ -227,6 +228,7 @@ discard block |
||
| 227 | 228 | /** |
| 228 | 229 | * Run post-compile visitors |
| 229 | 230 | * |
| 231 | + * @param Less_Tree_Ruleset $evaldRoot |
|
| 230 | 232 | */ |
| 231 | 233 | private function PostVisitors($evaldRoot){ |
| 232 | 234 | |
@@ -264,8 +266,7 @@ discard block |
||
| 264 | 266 | * Parse a Less string into css |
| 265 | 267 | * |
| 266 | 268 | * @param string $str The string to convert |
| 267 | - * @param string $uri_root The url of the file |
|
| 268 | - * @return Less_Tree_Ruleset|Less_Parser |
|
| 269 | + * @return Less_Parser |
|
| 269 | 270 | */ |
| 270 | 271 | public function parse( $str, $file_uri = null ){ |
| 271 | 272 | |
@@ -558,6 +559,7 @@ discard block |
||
| 558 | 559 | /** |
| 559 | 560 | * Set up the input buffer |
| 560 | 561 | * |
| 562 | + * @param string|null $file_path |
|
| 561 | 563 | */ |
| 562 | 564 | public function SetInput( $file_path ){ |
| 563 | 565 | |
@@ -590,6 +592,9 @@ discard block |
||
| 590 | 592 | } |
| 591 | 593 | |
| 592 | 594 | |
| 595 | + /** |
|
| 596 | + * @param string|null $file_path |
|
| 597 | + */ |
|
| 593 | 598 | public function CacheFile( $file_path ){ |
| 594 | 599 | |
| 595 | 600 | if( $file_path && $this->CacheEnabled() ){ |
@@ -645,7 +650,7 @@ discard block |
||
| 645 | 650 | /** |
| 646 | 651 | * Parse from a token, regexp or string, and move forward if match |
| 647 | 652 | * |
| 648 | - * @param array $toks |
|
| 653 | + * @param string[] $toks |
|
| 649 | 654 | * @return array |
| 650 | 655 | */ |
| 651 | 656 | private function match($toks){ |
@@ -2430,6 +2435,9 @@ discard block |
||
| 2430 | 2435 | |
| 2431 | 2436 | } |
| 2432 | 2437 | |
| 2438 | + /** |
|
| 2439 | + * @param string $re |
|
| 2440 | + */ |
|
| 2433 | 2441 | private function rulePropertyMatch( $re, &$offset, &$length, &$index, &$name ){ |
| 2434 | 2442 | preg_match($re, $this->input, $a, 0, $offset); |
| 2435 | 2443 | if( $a ){ |
@@ -2495,6 +2503,9 @@ discard block |
||
| 2495 | 2503 | return $obj; |
| 2496 | 2504 | } |
| 2497 | 2505 | |
| 2506 | + /** |
|
| 2507 | + * @param string $class |
|
| 2508 | + */ |
|
| 2498 | 2509 | public function NewObj1($class, $arg){ |
| 2499 | 2510 | $obj = new $class( $arg ); |
| 2500 | 2511 | if( $this->CacheEnabled() ){ |
@@ -2503,6 +2514,9 @@ discard block |
||
| 2503 | 2514 | return $obj; |
| 2504 | 2515 | } |
| 2505 | 2516 | |
| 2517 | + /** |
|
| 2518 | + * @param string $class |
|
| 2519 | + */ |
|
| 2506 | 2520 | public function NewObj2($class, $args){ |
| 2507 | 2521 | $obj = new $class( $args[0], $args[1] ); |
| 2508 | 2522 | if( $this->CacheEnabled() ){ |
@@ -2511,6 +2525,9 @@ discard block |
||
| 2511 | 2525 | return $obj; |
| 2512 | 2526 | } |
| 2513 | 2527 | |
| 2528 | + /** |
|
| 2529 | + * @param string $class |
|
| 2530 | + */ |
|
| 2514 | 2531 | public function NewObj3($class, $args){ |
| 2515 | 2532 | $obj = new $class( $args[0], $args[1], $args[2] ); |
| 2516 | 2533 | if( $this->CacheEnabled() ){ |
@@ -2519,6 +2536,9 @@ discard block |
||
| 2519 | 2536 | return $obj; |
| 2520 | 2537 | } |
| 2521 | 2538 | |
| 2539 | + /** |
|
| 2540 | + * @param string $class |
|
| 2541 | + */ |
|
| 2522 | 2542 | public function NewObj4($class, $args){ |
| 2523 | 2543 | $obj = new $class( $args[0], $args[1], $args[2], $args[3] ); |
| 2524 | 2544 | if( $this->CacheEnabled() ){ |
@@ -2527,6 +2547,9 @@ discard block |
||
| 2527 | 2547 | return $obj; |
| 2528 | 2548 | } |
| 2529 | 2549 | |
| 2550 | + /** |
|
| 2551 | + * @param string $class |
|
| 2552 | + */ |
|
| 2530 | 2553 | public function NewObj5($class, $args){ |
| 2531 | 2554 | $obj = new $class( $args[0], $args[1], $args[2], $args[3], $args[4] ); |
| 2532 | 2555 | if( $this->CacheEnabled() ){ |
@@ -2535,6 +2558,9 @@ discard block |
||
| 2535 | 2558 | return $obj; |
| 2536 | 2559 | } |
| 2537 | 2560 | |
| 2561 | + /** |
|
| 2562 | + * @param string $class |
|
| 2563 | + */ |
|
| 2538 | 2564 | public function NewObj6($class, $args){ |
| 2539 | 2565 | $obj = new $class( $args[0], $args[1], $args[2], $args[3], $args[4], $args[5] ); |
| 2540 | 2566 | if( $this->CacheEnabled() ){ |
@@ -2543,6 +2569,9 @@ discard block |
||
| 2543 | 2569 | return $obj; |
| 2544 | 2570 | } |
| 2545 | 2571 | |
| 2572 | + /** |
|
| 2573 | + * @param string $class |
|
| 2574 | + */ |
|
| 2546 | 2575 | public function NewObj7($class, $args){ |
| 2547 | 2576 | $obj = new $class( $args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6] ); |
| 2548 | 2577 | if( $this->CacheEnabled() ){ |
@@ -849,7 +849,7 @@ discard block |
||
| 849 | 849 | break; |
| 850 | 850 | } |
| 851 | 851 | |
| 852 | - if( $this->PeekChar('}') ){ |
|
| 852 | + if( $this->PeekChar('}') ){ |
|
| 853 | 853 | break; |
| 854 | 854 | } |
| 855 | 855 | } |
@@ -920,8 +920,8 @@ discard block |
||
| 920 | 920 | $this->MatchChar('~'); |
| 921 | 921 | } |
| 922 | 922 | |
| 923 | - // Fix for #124: match escaped newlines |
|
| 924 | - //$str = $this->MatchReg('/\\G"((?:[^"\\\\\r\n]|\\\\.)*)"|\'((?:[^\'\\\\\r\n]|\\\\.)*)\'/'); |
|
| 923 | + // Fix for #124: match escaped newlines |
|
| 924 | + //$str = $this->MatchReg('/\\G"((?:[^"\\\\\r\n]|\\\\.)*)"|\'((?:[^\'\\\\\r\n]|\\\\.)*)\'/'); |
|
| 925 | 925 | $str = $this->MatchReg('/\\G"((?:[^"\\\\\r\n]|\\\\.|\\\\\r\n|\\\\[\n\r\f])*)"|\'((?:[^\'\\\\\r\n]|\\\\.|\\\\\r\n|\\\\[\n\r\f])*)\'/'); |
| 926 | 926 | |
| 927 | 927 | if( $str ){ |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -require_once( dirname(__FILE__).'/Cache.php'); |
|
| 3 | +require_once(dirname(__FILE__).'/Cache.php'); |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * Class for parsing and compiling less files into css |
@@ -9,28 +9,28 @@ discard block |
||
| 9 | 9 | * @subpackage parser |
| 10 | 10 | * |
| 11 | 11 | */ |
| 12 | -class Less_Parser{ |
|
| 12 | +class Less_Parser { |
|
| 13 | 13 | |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * Default parser options |
| 17 | 17 | */ |
| 18 | 18 | public static $default_options = array( |
| 19 | - 'compress' => false, // option - whether to compress |
|
| 20 | - 'strictUnits' => false, // whether units need to evaluate correctly |
|
| 21 | - 'strictMath' => false, // whether math has to be within parenthesis |
|
| 22 | - 'relativeUrls' => true, // option - whether to adjust URL's to be relative |
|
| 23 | - 'urlArgs' => array(), // whether to add args into url tokens |
|
| 19 | + 'compress' => false, // option - whether to compress |
|
| 20 | + 'strictUnits' => false, // whether units need to evaluate correctly |
|
| 21 | + 'strictMath' => false, // whether math has to be within parenthesis |
|
| 22 | + 'relativeUrls' => true, // option - whether to adjust URL's to be relative |
|
| 23 | + 'urlArgs' => array(), // whether to add args into url tokens |
|
| 24 | 24 | 'numPrecision' => 8, |
| 25 | 25 | |
| 26 | 26 | 'import_dirs' => array(), |
| 27 | 27 | 'import_callback' => null, |
| 28 | 28 | 'cache_dir' => null, |
| 29 | - 'cache_method' => 'php', // false, 'serialize', 'php', 'var_export', 'callback'; |
|
| 29 | + 'cache_method' => 'php', // false, 'serialize', 'php', 'var_export', 'callback'; |
|
| 30 | 30 | 'cache_callback_get' => null, |
| 31 | 31 | 'cache_callback_set' => null, |
| 32 | 32 | |
| 33 | - 'sourceMap' => false, // whether to output a source map |
|
| 33 | + 'sourceMap' => false, // whether to output a source map |
|
| 34 | 34 | 'sourceMapBasepath' => null, |
| 35 | 35 | 'sourceMapWriteTo' => null, |
| 36 | 36 | 'sourceMapURL' => null, |
@@ -42,10 +42,10 @@ discard block |
||
| 42 | 42 | public static $options = array(); |
| 43 | 43 | |
| 44 | 44 | |
| 45 | - private $input; // Less input string |
|
| 46 | - private $input_len; // input string length |
|
| 47 | - private $pos; // current index in `input` |
|
| 48 | - private $saveStack = array(); // holds state for backtracking |
|
| 45 | + private $input; // Less input string |
|
| 46 | + private $input_len; // input string length |
|
| 47 | + private $pos; // current index in `input` |
|
| 48 | + private $saveStack = array(); // holds state for backtracking |
|
| 49 | 49 | private $furthest; |
| 50 | 50 | |
| 51 | 51 | /** |
@@ -72,15 +72,15 @@ discard block |
||
| 72 | 72 | /** |
| 73 | 73 | * @param Less_Environment|array|null $env |
| 74 | 74 | */ |
| 75 | - public function __construct( $env = null ){ |
|
| 75 | + public function __construct($env = null) { |
|
| 76 | 76 | |
| 77 | 77 | // Top parser on an import tree must be sure there is one "env" |
| 78 | 78 | // which will then be passed around by reference. |
| 79 | - if( $env instanceof Less_Environment ){ |
|
| 79 | + if ($env instanceof Less_Environment) { |
|
| 80 | 80 | $this->env = $env; |
| 81 | - }else{ |
|
| 81 | + }else { |
|
| 82 | 82 | $this->SetOptions(Less_Parser::$default_options); |
| 83 | - $this->Reset( $env ); |
|
| 83 | + $this->Reset($env); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | } |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * Reset the parser state completely |
| 91 | 91 | * |
| 92 | 92 | */ |
| 93 | - public function Reset( $options = null ){ |
|
| 93 | + public function Reset($options = null) { |
|
| 94 | 94 | $this->rules = array(); |
| 95 | 95 | self::$imports = array(); |
| 96 | 96 | self::$has_extends = false; |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | $this->env->Init(); |
| 102 | 102 | |
| 103 | 103 | //set new options |
| 104 | - if( is_array($options) ){ |
|
| 104 | + if (is_array($options)) { |
|
| 105 | 105 | $this->SetOptions(Less_Parser::$default_options); |
| 106 | 106 | $this->SetOptions($options); |
| 107 | 107 | } |
@@ -112,9 +112,9 @@ discard block |
||
| 112 | 112 | * options: import_dirs, cache_dir, cache_method |
| 113 | 113 | * |
| 114 | 114 | */ |
| 115 | - public function SetOptions( $options ){ |
|
| 116 | - foreach($options as $option => $value){ |
|
| 117 | - $this->SetOption($option,$value); |
|
| 115 | + public function SetOptions($options) { |
|
| 116 | + foreach ($options as $option => $value) { |
|
| 117 | + $this->SetOption($option, $value); |
|
| 118 | 118 | } |
| 119 | 119 | } |
| 120 | 120 | |
@@ -122,16 +122,16 @@ discard block |
||
| 122 | 122 | * Set one compiler option |
| 123 | 123 | * |
| 124 | 124 | */ |
| 125 | - public function SetOption($option,$value){ |
|
| 125 | + public function SetOption($option, $value) { |
|
| 126 | 126 | |
| 127 | - switch($option){ |
|
| 127 | + switch ($option) { |
|
| 128 | 128 | |
| 129 | 129 | case 'import_dirs': |
| 130 | 130 | $this->SetImportDirs($value); |
| 131 | 131 | return; |
| 132 | 132 | |
| 133 | 133 | case 'cache_dir': |
| 134 | - if( is_string($value) ){ |
|
| 134 | + if (is_string($value)) { |
|
| 135 | 135 | Less_Cache::SetCacheDir($value); |
| 136 | 136 | Less_Cache::CheckCacheDir(); |
| 137 | 137 | } |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | * @param string $name function name |
| 158 | 158 | */ |
| 159 | 159 | public function unregisterFunction($name) { |
| 160 | - if( isset($this->env->functions[$name]) ) |
|
| 160 | + if (isset($this->env->functions[$name])) |
|
| 161 | 161 | unset($this->env->functions[$name]); |
| 162 | 162 | } |
| 163 | 163 | |
@@ -167,14 +167,14 @@ discard block |
||
| 167 | 167 | * |
| 168 | 168 | * @return string |
| 169 | 169 | */ |
| 170 | - public function getCss(){ |
|
| 170 | + public function getCss() { |
|
| 171 | 171 | |
| 172 | 172 | $precision = ini_get('precision'); |
| 173 | - @ini_set('precision',16); |
|
| 173 | + @ini_set('precision', 16); |
|
| 174 | 174 | $locale = setlocale(LC_NUMERIC, 0); |
| 175 | 175 | setlocale(LC_NUMERIC, "C"); |
| 176 | 176 | |
| 177 | - $root = new Less_Tree_Ruleset(array(), $this->rules ); |
|
| 177 | + $root = new Less_Tree_Ruleset(array(), $this->rules); |
|
| 178 | 178 | $root->root = true; |
| 179 | 179 | $root->firstRoot = true; |
| 180 | 180 | |
@@ -188,21 +188,21 @@ discard block |
||
| 188 | 188 | |
| 189 | 189 | $this->PostVisitors($evaldRoot); |
| 190 | 190 | |
| 191 | - if( Less_Parser::$options['sourceMap'] ){ |
|
| 192 | - $generator = new Less_SourceMap_Generator($evaldRoot, Less_Parser::$contentsMap, Less_Parser::$options ); |
|
| 191 | + if (Less_Parser::$options['sourceMap']) { |
|
| 192 | + $generator = new Less_SourceMap_Generator($evaldRoot, Less_Parser::$contentsMap, Less_Parser::$options); |
|
| 193 | 193 | // will also save file |
| 194 | 194 | // FIXME: should happen somewhere else? |
| 195 | 195 | $css = $generator->generateCSS(); |
| 196 | - }else{ |
|
| 196 | + }else { |
|
| 197 | 197 | $css = $evaldRoot->toCSS(); |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - if( Less_Parser::$options['compress'] ){ |
|
| 200 | + if (Less_Parser::$options['compress']) { |
|
| 201 | 201 | $css = preg_replace('/(^(\s)+)|((\s)+$)/', '', $css); |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | //reset php settings |
| 205 | - @ini_set('precision',$precision); |
|
| 205 | + @ini_set('precision', $precision); |
|
| 206 | 206 | setlocale(LC_NUMERIC, $locale); |
| 207 | 207 | |
| 208 | 208 | return $css; |
@@ -212,11 +212,11 @@ discard block |
||
| 212 | 212 | * Run pre-compile visitors |
| 213 | 213 | * |
| 214 | 214 | */ |
| 215 | - private function PreVisitors($root){ |
|
| 215 | + private function PreVisitors($root) { |
|
| 216 | 216 | |
| 217 | - if( Less_Parser::$options['plugins'] ){ |
|
| 218 | - foreach(Less_Parser::$options['plugins'] as $plugin){ |
|
| 219 | - if( !empty($plugin->isPreEvalVisitor) ){ |
|
| 217 | + if (Less_Parser::$options['plugins']) { |
|
| 218 | + foreach (Less_Parser::$options['plugins'] as $plugin) { |
|
| 219 | + if (!empty($plugin->isPreEvalVisitor)) { |
|
| 220 | 220 | $plugin->run($root); |
| 221 | 221 | } |
| 222 | 222 | } |
@@ -228,32 +228,32 @@ discard block |
||
| 228 | 228 | * Run post-compile visitors |
| 229 | 229 | * |
| 230 | 230 | */ |
| 231 | - private function PostVisitors($evaldRoot){ |
|
| 231 | + private function PostVisitors($evaldRoot) { |
|
| 232 | 232 | |
| 233 | 233 | $visitors = array(); |
| 234 | 234 | $visitors[] = new Less_Visitor_joinSelector(); |
| 235 | - if( self::$has_extends ){ |
|
| 235 | + if (self::$has_extends) { |
|
| 236 | 236 | $visitors[] = new Less_Visitor_processExtends(); |
| 237 | 237 | } |
| 238 | 238 | $visitors[] = new Less_Visitor_toCSS(); |
| 239 | 239 | |
| 240 | 240 | |
| 241 | - if( Less_Parser::$options['plugins'] ){ |
|
| 242 | - foreach(Less_Parser::$options['plugins'] as $plugin){ |
|
| 243 | - if( property_exists($plugin,'isPreEvalVisitor') && $plugin->isPreEvalVisitor ){ |
|
| 241 | + if (Less_Parser::$options['plugins']) { |
|
| 242 | + foreach (Less_Parser::$options['plugins'] as $plugin) { |
|
| 243 | + if (property_exists($plugin, 'isPreEvalVisitor') && $plugin->isPreEvalVisitor) { |
|
| 244 | 244 | continue; |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | - if( property_exists($plugin,'isPreVisitor') && $plugin->isPreVisitor ){ |
|
| 248 | - array_unshift( $visitors, $plugin); |
|
| 249 | - }else{ |
|
| 247 | + if (property_exists($plugin, 'isPreVisitor') && $plugin->isPreVisitor) { |
|
| 248 | + array_unshift($visitors, $plugin); |
|
| 249 | + }else { |
|
| 250 | 250 | $visitors[] = $plugin; |
| 251 | 251 | } |
| 252 | 252 | } |
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | |
| 256 | - for($i = 0; $i < count($visitors); $i++ ){ |
|
| 256 | + for ($i = 0; $i<count($visitors); $i++) { |
|
| 257 | 257 | $visitors[$i]->run($evaldRoot); |
| 258 | 258 | } |
| 259 | 259 | |
@@ -267,12 +267,12 @@ discard block |
||
| 267 | 267 | * @param string $uri_root The url of the file |
| 268 | 268 | * @return Less_Tree_Ruleset|Less_Parser |
| 269 | 269 | */ |
| 270 | - public function parse( $str, $file_uri = null ){ |
|
| 270 | + public function parse($str, $file_uri = null) { |
|
| 271 | 271 | |
| 272 | - if( !$file_uri ){ |
|
| 272 | + if (!$file_uri) { |
|
| 273 | 273 | $uri_root = ''; |
| 274 | 274 | $filename = 'anonymous-file-'.Less_Parser::$next_id++.'.less'; |
| 275 | - }else{ |
|
| 275 | + }else { |
|
| 276 | 276 | $file_uri = self::WinPath($file_uri); |
| 277 | 277 | $filename = basename($file_uri); |
| 278 | 278 | $uri_root = dirname($file_uri); |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | $this->input = $str; |
| 286 | 286 | $this->_parse(); |
| 287 | 287 | |
| 288 | - if( $previousFileInfo ){ |
|
| 288 | + if ($previousFileInfo) { |
|
| 289 | 289 | $this->env->currentFileInfo = $previousFileInfo; |
| 290 | 290 | } |
| 291 | 291 | |
@@ -302,16 +302,16 @@ discard block |
||
| 302 | 302 | * @param bool $returnRoot Indicates whether the return value should be a css string a root node |
| 303 | 303 | * @return Less_Tree_Ruleset|Less_Parser |
| 304 | 304 | */ |
| 305 | - public function parseFile( $filename, $uri_root = '', $returnRoot = false){ |
|
| 305 | + public function parseFile($filename, $uri_root = '', $returnRoot = false) { |
|
| 306 | 306 | |
| 307 | - if( !file_exists($filename) ){ |
|
| 307 | + if (!file_exists($filename)) { |
|
| 308 | 308 | $this->Error(sprintf('File `%s` not found.', $filename)); |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | |
| 312 | 312 | // fix uri_root? |
| 313 | 313 | // Instead of The mixture of file path for the first argument and directory path for the second argument has bee |
| 314 | - if( !$returnRoot && !empty($uri_root) && basename($uri_root) == basename($filename) ){ |
|
| 314 | + if (!$returnRoot && !empty($uri_root) && basename($uri_root)==basename($filename)) { |
|
| 315 | 315 | $uri_root = dirname($uri_root); |
| 316 | 316 | } |
| 317 | 317 | |
@@ -323,15 +323,15 @@ discard block |
||
| 323 | 323 | |
| 324 | 324 | self::AddParsedFile($filename); |
| 325 | 325 | |
| 326 | - if( $returnRoot ){ |
|
| 327 | - $rules = $this->GetRules( $filename ); |
|
| 328 | - $return = new Less_Tree_Ruleset(array(), $rules ); |
|
| 329 | - }else{ |
|
| 330 | - $this->_parse( $filename ); |
|
| 326 | + if ($returnRoot) { |
|
| 327 | + $rules = $this->GetRules($filename); |
|
| 328 | + $return = new Less_Tree_Ruleset(array(), $rules); |
|
| 329 | + }else { |
|
| 330 | + $this->_parse($filename); |
|
| 331 | 331 | $return = $this; |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | - if( $previousFileInfo ){ |
|
| 334 | + if ($previousFileInfo) { |
|
| 335 | 335 | $this->env->currentFileInfo = $previousFileInfo; |
| 336 | 336 | } |
| 337 | 337 | |
@@ -344,9 +344,9 @@ discard block |
||
| 344 | 344 | * @param array $vars |
| 345 | 345 | * @return Less_Parser |
| 346 | 346 | */ |
| 347 | - public function ModifyVars( $vars ){ |
|
| 347 | + public function ModifyVars($vars) { |
|
| 348 | 348 | |
| 349 | - $this->input = Less_Parser::serializeVars( $vars ); |
|
| 349 | + $this->input = Less_Parser::serializeVars($vars); |
|
| 350 | 350 | $this->_parse(); |
| 351 | 351 | |
| 352 | 352 | return $this; |
@@ -356,24 +356,24 @@ discard block |
||
| 356 | 356 | /** |
| 357 | 357 | * @param string $filename |
| 358 | 358 | */ |
| 359 | - public function SetFileInfo( $filename, $uri_root = ''){ |
|
| 359 | + public function SetFileInfo($filename, $uri_root = '') { |
|
| 360 | 360 | |
| 361 | 361 | $filename = Less_Environment::normalizePath($filename); |
| 362 | - $dirname = preg_replace('/[^\/\\\\]*$/','',$filename); |
|
| 362 | + $dirname = preg_replace('/[^\/\\\\]*$/', '', $filename); |
|
| 363 | 363 | |
| 364 | - if( !empty($uri_root) ){ |
|
| 365 | - $uri_root = rtrim($uri_root,'/').'/'; |
|
| 364 | + if (!empty($uri_root)) { |
|
| 365 | + $uri_root = rtrim($uri_root, '/').'/'; |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | $currentFileInfo = array(); |
| 369 | 369 | |
| 370 | 370 | //entry info |
| 371 | - if( isset($this->env->currentFileInfo) ){ |
|
| 371 | + if (isset($this->env->currentFileInfo)) { |
|
| 372 | 372 | $currentFileInfo['entryPath'] = $this->env->currentFileInfo['entryPath']; |
| 373 | 373 | $currentFileInfo['entryUri'] = $this->env->currentFileInfo['entryUri']; |
| 374 | 374 | $currentFileInfo['rootpath'] = $this->env->currentFileInfo['rootpath']; |
| 375 | 375 | |
| 376 | - }else{ |
|
| 376 | + }else { |
|
| 377 | 377 | $currentFileInfo['entryPath'] = $dirname; |
| 378 | 378 | $currentFileInfo['entryUri'] = $uri_root; |
| 379 | 379 | $currentFileInfo['rootpath'] = $dirname; |
@@ -386,7 +386,7 @@ discard block |
||
| 386 | 386 | |
| 387 | 387 | |
| 388 | 388 | //inherit reference |
| 389 | - if( isset($this->env->currentFileInfo['reference']) && $this->env->currentFileInfo['reference'] ){ |
|
| 389 | + if (isset($this->env->currentFileInfo['reference']) && $this->env->currentFileInfo['reference']) { |
|
| 390 | 390 | $currentFileInfo['reference'] = true; |
| 391 | 391 | } |
| 392 | 392 | |
@@ -398,23 +398,23 @@ discard block |
||
| 398 | 398 | * @deprecated 1.5.1.2 |
| 399 | 399 | * |
| 400 | 400 | */ |
| 401 | - public function SetCacheDir( $dir ){ |
|
| 401 | + public function SetCacheDir($dir) { |
|
| 402 | 402 | |
| 403 | - if( !file_exists($dir) ){ |
|
| 404 | - if( mkdir($dir) ){ |
|
| 403 | + if (!file_exists($dir)) { |
|
| 404 | + if (mkdir($dir)) { |
|
| 405 | 405 | return true; |
| 406 | 406 | } |
| 407 | 407 | throw new Less_Exception_Parser('Less.php cache directory couldn\'t be created: '.$dir); |
| 408 | 408 | |
| 409 | - }elseif( !is_dir($dir) ){ |
|
| 409 | + }elseif (!is_dir($dir)) { |
|
| 410 | 410 | throw new Less_Exception_Parser('Less.php cache directory doesn\'t exist: '.$dir); |
| 411 | 411 | |
| 412 | - }elseif( !is_writable($dir) ){ |
|
| 412 | + }elseif (!is_writable($dir)) { |
|
| 413 | 413 | throw new Less_Exception_Parser('Less.php cache directory isn\'t writable: '.$dir); |
| 414 | 414 | |
| 415 | - }else{ |
|
| 415 | + }else { |
|
| 416 | 416 | $dir = self::WinPath($dir); |
| 417 | - Less_Cache::$cache_dir = rtrim($dir,'/').'/'; |
|
| 417 | + Less_Cache::$cache_dir = rtrim($dir, '/').'/'; |
|
| 418 | 418 | return true; |
| 419 | 419 | } |
| 420 | 420 | } |
@@ -425,20 +425,20 @@ discard block |
||
| 425 | 425 | * |
| 426 | 426 | * @param array $dirs |
| 427 | 427 | */ |
| 428 | - public function SetImportDirs( $dirs ){ |
|
| 428 | + public function SetImportDirs($dirs) { |
|
| 429 | 429 | Less_Parser::$options['import_dirs'] = array(); |
| 430 | 430 | |
| 431 | - foreach($dirs as $path => $uri_root){ |
|
| 431 | + foreach ($dirs as $path => $uri_root) { |
|
| 432 | 432 | |
| 433 | 433 | $path = self::WinPath($path); |
| 434 | - if( !empty($path) ){ |
|
| 435 | - $path = rtrim($path,'/').'/'; |
|
| 434 | + if (!empty($path)) { |
|
| 435 | + $path = rtrim($path, '/').'/'; |
|
| 436 | 436 | } |
| 437 | 437 | |
| 438 | - if ( !is_callable($uri_root) ){ |
|
| 438 | + if (!is_callable($uri_root)) { |
|
| 439 | 439 | $uri_root = self::WinPath($uri_root); |
| 440 | - if( !empty($uri_root) ){ |
|
| 441 | - $uri_root = rtrim($uri_root,'/').'/'; |
|
| 440 | + if (!empty($uri_root)) { |
|
| 441 | + $uri_root = rtrim($uri_root, '/').'/'; |
|
| 442 | 442 | } |
| 443 | 443 | } |
| 444 | 444 | |
@@ -449,13 +449,13 @@ discard block |
||
| 449 | 449 | /** |
| 450 | 450 | * @param string $file_path |
| 451 | 451 | */ |
| 452 | - private function _parse( $file_path = null ){ |
|
| 452 | + private function _parse($file_path = null) { |
|
| 453 | 453 | if (ini_get("mbstring.func_overload")) { |
| 454 | 454 | $mb_internal_encoding = ini_get("mbstring.internal_encoding"); |
| 455 | 455 | @ini_set("mbstring.internal_encoding", "ascii"); |
| 456 | 456 | } |
| 457 | 457 | |
| 458 | - $this->rules = array_merge($this->rules, $this->GetRules( $file_path )); |
|
| 458 | + $this->rules = array_merge($this->rules, $this->GetRules($file_path)); |
|
| 459 | 459 | |
| 460 | 460 | //reset php settings |
| 461 | 461 | if (isset($mb_internal_encoding)) { |
@@ -470,33 +470,33 @@ discard block |
||
| 470 | 470 | * |
| 471 | 471 | * @param string|null $file_path |
| 472 | 472 | */ |
| 473 | - private function GetRules( $file_path ){ |
|
| 473 | + private function GetRules($file_path) { |
|
| 474 | 474 | |
| 475 | 475 | $this->SetInput($file_path); |
| 476 | 476 | |
| 477 | - $cache_file = $this->CacheFile( $file_path ); |
|
| 478 | - if( $cache_file ){ |
|
| 479 | - if( Less_Parser::$options['cache_method'] == 'callback' ){ |
|
| 480 | - if( is_callable(Less_Parser::$options['cache_callback_get']) ){ |
|
| 477 | + $cache_file = $this->CacheFile($file_path); |
|
| 478 | + if ($cache_file) { |
|
| 479 | + if (Less_Parser::$options['cache_method']=='callback') { |
|
| 480 | + if (is_callable(Less_Parser::$options['cache_callback_get'])) { |
|
| 481 | 481 | $cache = call_user_func_array( |
| 482 | 482 | Less_Parser::$options['cache_callback_get'], |
| 483 | 483 | array($this, $file_path, $cache_file) |
| 484 | 484 | ); |
| 485 | 485 | |
| 486 | - if( $cache ){ |
|
| 486 | + if ($cache) { |
|
| 487 | 487 | $this->UnsetInput(); |
| 488 | 488 | return $cache; |
| 489 | 489 | } |
| 490 | 490 | } |
| 491 | 491 | |
| 492 | - }elseif( file_exists($cache_file) ){ |
|
| 493 | - switch(Less_Parser::$options['cache_method']){ |
|
| 492 | + }elseif (file_exists($cache_file)) { |
|
| 493 | + switch (Less_Parser::$options['cache_method']) { |
|
| 494 | 494 | |
| 495 | 495 | // Using serialize |
| 496 | 496 | // Faster but uses more memory |
| 497 | 497 | case 'serialize': |
| 498 | 498 | $cache = unserialize(file_get_contents($cache_file)); |
| 499 | - if( $cache ){ |
|
| 499 | + if ($cache) { |
|
| 500 | 500 | touch($cache_file); |
| 501 | 501 | $this->UnsetInput(); |
| 502 | 502 | return $cache; |
@@ -515,7 +515,7 @@ discard block |
||
| 515 | 515 | |
| 516 | 516 | $rules = $this->parsePrimary(); |
| 517 | 517 | |
| 518 | - if( $this->pos < $this->input_len ){ |
|
| 518 | + if ($this->pos<$this->input_len) { |
|
| 519 | 519 | throw new Less_Exception_Chunk($this->input, null, $this->furthest, $this->env->currentFileInfo); |
| 520 | 520 | } |
| 521 | 521 | |
@@ -523,27 +523,27 @@ discard block |
||
| 523 | 523 | |
| 524 | 524 | |
| 525 | 525 | //save the cache |
| 526 | - if( $cache_file ){ |
|
| 527 | - if( Less_Parser::$options['cache_method'] == 'callback' ){ |
|
| 528 | - if( is_callable(Less_Parser::$options['cache_callback_set']) ){ |
|
| 526 | + if ($cache_file) { |
|
| 527 | + if (Less_Parser::$options['cache_method']=='callback') { |
|
| 528 | + if (is_callable(Less_Parser::$options['cache_callback_set'])) { |
|
| 529 | 529 | call_user_func_array( |
| 530 | 530 | Less_Parser::$options['cache_callback_set'], |
| 531 | 531 | array($this, $file_path, $cache_file, $rules) |
| 532 | 532 | ); |
| 533 | 533 | } |
| 534 | 534 | |
| 535 | - }else{ |
|
| 535 | + }else { |
|
| 536 | 536 | //msg('write cache file'); |
| 537 | - switch(Less_Parser::$options['cache_method']){ |
|
| 537 | + switch (Less_Parser::$options['cache_method']) { |
|
| 538 | 538 | case 'serialize': |
| 539 | - file_put_contents( $cache_file, serialize($rules) ); |
|
| 539 | + file_put_contents($cache_file, serialize($rules)); |
|
| 540 | 540 | break; |
| 541 | 541 | case 'php': |
| 542 | - file_put_contents( $cache_file, '<?php return '.self::ArgString($rules).'; ?>' ); |
|
| 542 | + file_put_contents($cache_file, '<?php return '.self::ArgString($rules).'; ?>'); |
|
| 543 | 543 | break; |
| 544 | 544 | case 'var_export': |
| 545 | 545 | //Requires __set_state() |
| 546 | - file_put_contents( $cache_file, '<?php return '.var_export($rules,true).'; ?>' ); |
|
| 546 | + file_put_contents($cache_file, '<?php return '.var_export($rules, true).'; ?>'); |
|
| 547 | 547 | break; |
| 548 | 548 | } |
| 549 | 549 | |
@@ -559,10 +559,10 @@ discard block |
||
| 559 | 559 | * Set up the input buffer |
| 560 | 560 | * |
| 561 | 561 | */ |
| 562 | - public function SetInput( $file_path ){ |
|
| 562 | + public function SetInput($file_path) { |
|
| 563 | 563 | |
| 564 | - if( $file_path ){ |
|
| 565 | - $this->input = file_get_contents( $file_path ); |
|
| 564 | + if ($file_path) { |
|
| 565 | + $this->input = file_get_contents($file_path); |
|
| 566 | 566 | } |
| 567 | 567 | |
| 568 | 568 | $this->pos = $this->furthest = 0; |
@@ -572,7 +572,7 @@ discard block |
||
| 572 | 572 | $this->input_len = strlen($this->input); |
| 573 | 573 | |
| 574 | 574 | |
| 575 | - if( Less_Parser::$options['sourceMap'] && $this->env->currentFileInfo ){ |
|
| 575 | + if (Less_Parser::$options['sourceMap'] && $this->env->currentFileInfo) { |
|
| 576 | 576 | $uri = $this->env->currentFileInfo['currentUri']; |
| 577 | 577 | Less_Parser::$contentsMap[$uri] = $this->input; |
| 578 | 578 | } |
@@ -584,44 +584,44 @@ discard block |
||
| 584 | 584 | * Free up some memory |
| 585 | 585 | * |
| 586 | 586 | */ |
| 587 | - public function UnsetInput(){ |
|
| 587 | + public function UnsetInput() { |
|
| 588 | 588 | unset($this->input, $this->pos, $this->input_len, $this->furthest); |
| 589 | 589 | $this->saveStack = array(); |
| 590 | 590 | } |
| 591 | 591 | |
| 592 | 592 | |
| 593 | - public function CacheFile( $file_path ){ |
|
| 593 | + public function CacheFile($file_path) { |
|
| 594 | 594 | |
| 595 | - if( $file_path && $this->CacheEnabled() ){ |
|
| 595 | + if ($file_path && $this->CacheEnabled()) { |
|
| 596 | 596 | |
| 597 | 597 | $env = get_object_vars($this->env); |
| 598 | 598 | unset($env['frames']); |
| 599 | 599 | |
| 600 | 600 | $parts = array(); |
| 601 | 601 | $parts[] = $file_path; |
| 602 | - $parts[] = filesize( $file_path ); |
|
| 603 | - $parts[] = filemtime( $file_path ); |
|
| 602 | + $parts[] = filesize($file_path); |
|
| 603 | + $parts[] = filemtime($file_path); |
|
| 604 | 604 | $parts[] = $env; |
| 605 | 605 | $parts[] = Less_Version::cache_version; |
| 606 | 606 | $parts[] = Less_Parser::$options['cache_method']; |
| 607 | - return Less_Cache::$cache_dir.'lessphp_'.base_convert( sha1(json_encode($parts) ), 16, 36).'.lesscache'; |
|
| 607 | + return Less_Cache::$cache_dir.'lessphp_'.base_convert(sha1(json_encode($parts)), 16, 36).'.lesscache'; |
|
| 608 | 608 | } |
| 609 | 609 | } |
| 610 | 610 | |
| 611 | 611 | |
| 612 | - static function AddParsedFile($file){ |
|
| 612 | + static function AddParsedFile($file) { |
|
| 613 | 613 | self::$imports[] = $file; |
| 614 | 614 | } |
| 615 | 615 | |
| 616 | - static function AllParsedFiles(){ |
|
| 616 | + static function AllParsedFiles() { |
|
| 617 | 617 | return self::$imports; |
| 618 | 618 | } |
| 619 | 619 | |
| 620 | 620 | /** |
| 621 | 621 | * @param string $file |
| 622 | 622 | */ |
| 623 | - static function FileParsed($file){ |
|
| 624 | - return in_array($file,self::$imports); |
|
| 623 | + static function FileParsed($file) { |
|
| 624 | + return in_array($file, self::$imports); |
|
| 625 | 625 | } |
| 626 | 626 | |
| 627 | 627 | |
@@ -633,13 +633,13 @@ discard block |
||
| 633 | 633 | $this->pos = array_pop($this->saveStack); |
| 634 | 634 | } |
| 635 | 635 | |
| 636 | - private function forget(){ |
|
| 636 | + private function forget() { |
|
| 637 | 637 | array_pop($this->saveStack); |
| 638 | 638 | } |
| 639 | 639 | |
| 640 | 640 | |
| 641 | 641 | private function isWhitespace($offset = 0) { |
| 642 | - return preg_match('/\s/',$this->input[ $this->pos + $offset]); |
|
| 642 | + return preg_match('/\s/', $this->input[$this->pos+$offset]); |
|
| 643 | 643 | } |
| 644 | 644 | |
| 645 | 645 | /** |
@@ -648,7 +648,7 @@ discard block |
||
| 648 | 648 | * @param array $toks |
| 649 | 649 | * @return array |
| 650 | 650 | */ |
| 651 | - private function match($toks){ |
|
| 651 | + private function match($toks) { |
|
| 652 | 652 | |
| 653 | 653 | // The match is confirmed, add the match length to `this::pos`, |
| 654 | 654 | // and consume any extra white-space characters (' ' || '\n') |
@@ -656,27 +656,27 @@ discard block |
||
| 656 | 656 | // grammar is mostly white-space insensitive. |
| 657 | 657 | // |
| 658 | 658 | |
| 659 | - foreach($toks as $tok){ |
|
| 659 | + foreach ($toks as $tok) { |
|
| 660 | 660 | |
| 661 | 661 | $char = $tok[0]; |
| 662 | 662 | |
| 663 | - if( $char === '/' ){ |
|
| 663 | + if ($char==='/') { |
|
| 664 | 664 | $match = $this->MatchReg($tok); |
| 665 | 665 | |
| 666 | - if( $match ){ |
|
| 667 | - return count($match) === 1 ? $match[0] : $match; |
|
| 666 | + if ($match) { |
|
| 667 | + return count($match)===1 ? $match[0] : $match; |
|
| 668 | 668 | } |
| 669 | 669 | |
| 670 | - }elseif( $char === '#' ){ |
|
| 670 | + }elseif ($char==='#') { |
|
| 671 | 671 | $match = $this->MatchChar($tok[1]); |
| 672 | 672 | |
| 673 | - }else{ |
|
| 673 | + }else { |
|
| 674 | 674 | // Non-terminal, match using a function call |
| 675 | 675 | $match = $this->$tok(); |
| 676 | 676 | |
| 677 | 677 | } |
| 678 | 678 | |
| 679 | - if( $match ){ |
|
| 679 | + if ($match) { |
|
| 680 | 680 | return $match; |
| 681 | 681 | } |
| 682 | 682 | } |
@@ -687,12 +687,12 @@ discard block |
||
| 687 | 687 | * |
| 688 | 688 | * @return string |
| 689 | 689 | */ |
| 690 | - private function MatchFuncs($toks){ |
|
| 690 | + private function MatchFuncs($toks) { |
|
| 691 | 691 | |
| 692 | - if( $this->pos < $this->input_len ){ |
|
| 693 | - foreach($toks as $tok){ |
|
| 692 | + if ($this->pos<$this->input_len) { |
|
| 693 | + foreach ($toks as $tok) { |
|
| 694 | 694 | $match = $this->$tok(); |
| 695 | - if( $match ){ |
|
| 695 | + if ($match) { |
|
| 696 | 696 | return $match; |
| 697 | 697 | } |
| 698 | 698 | } |
@@ -701,17 +701,17 @@ discard block |
||
| 701 | 701 | } |
| 702 | 702 | |
| 703 | 703 | // Match a single character in the input, |
| 704 | - private function MatchChar($tok){ |
|
| 705 | - if( ($this->pos < $this->input_len) && ($this->input[$this->pos] === $tok) ){ |
|
| 704 | + private function MatchChar($tok) { |
|
| 705 | + if (($this->pos<$this->input_len) && ($this->input[$this->pos]===$tok)) { |
|
| 706 | 706 | $this->skipWhitespace(1); |
| 707 | 707 | return $tok; |
| 708 | 708 | } |
| 709 | 709 | } |
| 710 | 710 | |
| 711 | 711 | // Match a regexp from the current start point |
| 712 | - private function MatchReg($tok){ |
|
| 712 | + private function MatchReg($tok) { |
|
| 713 | 713 | |
| 714 | - if( preg_match($tok, $this->input, $match, 0, $this->pos) ){ |
|
| 714 | + if (preg_match($tok, $this->input, $match, 0, $this->pos)) { |
|
| 715 | 715 | $this->skipWhitespace(strlen($match[0])); |
| 716 | 716 | return $match; |
| 717 | 717 | } |
@@ -725,30 +725,30 @@ discard block |
||
| 725 | 725 | * @param string $tok |
| 726 | 726 | * @return integer |
| 727 | 727 | */ |
| 728 | - public function PeekReg($tok){ |
|
| 728 | + public function PeekReg($tok) { |
|
| 729 | 729 | return preg_match($tok, $this->input, $match, 0, $this->pos); |
| 730 | 730 | } |
| 731 | 731 | |
| 732 | 732 | /** |
| 733 | 733 | * @param string $tok |
| 734 | 734 | */ |
| 735 | - public function PeekChar($tok){ |
|
| 735 | + public function PeekChar($tok) { |
|
| 736 | 736 | //return ($this->input[$this->pos] === $tok ); |
| 737 | - return ($this->pos < $this->input_len) && ($this->input[$this->pos] === $tok ); |
|
| 737 | + return ($this->pos<$this->input_len) && ($this->input[$this->pos]===$tok); |
|
| 738 | 738 | } |
| 739 | 739 | |
| 740 | 740 | |
| 741 | 741 | /** |
| 742 | 742 | * @param integer $length |
| 743 | 743 | */ |
| 744 | - public function skipWhitespace($length){ |
|
| 744 | + public function skipWhitespace($length) { |
|
| 745 | 745 | |
| 746 | 746 | $this->pos += $length; |
| 747 | 747 | |
| 748 | - for(; $this->pos < $this->input_len; $this->pos++ ){ |
|
| 748 | + for (; $this->pos<$this->input_len; $this->pos++) { |
|
| 749 | 749 | $c = $this->input[$this->pos]; |
| 750 | 750 | |
| 751 | - if( ($c !== "\n") && ($c !== "\r") && ($c !== "\t") && ($c !== ' ') ){ |
|
| 751 | + if (($c!=="\n") && ($c!=="\r") && ($c!=="\t") && ($c!==' ')) { |
|
| 752 | 752 | break; |
| 753 | 753 | } |
| 754 | 754 | } |
@@ -760,10 +760,10 @@ discard block |
||
| 760 | 760 | * @param string|null $msg |
| 761 | 761 | */ |
| 762 | 762 | public function expect($tok, $msg = NULL) { |
| 763 | - $result = $this->match( array($tok) ); |
|
| 763 | + $result = $this->match(array($tok)); |
|
| 764 | 764 | if (!$result) { |
| 765 | - $this->Error( $msg ? "Expected '" . $tok . "' got '" . $this->input[$this->pos] . "'" : $msg ); |
|
| 766 | - } else { |
|
| 765 | + $this->Error($msg ? "Expected '".$tok."' got '".$this->input[$this->pos]."'" : $msg); |
|
| 766 | + }else { |
|
| 767 | 767 | return $result; |
| 768 | 768 | } |
| 769 | 769 | } |
@@ -771,11 +771,11 @@ discard block |
||
| 771 | 771 | /** |
| 772 | 772 | * @param string $tok |
| 773 | 773 | */ |
| 774 | - public function expectChar($tok, $msg = null ){ |
|
| 774 | + public function expectChar($tok, $msg = null) { |
|
| 775 | 775 | $result = $this->MatchChar($tok); |
| 776 | - if( !$result ){ |
|
| 777 | - $this->Error( $msg ? "Expected '" . $tok . "' got '" . $this->input[$this->pos] . "'" : $msg ); |
|
| 778 | - }else{ |
|
| 776 | + if (!$result) { |
|
| 777 | + $this->Error($msg ? "Expected '".$tok."' got '".$this->input[$this->pos]."'" : $msg); |
|
| 778 | + }else { |
|
| 779 | 779 | return $result; |
| 780 | 780 | } |
| 781 | 781 | } |
@@ -825,31 +825,31 @@ discard block |
||
| 825 | 825 | // Only at one point is the primary rule not called from the |
| 826 | 826 | // block rule: at the root level. |
| 827 | 827 | // |
| 828 | - private function parsePrimary(){ |
|
| 828 | + private function parsePrimary() { |
|
| 829 | 829 | $root = array(); |
| 830 | 830 | |
| 831 | - while( true ){ |
|
| 831 | + while (true) { |
|
| 832 | 832 | |
| 833 | - if( $this->pos >= $this->input_len ){ |
|
| 833 | + if ($this->pos>=$this->input_len) { |
|
| 834 | 834 | break; |
| 835 | 835 | } |
| 836 | 836 | |
| 837 | 837 | $node = $this->parseExtend(true); |
| 838 | - if( $node ){ |
|
| 839 | - $root = array_merge($root,$node); |
|
| 838 | + if ($node) { |
|
| 839 | + $root = array_merge($root, $node); |
|
| 840 | 840 | continue; |
| 841 | 841 | } |
| 842 | 842 | |
| 843 | 843 | //$node = $this->MatchFuncs( array( 'parseMixinDefinition', 'parseRule', 'parseRuleset', 'parseMixinCall', 'parseComment', 'parseDirective')); |
| 844 | - $node = $this->MatchFuncs( array( 'parseMixinDefinition', 'parseNameValue', 'parseRule', 'parseRuleset', 'parseMixinCall', 'parseComment', 'parseRulesetCall', 'parseDirective')); |
|
| 844 | + $node = $this->MatchFuncs(array('parseMixinDefinition', 'parseNameValue', 'parseRule', 'parseRuleset', 'parseMixinCall', 'parseComment', 'parseRulesetCall', 'parseDirective')); |
|
| 845 | 845 | |
| 846 | - if( $node ){ |
|
| 846 | + if ($node) { |
|
| 847 | 847 | $root[] = $node; |
| 848 | - }elseif( !$this->MatchReg('/\\G[\s\n;]+/') ){ |
|
| 848 | + }elseif (!$this->MatchReg('/\\G[\s\n;]+/')) { |
|
| 849 | 849 | break; |
| 850 | 850 | } |
| 851 | 851 | |
| 852 | - if( $this->PeekChar('}') ){ |
|
| 852 | + if ($this->PeekChar('}')) { |
|
| 853 | 853 | break; |
| 854 | 854 | } |
| 855 | 855 | } |
@@ -862,30 +862,30 @@ discard block |
||
| 862 | 862 | // We create a Comment node for CSS comments `/* */`, |
| 863 | 863 | // but keep the LeSS comments `//` silent, by just skipping |
| 864 | 864 | // over them. |
| 865 | - private function parseComment(){ |
|
| 865 | + private function parseComment() { |
|
| 866 | 866 | |
| 867 | - if( $this->input[$this->pos] !== '/' ){ |
|
| 867 | + if ($this->input[$this->pos]!=='/') { |
|
| 868 | 868 | return; |
| 869 | 869 | } |
| 870 | 870 | |
| 871 | - if( $this->input[$this->pos+1] === '/' ){ |
|
| 871 | + if ($this->input[$this->pos+1]==='/') { |
|
| 872 | 872 | $match = $this->MatchReg('/\\G\/\/.*/'); |
| 873 | - return $this->NewObj4('Less_Tree_Comment',array($match[0], true, $this->pos, $this->env->currentFileInfo)); |
|
| 873 | + return $this->NewObj4('Less_Tree_Comment', array($match[0], true, $this->pos, $this->env->currentFileInfo)); |
|
| 874 | 874 | } |
| 875 | 875 | |
| 876 | 876 | //$comment = $this->MatchReg('/\\G\/\*(?:[^*]|\*+[^\/*])*\*+\/\n?/'); |
| 877 | - $comment = $this->MatchReg('/\\G\/\*(?s).*?\*+\/\n?/');//not the same as less.js to prevent fatal errors |
|
| 878 | - if( $comment ){ |
|
| 879 | - return $this->NewObj4('Less_Tree_Comment',array($comment[0], false, $this->pos, $this->env->currentFileInfo)); |
|
| 877 | + $comment = $this->MatchReg('/\\G\/\*(?s).*?\*+\/\n?/'); //not the same as less.js to prevent fatal errors |
|
| 878 | + if ($comment) { |
|
| 879 | + return $this->NewObj4('Less_Tree_Comment', array($comment[0], false, $this->pos, $this->env->currentFileInfo)); |
|
| 880 | 880 | } |
| 881 | 881 | } |
| 882 | 882 | |
| 883 | - private function parseComments(){ |
|
| 883 | + private function parseComments() { |
|
| 884 | 884 | $comments = array(); |
| 885 | 885 | |
| 886 | - while( $this->pos < $this->input_len ){ |
|
| 886 | + while ($this->pos<$this->input_len) { |
|
| 887 | 887 | $comment = $this->parseComment(); |
| 888 | - if( !$comment ){ |
|
| 888 | + if (!$comment) { |
|
| 889 | 889 | break; |
| 890 | 890 | } |
| 891 | 891 | |
@@ -907,12 +907,12 @@ discard block |
||
| 907 | 907 | $e = false; |
| 908 | 908 | $index = $this->pos; |
| 909 | 909 | |
| 910 | - if( $this->input[$this->pos] === '~' ){ |
|
| 910 | + if ($this->input[$this->pos]==='~') { |
|
| 911 | 911 | $j++; |
| 912 | 912 | $e = true; // Escaped strings |
| 913 | 913 | } |
| 914 | 914 | |
| 915 | - if( $this->input[$j] != '"' && $this->input[$j] !== "'" ){ |
|
| 915 | + if ($this->input[$j]!='"' && $this->input[$j]!=="'") { |
|
| 916 | 916 | return; |
| 917 | 917 | } |
| 918 | 918 | |
@@ -924,9 +924,9 @@ discard block |
||
| 924 | 924 | //$str = $this->MatchReg('/\\G"((?:[^"\\\\\r\n]|\\\\.)*)"|\'((?:[^\'\\\\\r\n]|\\\\.)*)\'/'); |
| 925 | 925 | $str = $this->MatchReg('/\\G"((?:[^"\\\\\r\n]|\\\\.|\\\\\r\n|\\\\[\n\r\f])*)"|\'((?:[^\'\\\\\r\n]|\\\\.|\\\\\r\n|\\\\[\n\r\f])*)\'/'); |
| 926 | 926 | |
| 927 | - if( $str ){ |
|
| 928 | - $result = $str[0][0] == '"' ? $str[1] : $str[2]; |
|
| 929 | - return $this->NewObj5('Less_Tree_Quoted',array($str[0], $result, $e, $index, $this->env->currentFileInfo) ); |
|
| 927 | + if ($str) { |
|
| 928 | + $result = $str[0][0]=='"' ? $str[1] : $str[2]; |
|
| 929 | + return $this->NewObj5('Less_Tree_Quoted', array($str[0], $result, $e, $index, $this->env->currentFileInfo)); |
|
| 930 | 930 | } |
| 931 | 931 | return; |
| 932 | 932 | } |
@@ -937,31 +937,31 @@ discard block |
||
| 937 | 937 | // |
| 938 | 938 | // black border-collapse |
| 939 | 939 | // |
| 940 | - private function parseEntitiesKeyword(){ |
|
| 940 | + private function parseEntitiesKeyword() { |
|
| 941 | 941 | |
| 942 | 942 | //$k = $this->MatchReg('/\\G[_A-Za-z-][_A-Za-z0-9-]*/'); |
| 943 | 943 | $k = $this->MatchReg('/\\G%|\\G[_A-Za-z-][_A-Za-z0-9-]*/'); |
| 944 | - if( $k ){ |
|
| 944 | + if ($k) { |
|
| 945 | 945 | $k = $k[0]; |
| 946 | 946 | $color = $this->fromKeyword($k); |
| 947 | - if( $color ){ |
|
| 947 | + if ($color) { |
|
| 948 | 948 | return $color; |
| 949 | 949 | } |
| 950 | - return $this->NewObj1('Less_Tree_Keyword',$k); |
|
| 950 | + return $this->NewObj1('Less_Tree_Keyword', $k); |
|
| 951 | 951 | } |
| 952 | 952 | } |
| 953 | 953 | |
| 954 | 954 | // duplicate of Less_Tree_Color::FromKeyword |
| 955 | - private function FromKeyword( $keyword ){ |
|
| 955 | + private function FromKeyword($keyword) { |
|
| 956 | 956 | $keyword = strtolower($keyword); |
| 957 | 957 | |
| 958 | - if( Less_Colors::hasOwnProperty($keyword) ){ |
|
| 958 | + if (Less_Colors::hasOwnProperty($keyword)) { |
|
| 959 | 959 | // detect named color |
| 960 | - return $this->NewObj1('Less_Tree_Color',substr(Less_Colors::color($keyword), 1)); |
|
| 960 | + return $this->NewObj1('Less_Tree_Color', substr(Less_Colors::color($keyword), 1)); |
|
| 961 | 961 | } |
| 962 | 962 | |
| 963 | - if( $keyword === 'transparent' ){ |
|
| 964 | - return $this->NewObj3('Less_Tree_Color', array( array(0, 0, 0), 0, true)); |
|
| 963 | + if ($keyword==='transparent') { |
|
| 964 | + return $this->NewObj3('Less_Tree_Color', array(array(0, 0, 0), 0, true)); |
|
| 965 | 965 | } |
| 966 | 966 | } |
| 967 | 967 | |
@@ -975,24 +975,24 @@ discard block |
||
| 975 | 975 | // |
| 976 | 976 | // The arguments are parsed with the `entities.arguments` parser. |
| 977 | 977 | // |
| 978 | - private function parseEntitiesCall(){ |
|
| 978 | + private function parseEntitiesCall() { |
|
| 979 | 979 | $index = $this->pos; |
| 980 | 980 | |
| 981 | - if( !preg_match('/\\G([\w-]+|%|progid:[\w\.]+)\(/', $this->input, $name,0,$this->pos) ){ |
|
| 981 | + if (!preg_match('/\\G([\w-]+|%|progid:[\w\.]+)\(/', $this->input, $name, 0, $this->pos)) { |
|
| 982 | 982 | return; |
| 983 | 983 | } |
| 984 | 984 | $name = $name[1]; |
| 985 | 985 | $nameLC = strtolower($name); |
| 986 | 986 | |
| 987 | - if ($nameLC === 'url') { |
|
| 987 | + if ($nameLC==='url') { |
|
| 988 | 988 | return null; |
| 989 | 989 | } |
| 990 | 990 | |
| 991 | 991 | $this->pos += strlen($name); |
| 992 | 992 | |
| 993 | - if( $nameLC === 'alpha' ){ |
|
| 993 | + if ($nameLC==='alpha') { |
|
| 994 | 994 | $alpha_ret = $this->parseAlpha(); |
| 995 | - if( $alpha_ret ){ |
|
| 995 | + if ($alpha_ret) { |
|
| 996 | 996 | return $alpha_ret; |
| 997 | 997 | } |
| 998 | 998 | } |
@@ -1001,12 +1001,12 @@ discard block |
||
| 1001 | 1001 | |
| 1002 | 1002 | $args = $this->parseEntitiesArguments(); |
| 1003 | 1003 | |
| 1004 | - if( !$this->MatchChar(')') ){ |
|
| 1004 | + if (!$this->MatchChar(')')) { |
|
| 1005 | 1005 | return; |
| 1006 | 1006 | } |
| 1007 | 1007 | |
| 1008 | 1008 | if ($name) { |
| 1009 | - return $this->NewObj4('Less_Tree_Call',array($name, $args, $index, $this->env->currentFileInfo) ); |
|
| 1009 | + return $this->NewObj4('Less_Tree_Call', array($name, $args, $index, $this->env->currentFileInfo)); |
|
| 1010 | 1010 | } |
| 1011 | 1011 | } |
| 1012 | 1012 | |
@@ -1015,25 +1015,25 @@ discard block |
||
| 1015 | 1015 | * |
| 1016 | 1016 | * @return array |
| 1017 | 1017 | */ |
| 1018 | - private function parseEntitiesArguments(){ |
|
| 1018 | + private function parseEntitiesArguments() { |
|
| 1019 | 1019 | |
| 1020 | 1020 | $args = array(); |
| 1021 | - while( true ){ |
|
| 1022 | - $arg = $this->MatchFuncs( array('parseEntitiesAssignment','parseExpression') ); |
|
| 1023 | - if( !$arg ){ |
|
| 1021 | + while (true) { |
|
| 1022 | + $arg = $this->MatchFuncs(array('parseEntitiesAssignment', 'parseExpression')); |
|
| 1023 | + if (!$arg) { |
|
| 1024 | 1024 | break; |
| 1025 | 1025 | } |
| 1026 | 1026 | |
| 1027 | 1027 | $args[] = $arg; |
| 1028 | - if( !$this->MatchChar(',') ){ |
|
| 1028 | + if (!$this->MatchChar(',')) { |
|
| 1029 | 1029 | break; |
| 1030 | 1030 | } |
| 1031 | 1031 | } |
| 1032 | 1032 | return $args; |
| 1033 | 1033 | } |
| 1034 | 1034 | |
| 1035 | - private function parseEntitiesLiteral(){ |
|
| 1036 | - return $this->MatchFuncs( array('parseEntitiesDimension','parseEntitiesColor','parseEntitiesQuoted','parseUnicodeDescriptor') ); |
|
| 1035 | + private function parseEntitiesLiteral() { |
|
| 1036 | + return $this->MatchFuncs(array('parseEntitiesDimension', 'parseEntitiesColor', 'parseEntitiesQuoted', 'parseUnicodeDescriptor')); |
|
| 1037 | 1037 | } |
| 1038 | 1038 | |
| 1039 | 1039 | // Assignments are argument entities for calls. |
@@ -1044,17 +1044,17 @@ discard block |
||
| 1044 | 1044 | private function parseEntitiesAssignment() { |
| 1045 | 1045 | |
| 1046 | 1046 | $key = $this->MatchReg('/\\G\w+(?=\s?=)/'); |
| 1047 | - if( !$key ){ |
|
| 1047 | + if (!$key) { |
|
| 1048 | 1048 | return; |
| 1049 | 1049 | } |
| 1050 | 1050 | |
| 1051 | - if( !$this->MatchChar('=') ){ |
|
| 1051 | + if (!$this->MatchChar('=')) { |
|
| 1052 | 1052 | return; |
| 1053 | 1053 | } |
| 1054 | 1054 | |
| 1055 | 1055 | $value = $this->parseEntity(); |
| 1056 | - if( $value ){ |
|
| 1057 | - return $this->NewObj2('Less_Tree_Assignment',array($key[0], $value)); |
|
| 1056 | + if ($value) { |
|
| 1057 | + return $this->NewObj2('Less_Tree_Assignment', array($key[0], $value)); |
|
| 1058 | 1058 | } |
| 1059 | 1059 | } |
| 1060 | 1060 | |
@@ -1065,15 +1065,15 @@ discard block |
||
| 1065 | 1065 | // standard function calls. The difference is that the argument doesn't have |
| 1066 | 1066 | // to be enclosed within a string, so it can't be parsed as an Expression. |
| 1067 | 1067 | // |
| 1068 | - private function parseEntitiesUrl(){ |
|
| 1068 | + private function parseEntitiesUrl() { |
|
| 1069 | 1069 | |
| 1070 | 1070 | |
| 1071 | - if( $this->input[$this->pos] !== 'u' || !$this->matchReg('/\\Gurl\(/') ){ |
|
| 1071 | + if ($this->input[$this->pos]!=='u' || !$this->matchReg('/\\Gurl\(/')) { |
|
| 1072 | 1072 | return; |
| 1073 | 1073 | } |
| 1074 | 1074 | |
| 1075 | - $value = $this->match( array('parseEntitiesQuoted','parseEntitiesVariable','/\\Gdata\:.*?[^\)]+/','/\\G(?:(?:\\\\[\(\)\'"])|[^\(\)\'"])+/') ); |
|
| 1076 | - if( !$value ){ |
|
| 1075 | + $value = $this->match(array('parseEntitiesQuoted', 'parseEntitiesVariable', '/\\Gdata\:.*?[^\)]+/', '/\\G(?:(?:\\\\[\(\)\'"])|[^\(\)\'"])+/')); |
|
| 1076 | + if (!$value) { |
|
| 1077 | 1077 | $value = ''; |
| 1078 | 1078 | } |
| 1079 | 1079 | |
@@ -1081,11 +1081,11 @@ discard block |
||
| 1081 | 1081 | $this->expectChar(')'); |
| 1082 | 1082 | |
| 1083 | 1083 | |
| 1084 | - if( isset($value->value) || $value instanceof Less_Tree_Variable ){ |
|
| 1085 | - return $this->NewObj2('Less_Tree_Url',array($value, $this->env->currentFileInfo)); |
|
| 1084 | + if (isset($value->value) || $value instanceof Less_Tree_Variable) { |
|
| 1085 | + return $this->NewObj2('Less_Tree_Url', array($value, $this->env->currentFileInfo)); |
|
| 1086 | 1086 | } |
| 1087 | 1087 | |
| 1088 | - return $this->NewObj2('Less_Tree_Url', array( $this->NewObj1('Less_Tree_Anonymous',$value), $this->env->currentFileInfo) ); |
|
| 1088 | + return $this->NewObj2('Less_Tree_Url', array($this->NewObj1('Less_Tree_Anonymous', $value), $this->env->currentFileInfo)); |
|
| 1089 | 1089 | } |
| 1090 | 1090 | |
| 1091 | 1091 | |
@@ -1097,10 +1097,10 @@ discard block |
||
| 1097 | 1097 | // We use a different parser for variable definitions, |
| 1098 | 1098 | // see `parsers.variable`. |
| 1099 | 1099 | // |
| 1100 | - private function parseEntitiesVariable(){ |
|
| 1100 | + private function parseEntitiesVariable() { |
|
| 1101 | 1101 | $index = $this->pos; |
| 1102 | 1102 | if ($this->PeekChar('@') && ($name = $this->MatchReg('/\\G@@?[\w-]+/'))) { |
| 1103 | - return $this->NewObj3('Less_Tree_Variable', array( $name[0], $index, $this->env->currentFileInfo)); |
|
| 1103 | + return $this->NewObj3('Less_Tree_Variable', array($name[0], $index, $this->env->currentFileInfo)); |
|
| 1104 | 1104 | } |
| 1105 | 1105 | } |
| 1106 | 1106 | |
@@ -1109,8 +1109,8 @@ discard block |
||
| 1109 | 1109 | private function parseEntitiesVariableCurly() { |
| 1110 | 1110 | $index = $this->pos; |
| 1111 | 1111 | |
| 1112 | - if( $this->input_len > ($this->pos+1) && $this->input[$this->pos] === '@' && ($curly = $this->MatchReg('/\\G@\{([\w-]+)\}/')) ){ |
|
| 1113 | - return $this->NewObj3('Less_Tree_Variable',array('@'.$curly[1], $index, $this->env->currentFileInfo)); |
|
| 1112 | + if ($this->input_len>($this->pos+1) && $this->input[$this->pos]==='@' && ($curly = $this->MatchReg('/\\G@\{([\w-]+)\}/'))) { |
|
| 1113 | + return $this->NewObj3('Less_Tree_Variable', array('@'.$curly[1], $index, $this->env->currentFileInfo)); |
|
| 1114 | 1114 | } |
| 1115 | 1115 | } |
| 1116 | 1116 | |
@@ -1121,9 +1121,9 @@ discard block |
||
| 1121 | 1121 | // |
| 1122 | 1122 | // `rgb` and `hsl` colors are parsed through the `entities.call` parser. |
| 1123 | 1123 | // |
| 1124 | - private function parseEntitiesColor(){ |
|
| 1124 | + private function parseEntitiesColor() { |
|
| 1125 | 1125 | if ($this->PeekChar('#') && ($rgb = $this->MatchReg('/\\G#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})/'))) { |
| 1126 | - return $this->NewObj1('Less_Tree_Color',$rgb[1]); |
|
| 1126 | + return $this->NewObj1('Less_Tree_Color', $rgb[1]); |
|
| 1127 | 1127 | } |
| 1128 | 1128 | } |
| 1129 | 1129 | |
@@ -1132,22 +1132,22 @@ discard block |
||
| 1132 | 1132 | // |
| 1133 | 1133 | // 0.5em 95% |
| 1134 | 1134 | // |
| 1135 | - private function parseEntitiesDimension(){ |
|
| 1135 | + private function parseEntitiesDimension() { |
|
| 1136 | 1136 | |
| 1137 | 1137 | $c = @ord($this->input[$this->pos]); |
| 1138 | 1138 | |
| 1139 | 1139 | //Is the first char of the dimension 0-9, '.', '+' or '-' |
| 1140 | - if (($c > 57 || $c < 43) || $c === 47 || $c == 44){ |
|
| 1140 | + if (($c>57 || $c<43) || $c===47 || $c==44) { |
|
| 1141 | 1141 | return; |
| 1142 | 1142 | } |
| 1143 | 1143 | |
| 1144 | 1144 | $value = $this->MatchReg('/\\G([+-]?\d*\.?\d+)(%|[a-z]+)?/'); |
| 1145 | - if( $value ){ |
|
| 1145 | + if ($value) { |
|
| 1146 | 1146 | |
| 1147 | - if( isset($value[2]) ){ |
|
| 1148 | - return $this->NewObj2('Less_Tree_Dimension', array($value[1],$value[2])); |
|
| 1147 | + if (isset($value[2])) { |
|
| 1148 | + return $this->NewObj2('Less_Tree_Dimension', array($value[1], $value[2])); |
|
| 1149 | 1149 | } |
| 1150 | - return $this->NewObj1('Less_Tree_Dimension',$value[1]); |
|
| 1150 | + return $this->NewObj1('Less_Tree_Dimension', $value[1]); |
|
| 1151 | 1151 | } |
| 1152 | 1152 | } |
| 1153 | 1153 | |
@@ -1159,7 +1159,7 @@ discard block |
||
| 1159 | 1159 | // |
| 1160 | 1160 | function parseUnicodeDescriptor() { |
| 1161 | 1161 | $ud = $this->MatchReg('/\\G(U\+[0-9a-fA-F?]+)(\-[0-9a-fA-F?]+)?/'); |
| 1162 | - if( $ud ){ |
|
| 1162 | + if ($ud) { |
|
| 1163 | 1163 | return $this->NewObj1('Less_Tree_UnicodeDescriptor', $ud[0]); |
| 1164 | 1164 | } |
| 1165 | 1165 | } |
@@ -1170,21 +1170,21 @@ discard block |
||
| 1170 | 1170 | // |
| 1171 | 1171 | // `window.location.href` |
| 1172 | 1172 | // |
| 1173 | - private function parseEntitiesJavascript(){ |
|
| 1173 | + private function parseEntitiesJavascript() { |
|
| 1174 | 1174 | $e = false; |
| 1175 | 1175 | $j = $this->pos; |
| 1176 | - if( $this->input[$j] === '~' ){ |
|
| 1176 | + if ($this->input[$j]==='~') { |
|
| 1177 | 1177 | $j++; |
| 1178 | 1178 | $e = true; |
| 1179 | 1179 | } |
| 1180 | - if( $this->input[$j] !== '`' ){ |
|
| 1180 | + if ($this->input[$j]!=='`') { |
|
| 1181 | 1181 | return; |
| 1182 | 1182 | } |
| 1183 | - if( $e ){ |
|
| 1183 | + if ($e) { |
|
| 1184 | 1184 | $this->MatchChar('~'); |
| 1185 | 1185 | } |
| 1186 | 1186 | $str = $this->MatchReg('/\\G`([^`]*)`/'); |
| 1187 | - if( $str ){ |
|
| 1187 | + if ($str) { |
|
| 1188 | 1188 | return $this->NewObj3('Less_Tree_Javascript', array($str[1], $this->pos, $e)); |
| 1189 | 1189 | } |
| 1190 | 1190 | } |
@@ -1195,7 +1195,7 @@ discard block |
||
| 1195 | 1195 | // |
| 1196 | 1196 | // @fink: |
| 1197 | 1197 | // |
| 1198 | - private function parseVariable(){ |
|
| 1198 | + private function parseVariable() { |
|
| 1199 | 1199 | if ($this->PeekChar('@') && ($name = $this->MatchReg('/\\G(@[\w-]+)\s*:/'))) { |
| 1200 | 1200 | return $name[1]; |
| 1201 | 1201 | } |
@@ -1207,10 +1207,10 @@ discard block |
||
| 1207 | 1207 | // |
| 1208 | 1208 | // @fink(); |
| 1209 | 1209 | // |
| 1210 | - private function parseRulesetCall(){ |
|
| 1210 | + private function parseRulesetCall() { |
|
| 1211 | 1211 | |
| 1212 | - if( $this->input[$this->pos] === '@' && ($name = $this->MatchReg('/\\G(@[\w-]+)\s*\(\s*\)\s*;/')) ){ |
|
| 1213 | - return $this->NewObj1('Less_Tree_RulesetCall', $name[1] ); |
|
| 1212 | + if ($this->input[$this->pos]==='@' && ($name = $this->MatchReg('/\\G(@[\w-]+)\s*\(\s*\)\s*;/'))) { |
|
| 1213 | + return $this->NewObj1('Less_Tree_RulesetCall', $name[1]); |
|
| 1214 | 1214 | } |
| 1215 | 1215 | } |
| 1216 | 1216 | |
@@ -1218,36 +1218,36 @@ discard block |
||
| 1218 | 1218 | // |
| 1219 | 1219 | // extend syntax - used to extend selectors |
| 1220 | 1220 | // |
| 1221 | - function parseExtend($isRule = false){ |
|
| 1221 | + function parseExtend($isRule = false) { |
|
| 1222 | 1222 | |
| 1223 | 1223 | $index = $this->pos; |
| 1224 | 1224 | $extendList = array(); |
| 1225 | 1225 | |
| 1226 | 1226 | |
| 1227 | - if( !$this->MatchReg( $isRule ? '/\\G&:extend\(/' : '/\\G:extend\(/' ) ){ return; } |
|
| 1227 | + if (!$this->MatchReg($isRule ? '/\\G&:extend\(/' : '/\\G:extend\(/')) { return; } |
|
| 1228 | 1228 | |
| 1229 | - do{ |
|
| 1229 | + do { |
|
| 1230 | 1230 | $option = null; |
| 1231 | 1231 | $elements = array(); |
| 1232 | - while( true ){ |
|
| 1232 | + while (true) { |
|
| 1233 | 1233 | $option = $this->MatchReg('/\\G(all)(?=\s*(\)|,))/'); |
| 1234 | - if( $option ){ break; } |
|
| 1234 | + if ($option) { break; } |
|
| 1235 | 1235 | $e = $this->parseElement(); |
| 1236 | - if( !$e ){ break; } |
|
| 1236 | + if (!$e) { break; } |
|
| 1237 | 1237 | $elements[] = $e; |
| 1238 | 1238 | } |
| 1239 | 1239 | |
| 1240 | - if( $option ){ |
|
| 1240 | + if ($option) { |
|
| 1241 | 1241 | $option = $option[1]; |
| 1242 | 1242 | } |
| 1243 | 1243 | |
| 1244 | - $extendList[] = $this->NewObj3('Less_Tree_Extend', array( $this->NewObj1('Less_Tree_Selector',$elements), $option, $index )); |
|
| 1244 | + $extendList[] = $this->NewObj3('Less_Tree_Extend', array($this->NewObj1('Less_Tree_Selector', $elements), $option, $index)); |
|
| 1245 | 1245 | |
| 1246 | - }while( $this->MatchChar(",") ); |
|
| 1246 | + } while ($this->MatchChar(",")); |
|
| 1247 | 1247 | |
| 1248 | 1248 | $this->expect('/\\G\)/'); |
| 1249 | 1249 | |
| 1250 | - if( $isRule ){ |
|
| 1250 | + if ($isRule) { |
|
| 1251 | 1251 | $this->expect('/\\G;/'); |
| 1252 | 1252 | } |
| 1253 | 1253 | |
@@ -1266,10 +1266,10 @@ discard block |
||
| 1266 | 1266 | // namespaced, but we only support the child and descendant |
| 1267 | 1267 | // selector for now. |
| 1268 | 1268 | // |
| 1269 | - private function parseMixinCall(){ |
|
| 1269 | + private function parseMixinCall() { |
|
| 1270 | 1270 | |
| 1271 | 1271 | $char = $this->input[$this->pos]; |
| 1272 | - if( $char !== '.' && $char !== '#' ){ |
|
| 1272 | + if ($char!=='.' && $char!=='#') { |
|
| 1273 | 1273 | return; |
| 1274 | 1274 | } |
| 1275 | 1275 | |
@@ -1278,21 +1278,21 @@ discard block |
||
| 1278 | 1278 | |
| 1279 | 1279 | $elements = $this->parseMixinCallElements(); |
| 1280 | 1280 | |
| 1281 | - if( $elements ){ |
|
| 1281 | + if ($elements) { |
|
| 1282 | 1282 | |
| 1283 | - if( $this->MatchChar('(') ){ |
|
| 1283 | + if ($this->MatchChar('(')) { |
|
| 1284 | 1284 | $returned = $this->parseMixinArgs(true); |
| 1285 | 1285 | $args = $returned['args']; |
| 1286 | 1286 | $this->expectChar(')'); |
| 1287 | - }else{ |
|
| 1287 | + }else { |
|
| 1288 | 1288 | $args = array(); |
| 1289 | 1289 | } |
| 1290 | 1290 | |
| 1291 | 1291 | $important = $this->parseImportant(); |
| 1292 | 1292 | |
| 1293 | - if( $this->parseEnd() ){ |
|
| 1293 | + if ($this->parseEnd()) { |
|
| 1294 | 1294 | $this->forget(); |
| 1295 | - return $this->NewObj5('Less_Tree_Mixin_Call', array( $elements, $args, $index, $this->env->currentFileInfo, $important)); |
|
| 1295 | + return $this->NewObj5('Less_Tree_Mixin_Call', array($elements, $args, $index, $this->env->currentFileInfo, $important)); |
|
| 1296 | 1296 | } |
| 1297 | 1297 | } |
| 1298 | 1298 | |
@@ -1300,14 +1300,14 @@ discard block |
||
| 1300 | 1300 | } |
| 1301 | 1301 | |
| 1302 | 1302 | |
| 1303 | - private function parseMixinCallElements(){ |
|
| 1303 | + private function parseMixinCallElements() { |
|
| 1304 | 1304 | $elements = array(); |
| 1305 | 1305 | $c = null; |
| 1306 | 1306 | |
| 1307 | - while( true ){ |
|
| 1307 | + while (true) { |
|
| 1308 | 1308 | $elemIndex = $this->pos; |
| 1309 | 1309 | $e = $this->MatchReg('/\\G[#.](?:[\w-]|\\\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/'); |
| 1310 | - if( !$e ){ |
|
| 1310 | + if (!$e) { |
|
| 1311 | 1311 | break; |
| 1312 | 1312 | } |
| 1313 | 1313 | $elements[] = $this->NewObj4('Less_Tree_Element', array($c, $e[0], $elemIndex, $this->env->currentFileInfo)); |
@@ -1322,7 +1322,7 @@ discard block |
||
| 1322 | 1322 | /** |
| 1323 | 1323 | * @param boolean $isCall |
| 1324 | 1324 | */ |
| 1325 | - private function parseMixinArgs( $isCall ){ |
|
| 1325 | + private function parseMixinArgs($isCall) { |
|
| 1326 | 1326 | $expressions = array(); |
| 1327 | 1327 | $argsSemiColon = array(); |
| 1328 | 1328 | $isSemiColonSeperated = null; |
@@ -1333,54 +1333,54 @@ discard block |
||
| 1333 | 1333 | |
| 1334 | 1334 | $this->save(); |
| 1335 | 1335 | |
| 1336 | - while( true ){ |
|
| 1337 | - if( $isCall ){ |
|
| 1338 | - $arg = $this->MatchFuncs( array( 'parseDetachedRuleset','parseExpression' ) ); |
|
| 1339 | - } else { |
|
| 1336 | + while (true) { |
|
| 1337 | + if ($isCall) { |
|
| 1338 | + $arg = $this->MatchFuncs(array('parseDetachedRuleset', 'parseExpression')); |
|
| 1339 | + }else { |
|
| 1340 | 1340 | $this->parseComments(); |
| 1341 | - if( $this->input[ $this->pos ] === '.' && $this->MatchReg('/\\G\.{3}/') ){ |
|
| 1341 | + if ($this->input[$this->pos]==='.' && $this->MatchReg('/\\G\.{3}/')) { |
|
| 1342 | 1342 | $returner['variadic'] = true; |
| 1343 | - if( $this->MatchChar(";") && !$isSemiColonSeperated ){ |
|
| 1343 | + if ($this->MatchChar(";") && !$isSemiColonSeperated) { |
|
| 1344 | 1344 | $isSemiColonSeperated = true; |
| 1345 | 1345 | } |
| 1346 | 1346 | |
| 1347 | - if( $isSemiColonSeperated ){ |
|
| 1347 | + if ($isSemiColonSeperated) { |
|
| 1348 | 1348 | $argsSemiColon[] = array('variadic'=>true); |
| 1349 | - }else{ |
|
| 1349 | + }else { |
|
| 1350 | 1350 | $argsComma[] = array('variadic'=>true); |
| 1351 | 1351 | } |
| 1352 | 1352 | break; |
| 1353 | 1353 | } |
| 1354 | - $arg = $this->MatchFuncs( array('parseEntitiesVariable','parseEntitiesLiteral','parseEntitiesKeyword') ); |
|
| 1354 | + $arg = $this->MatchFuncs(array('parseEntitiesVariable', 'parseEntitiesLiteral', 'parseEntitiesKeyword')); |
|
| 1355 | 1355 | } |
| 1356 | 1356 | |
| 1357 | - if( !$arg ){ |
|
| 1357 | + if (!$arg) { |
|
| 1358 | 1358 | break; |
| 1359 | 1359 | } |
| 1360 | 1360 | |
| 1361 | 1361 | |
| 1362 | 1362 | $nameLoop = null; |
| 1363 | - if( $arg instanceof Less_Tree_Expression ){ |
|
| 1363 | + if ($arg instanceof Less_Tree_Expression) { |
|
| 1364 | 1364 | $arg->throwAwayComments(); |
| 1365 | 1365 | } |
| 1366 | 1366 | $value = $arg; |
| 1367 | 1367 | $val = null; |
| 1368 | 1368 | |
| 1369 | - if( $isCall ){ |
|
| 1369 | + if ($isCall) { |
|
| 1370 | 1370 | // Variable |
| 1371 | - if( property_exists($arg,'value') && count($arg->value) == 1 ){ |
|
| 1371 | + if (property_exists($arg, 'value') && count($arg->value)==1) { |
|
| 1372 | 1372 | $val = $arg->value[0]; |
| 1373 | 1373 | } |
| 1374 | - } else { |
|
| 1374 | + }else { |
|
| 1375 | 1375 | $val = $arg; |
| 1376 | 1376 | } |
| 1377 | 1377 | |
| 1378 | 1378 | |
| 1379 | - if( $val instanceof Less_Tree_Variable ){ |
|
| 1379 | + if ($val instanceof Less_Tree_Variable) { |
|
| 1380 | 1380 | |
| 1381 | - if( $this->MatchChar(':') ){ |
|
| 1382 | - if( $expressions ){ |
|
| 1383 | - if( $isSemiColonSeperated ){ |
|
| 1381 | + if ($this->MatchChar(':')) { |
|
| 1382 | + if ($expressions) { |
|
| 1383 | + if ($isSemiColonSeperated) { |
|
| 1384 | 1384 | $this->Error('Cannot mix ; and , as delimiter types'); |
| 1385 | 1385 | } |
| 1386 | 1386 | $expressionContainsNamed = true; |
@@ -1390,17 +1390,17 @@ discard block |
||
| 1390 | 1390 | // However if we do want to add it, there is nothing blocking it, just don't error |
| 1391 | 1391 | // and remove isCall dependency below |
| 1392 | 1392 | $value = null; |
| 1393 | - if( $isCall ){ |
|
| 1393 | + if ($isCall) { |
|
| 1394 | 1394 | $value = $this->parseDetachedRuleset(); |
| 1395 | 1395 | } |
| 1396 | - if( !$value ){ |
|
| 1396 | + if (!$value) { |
|
| 1397 | 1397 | $value = $this->parseExpression(); |
| 1398 | 1398 | } |
| 1399 | 1399 | |
| 1400 | - if( !$value ){ |
|
| 1401 | - if( $isCall ){ |
|
| 1400 | + if (!$value) { |
|
| 1401 | + if ($isCall) { |
|
| 1402 | 1402 | $this->Error('could not understand value for named argument'); |
| 1403 | - } else { |
|
| 1403 | + }else { |
|
| 1404 | 1404 | $this->restore(); |
| 1405 | 1405 | $returner['args'] = array(); |
| 1406 | 1406 | return $returner; |
@@ -1408,45 +1408,45 @@ discard block |
||
| 1408 | 1408 | } |
| 1409 | 1409 | |
| 1410 | 1410 | $nameLoop = ($name = $val->name); |
| 1411 | - }elseif( !$isCall && $this->MatchReg('/\\G\.{3}/') ){ |
|
| 1411 | + }elseif (!$isCall && $this->MatchReg('/\\G\.{3}/')) { |
|
| 1412 | 1412 | $returner['variadic'] = true; |
| 1413 | - if( $this->MatchChar(";") && !$isSemiColonSeperated ){ |
|
| 1413 | + if ($this->MatchChar(";") && !$isSemiColonSeperated) { |
|
| 1414 | 1414 | $isSemiColonSeperated = true; |
| 1415 | 1415 | } |
| 1416 | - if( $isSemiColonSeperated ){ |
|
| 1416 | + if ($isSemiColonSeperated) { |
|
| 1417 | 1417 | $argsSemiColon[] = array('name'=> $arg->name, 'variadic' => true); |
| 1418 | - }else{ |
|
| 1418 | + }else { |
|
| 1419 | 1419 | $argsComma[] = array('name'=> $arg->name, 'variadic' => true); |
| 1420 | 1420 | } |
| 1421 | 1421 | break; |
| 1422 | - }elseif( !$isCall ){ |
|
| 1422 | + }elseif (!$isCall) { |
|
| 1423 | 1423 | $name = $nameLoop = $val->name; |
| 1424 | 1424 | $value = null; |
| 1425 | 1425 | } |
| 1426 | 1426 | } |
| 1427 | 1427 | |
| 1428 | - if( $value ){ |
|
| 1428 | + if ($value) { |
|
| 1429 | 1429 | $expressions[] = $value; |
| 1430 | 1430 | } |
| 1431 | 1431 | |
| 1432 | - $argsComma[] = array('name'=>$nameLoop, 'value'=>$value ); |
|
| 1432 | + $argsComma[] = array('name'=>$nameLoop, 'value'=>$value); |
|
| 1433 | 1433 | |
| 1434 | - if( $this->MatchChar(',') ){ |
|
| 1434 | + if ($this->MatchChar(',')) { |
|
| 1435 | 1435 | continue; |
| 1436 | 1436 | } |
| 1437 | 1437 | |
| 1438 | - if( $this->MatchChar(';') || $isSemiColonSeperated ){ |
|
| 1438 | + if ($this->MatchChar(';') || $isSemiColonSeperated) { |
|
| 1439 | 1439 | |
| 1440 | - if( $expressionContainsNamed ){ |
|
| 1440 | + if ($expressionContainsNamed) { |
|
| 1441 | 1441 | $this->Error('Cannot mix ; and , as delimiter types'); |
| 1442 | 1442 | } |
| 1443 | 1443 | |
| 1444 | 1444 | $isSemiColonSeperated = true; |
| 1445 | 1445 | |
| 1446 | - if( count($expressions) > 1 ){ |
|
| 1446 | + if (count($expressions)>1) { |
|
| 1447 | 1447 | $value = $this->NewObj1('Less_Tree_Value', $expressions); |
| 1448 | 1448 | } |
| 1449 | - $argsSemiColon[] = array('name'=>$name, 'value'=>$value ); |
|
| 1449 | + $argsSemiColon[] = array('name'=>$name, 'value'=>$value); |
|
| 1450 | 1450 | |
| 1451 | 1451 | $name = null; |
| 1452 | 1452 | $expressions = array(); |
@@ -1480,21 +1480,21 @@ discard block |
||
| 1480 | 1480 | // Once we've got our params list, and a closing `)`, we parse |
| 1481 | 1481 | // the `{...}` block. |
| 1482 | 1482 | // |
| 1483 | - private function parseMixinDefinition(){ |
|
| 1483 | + private function parseMixinDefinition() { |
|
| 1484 | 1484 | $cond = null; |
| 1485 | 1485 | |
| 1486 | 1486 | $char = $this->input[$this->pos]; |
| 1487 | - if( ($char !== '.' && $char !== '#') || ($char === '{' && $this->PeekReg('/\\G[^{]*\}/')) ){ |
|
| 1487 | + if (($char!=='.' && $char!=='#') || ($char==='{' && $this->PeekReg('/\\G[^{]*\}/'))) { |
|
| 1488 | 1488 | return; |
| 1489 | 1489 | } |
| 1490 | 1490 | |
| 1491 | 1491 | $this->save(); |
| 1492 | 1492 | |
| 1493 | 1493 | $match = $this->MatchReg('/\\G([#.](?:[\w-]|\\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+)\s*\(/'); |
| 1494 | - if( $match ){ |
|
| 1494 | + if ($match) { |
|
| 1495 | 1495 | $name = $match[1]; |
| 1496 | 1496 | |
| 1497 | - $argInfo = $this->parseMixinArgs( false ); |
|
| 1497 | + $argInfo = $this->parseMixinArgs(false); |
|
| 1498 | 1498 | $params = $argInfo['args']; |
| 1499 | 1499 | $variadic = $argInfo['variadic']; |
| 1500 | 1500 | |
@@ -1504,7 +1504,7 @@ discard block |
||
| 1504 | 1504 | // also |
| 1505 | 1505 | // .mixincall(@a: {rule: set;}); |
| 1506 | 1506 | // so we have to be nice and restore |
| 1507 | - if( !$this->MatchChar(')') ){ |
|
| 1507 | + if (!$this->MatchChar(')')) { |
|
| 1508 | 1508 | $this->furthest = $this->pos; |
| 1509 | 1509 | $this->restore(); |
| 1510 | 1510 | return; |
@@ -1519,13 +1519,13 @@ discard block |
||
| 1519 | 1519 | |
| 1520 | 1520 | $ruleset = $this->parseBlock(); |
| 1521 | 1521 | |
| 1522 | - if( is_array($ruleset) ){ |
|
| 1522 | + if (is_array($ruleset)) { |
|
| 1523 | 1523 | $this->forget(); |
| 1524 | - return $this->NewObj5('Less_Tree_Mixin_Definition', array( $name, $params, $ruleset, $cond, $variadic)); |
|
| 1524 | + return $this->NewObj5('Less_Tree_Mixin_Definition', array($name, $params, $ruleset, $cond, $variadic)); |
|
| 1525 | 1525 | } |
| 1526 | 1526 | |
| 1527 | 1527 | $this->restore(); |
| 1528 | - }else{ |
|
| 1528 | + }else { |
|
| 1529 | 1529 | $this->forget(); |
| 1530 | 1530 | } |
| 1531 | 1531 | } |
@@ -1534,9 +1534,9 @@ discard block |
||
| 1534 | 1534 | // Entities are the smallest recognized token, |
| 1535 | 1535 | // and can be found inside a rule's value. |
| 1536 | 1536 | // |
| 1537 | - private function parseEntity(){ |
|
| 1537 | + private function parseEntity() { |
|
| 1538 | 1538 | |
| 1539 | - return $this->MatchFuncs( array('parseEntitiesLiteral','parseEntitiesVariable','parseEntitiesUrl','parseEntitiesCall','parseEntitiesKeyword','parseEntitiesJavascript','parseComment') ); |
|
| 1539 | + return $this->MatchFuncs(array('parseEntitiesLiteral', 'parseEntitiesVariable', 'parseEntitiesUrl', 'parseEntitiesCall', 'parseEntitiesKeyword', 'parseEntitiesJavascript', 'parseComment')); |
|
| 1540 | 1540 | } |
| 1541 | 1541 | |
| 1542 | 1542 | // |
@@ -1544,7 +1544,7 @@ discard block |
||
| 1544 | 1544 | // because the `block` rule will be expecting it, but we still need to make sure |
| 1545 | 1545 | // it's there, if ';' was ommitted. |
| 1546 | 1546 | // |
| 1547 | - private function parseEnd(){ |
|
| 1547 | + private function parseEnd() { |
|
| 1548 | 1548 | return $this->MatchChar(';') || $this->PeekChar('}'); |
| 1549 | 1549 | } |
| 1550 | 1550 | |
@@ -1553,24 +1553,24 @@ discard block |
||
| 1553 | 1553 | // |
| 1554 | 1554 | // alpha(opacity=88) |
| 1555 | 1555 | // |
| 1556 | - private function parseAlpha(){ |
|
| 1556 | + private function parseAlpha() { |
|
| 1557 | 1557 | |
| 1558 | - if ( ! $this->MatchReg('/\\G\(opacity=/i')) { |
|
| 1558 | + if (!$this->MatchReg('/\\G\(opacity=/i')) { |
|
| 1559 | 1559 | return; |
| 1560 | 1560 | } |
| 1561 | 1561 | |
| 1562 | 1562 | $value = $this->MatchReg('/\\G[0-9]+/'); |
| 1563 | - if( $value ){ |
|
| 1563 | + if ($value) { |
|
| 1564 | 1564 | $value = $value[0]; |
| 1565 | - }else{ |
|
| 1565 | + }else { |
|
| 1566 | 1566 | $value = $this->parseEntitiesVariable(); |
| 1567 | - if( !$value ){ |
|
| 1567 | + if (!$value) { |
|
| 1568 | 1568 | return; |
| 1569 | 1569 | } |
| 1570 | 1570 | } |
| 1571 | 1571 | |
| 1572 | 1572 | $this->expectChar(')'); |
| 1573 | - return $this->NewObj1('Less_Tree_Alpha',$value); |
|
| 1573 | + return $this->NewObj1('Less_Tree_Alpha', $value); |
|
| 1574 | 1574 | } |
| 1575 | 1575 | |
| 1576 | 1576 | |
@@ -1586,29 +1586,29 @@ discard block |
||
| 1586 | 1586 | // they are made out of a `Combinator` (see combinator rule), |
| 1587 | 1587 | // and an element name, such as a tag a class, or `*`. |
| 1588 | 1588 | // |
| 1589 | - private function parseElement(){ |
|
| 1589 | + private function parseElement() { |
|
| 1590 | 1590 | $c = $this->parseCombinator(); |
| 1591 | 1591 | $index = $this->pos; |
| 1592 | 1592 | |
| 1593 | - $e = $this->match( array('/\\G(?:\d+\.\d+|\d+)%/', '/\\G(?:[.#]?|:*)(?:[\w-]|[^\x00-\x9f]|\\\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/', |
|
| 1594 | - '#*', '#&', 'parseAttribute', '/\\G\([^()@]+\)/', '/\\G[\.#](?=@)/', 'parseEntitiesVariableCurly') ); |
|
| 1593 | + $e = $this->match(array('/\\G(?:\d+\.\d+|\d+)%/', '/\\G(?:[.#]?|:*)(?:[\w-]|[^\x00-\x9f]|\\\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/', |
|
| 1594 | + '#*', '#&', 'parseAttribute', '/\\G\([^()@]+\)/', '/\\G[\.#](?=@)/', 'parseEntitiesVariableCurly')); |
|
| 1595 | 1595 | |
| 1596 | - if( is_null($e) ){ |
|
| 1596 | + if (is_null($e)) { |
|
| 1597 | 1597 | $this->save(); |
| 1598 | - if( $this->MatchChar('(') ){ |
|
| 1599 | - if( ($v = $this->parseSelector()) && $this->MatchChar(')') ){ |
|
| 1600 | - $e = $this->NewObj1('Less_Tree_Paren',$v); |
|
| 1598 | + if ($this->MatchChar('(')) { |
|
| 1599 | + if (($v = $this->parseSelector()) && $this->MatchChar(')')) { |
|
| 1600 | + $e = $this->NewObj1('Less_Tree_Paren', $v); |
|
| 1601 | 1601 | $this->forget(); |
| 1602 | - }else{ |
|
| 1602 | + }else { |
|
| 1603 | 1603 | $this->restore(); |
| 1604 | 1604 | } |
| 1605 | - }else{ |
|
| 1605 | + }else { |
|
| 1606 | 1606 | $this->forget(); |
| 1607 | 1607 | } |
| 1608 | 1608 | } |
| 1609 | 1609 | |
| 1610 | - if( !is_null($e) ){ |
|
| 1611 | - return $this->NewObj4('Less_Tree_Element',array( $c, $e, $index, $this->env->currentFileInfo)); |
|
| 1610 | + if (!is_null($e)) { |
|
| 1611 | + return $this->NewObj4('Less_Tree_Element', array($c, $e, $index, $this->env->currentFileInfo)); |
|
| 1612 | 1612 | } |
| 1613 | 1613 | } |
| 1614 | 1614 | |
@@ -1620,13 +1620,13 @@ discard block |
||
| 1620 | 1620 | // as it's an empty space. We have to check the previous character |
| 1621 | 1621 | // in the input, to see if it's a ` ` character. |
| 1622 | 1622 | // |
| 1623 | - private function parseCombinator(){ |
|
| 1624 | - if( $this->pos < $this->input_len ){ |
|
| 1623 | + private function parseCombinator() { |
|
| 1624 | + if ($this->pos<$this->input_len) { |
|
| 1625 | 1625 | $c = $this->input[$this->pos]; |
| 1626 | - if ($c === '>' || $c === '+' || $c === '~' || $c === '|' || $c === '^' ){ |
|
| 1626 | + if ($c==='>' || $c==='+' || $c==='~' || $c==='|' || $c==='^') { |
|
| 1627 | 1627 | |
| 1628 | 1628 | $this->pos++; |
| 1629 | - if( $this->input[$this->pos] === '^' ){ |
|
| 1629 | + if ($this->input[$this->pos]==='^') { |
|
| 1630 | 1630 | $c = '^^'; |
| 1631 | 1631 | $this->pos++; |
| 1632 | 1632 | } |
@@ -1636,7 +1636,7 @@ discard block |
||
| 1636 | 1636 | return $c; |
| 1637 | 1637 | } |
| 1638 | 1638 | |
| 1639 | - if( $this->pos > 0 && $this->isWhitespace(-1) ){ |
|
| 1639 | + if ($this->pos>0 && $this->isWhitespace(-1)) { |
|
| 1640 | 1640 | return ' '; |
| 1641 | 1641 | } |
| 1642 | 1642 | } |
@@ -1646,7 +1646,7 @@ discard block |
||
| 1646 | 1646 | // A CSS selector (see selector below) |
| 1647 | 1647 | // with less extensions e.g. the ability to extend and guard |
| 1648 | 1648 | // |
| 1649 | - private function parseLessSelector(){ |
|
| 1649 | + private function parseLessSelector() { |
|
| 1650 | 1650 | return $this->parseSelector(true); |
| 1651 | 1651 | } |
| 1652 | 1652 | |
@@ -1658,7 +1658,7 @@ discard block |
||
| 1658 | 1658 | // |
| 1659 | 1659 | // Selectors are made out of one or more Elements, see above. |
| 1660 | 1660 | // |
| 1661 | - private function parseSelector( $isLess = false ){ |
|
| 1661 | + private function parseSelector($isLess = false) { |
|
| 1662 | 1662 | $elements = array(); |
| 1663 | 1663 | $extendList = array(); |
| 1664 | 1664 | $condition = null; |
@@ -1668,127 +1668,127 @@ discard block |
||
| 1668 | 1668 | $c = null; |
| 1669 | 1669 | $index = $this->pos; |
| 1670 | 1670 | |
| 1671 | - while( ($isLess && ($extend = $this->parseExtend())) || ($isLess && ($when = $this->MatchReg('/\\Gwhen/') )) || ($e = $this->parseElement()) ){ |
|
| 1672 | - if( $when ){ |
|
| 1671 | + while (($isLess && ($extend = $this->parseExtend())) || ($isLess && ($when = $this->MatchReg('/\\Gwhen/'))) || ($e = $this->parseElement())) { |
|
| 1672 | + if ($when) { |
|
| 1673 | 1673 | $condition = $this->expect('parseConditions', 'expected condition'); |
| 1674 | - }elseif( $condition ){ |
|
| 1674 | + }elseif ($condition) { |
|
| 1675 | 1675 | //error("CSS guard can only be used at the end of selector"); |
| 1676 | - }elseif( $extend ){ |
|
| 1677 | - $extendList = array_merge($extendList,$extend); |
|
| 1678 | - }else{ |
|
| 1676 | + }elseif ($extend) { |
|
| 1677 | + $extendList = array_merge($extendList, $extend); |
|
| 1678 | + }else { |
|
| 1679 | 1679 | //if( count($extendList) ){ |
| 1680 | 1680 | //error("Extend can only be used at the end of selector"); |
| 1681 | 1681 | //} |
| 1682 | - if( $this->pos < $this->input_len ){ |
|
| 1683 | - $c = $this->input[ $this->pos ]; |
|
| 1682 | + if ($this->pos<$this->input_len) { |
|
| 1683 | + $c = $this->input[$this->pos]; |
|
| 1684 | 1684 | } |
| 1685 | 1685 | $elements[] = $e; |
| 1686 | 1686 | $e = null; |
| 1687 | 1687 | } |
| 1688 | 1688 | |
| 1689 | - if( $c === '{' || $c === '}' || $c === ';' || $c === ',' || $c === ')') { break; } |
|
| 1689 | + if ($c==='{' || $c==='}' || $c===';' || $c===',' || $c===')') { break; } |
|
| 1690 | 1690 | } |
| 1691 | 1691 | |
| 1692 | - if( $elements ){ |
|
| 1693 | - return $this->NewObj5('Less_Tree_Selector',array($elements, $extendList, $condition, $index, $this->env->currentFileInfo)); |
|
| 1692 | + if ($elements) { |
|
| 1693 | + return $this->NewObj5('Less_Tree_Selector', array($elements, $extendList, $condition, $index, $this->env->currentFileInfo)); |
|
| 1694 | 1694 | } |
| 1695 | - if( $extendList ) { |
|
| 1695 | + if ($extendList) { |
|
| 1696 | 1696 | $this->Error('Extend must be used to extend a selector, it cannot be used on its own'); |
| 1697 | 1697 | } |
| 1698 | 1698 | } |
| 1699 | 1699 | |
| 1700 | - private function parseTag(){ |
|
| 1701 | - return ( $tag = $this->MatchReg('/\\G[A-Za-z][A-Za-z-]*[0-9]?/') ) ? $tag : $this->MatchChar('*'); |
|
| 1700 | + private function parseTag() { |
|
| 1701 | + return ($tag = $this->MatchReg('/\\G[A-Za-z][A-Za-z-]*[0-9]?/')) ? $tag : $this->MatchChar('*'); |
|
| 1702 | 1702 | } |
| 1703 | 1703 | |
| 1704 | - private function parseAttribute(){ |
|
| 1704 | + private function parseAttribute() { |
|
| 1705 | 1705 | |
| 1706 | 1706 | $val = null; |
| 1707 | 1707 | |
| 1708 | - if( !$this->MatchChar('[') ){ |
|
| 1708 | + if (!$this->MatchChar('[')) { |
|
| 1709 | 1709 | return; |
| 1710 | 1710 | } |
| 1711 | 1711 | |
| 1712 | 1712 | $key = $this->parseEntitiesVariableCurly(); |
| 1713 | - if( !$key ){ |
|
| 1713 | + if (!$key) { |
|
| 1714 | 1714 | $key = $this->expect('/\\G(?:[_A-Za-z0-9-\*]*\|)?(?:[_A-Za-z0-9-]|\\\\.)+/'); |
| 1715 | 1715 | } |
| 1716 | 1716 | |
| 1717 | 1717 | $op = $this->MatchReg('/\\G[|~*$^]?=/'); |
| 1718 | - if( $op ){ |
|
| 1719 | - $val = $this->match( array('parseEntitiesQuoted','/\\G[0-9]+%/','/\\G[\w-]+/','parseEntitiesVariableCurly') ); |
|
| 1718 | + if ($op) { |
|
| 1719 | + $val = $this->match(array('parseEntitiesQuoted', '/\\G[0-9]+%/', '/\\G[\w-]+/', 'parseEntitiesVariableCurly')); |
|
| 1720 | 1720 | } |
| 1721 | 1721 | |
| 1722 | 1722 | $this->expectChar(']'); |
| 1723 | 1723 | |
| 1724 | - return $this->NewObj3('Less_Tree_Attribute',array( $key, $op[0], $val)); |
|
| 1724 | + return $this->NewObj3('Less_Tree_Attribute', array($key, $op[0], $val)); |
|
| 1725 | 1725 | } |
| 1726 | 1726 | |
| 1727 | 1727 | // |
| 1728 | 1728 | // The `block` rule is used by `ruleset` and `mixin.definition`. |
| 1729 | 1729 | // It's a wrapper around the `primary` rule, with added `{}`. |
| 1730 | 1730 | // |
| 1731 | - private function parseBlock(){ |
|
| 1732 | - if( $this->MatchChar('{') ){ |
|
| 1731 | + private function parseBlock() { |
|
| 1732 | + if ($this->MatchChar('{')) { |
|
| 1733 | 1733 | $content = $this->parsePrimary(); |
| 1734 | - if( $this->MatchChar('}') ){ |
|
| 1734 | + if ($this->MatchChar('}')) { |
|
| 1735 | 1735 | return $content; |
| 1736 | 1736 | } |
| 1737 | 1737 | } |
| 1738 | 1738 | } |
| 1739 | 1739 | |
| 1740 | - private function parseBlockRuleset(){ |
|
| 1740 | + private function parseBlockRuleset() { |
|
| 1741 | 1741 | $block = $this->parseBlock(); |
| 1742 | 1742 | |
| 1743 | - if( $block ){ |
|
| 1744 | - $block = $this->NewObj2('Less_Tree_Ruleset',array( null, $block)); |
|
| 1743 | + if ($block) { |
|
| 1744 | + $block = $this->NewObj2('Less_Tree_Ruleset', array(null, $block)); |
|
| 1745 | 1745 | } |
| 1746 | 1746 | |
| 1747 | 1747 | return $block; |
| 1748 | 1748 | } |
| 1749 | 1749 | |
| 1750 | - private function parseDetachedRuleset(){ |
|
| 1750 | + private function parseDetachedRuleset() { |
|
| 1751 | 1751 | $blockRuleset = $this->parseBlockRuleset(); |
| 1752 | - if( $blockRuleset ){ |
|
| 1753 | - return $this->NewObj1('Less_Tree_DetachedRuleset',$blockRuleset); |
|
| 1752 | + if ($blockRuleset) { |
|
| 1753 | + return $this->NewObj1('Less_Tree_DetachedRuleset', $blockRuleset); |
|
| 1754 | 1754 | } |
| 1755 | 1755 | } |
| 1756 | 1756 | |
| 1757 | 1757 | // |
| 1758 | 1758 | // div, .class, body > p {...} |
| 1759 | 1759 | // |
| 1760 | - private function parseRuleset(){ |
|
| 1760 | + private function parseRuleset() { |
|
| 1761 | 1761 | $selectors = array(); |
| 1762 | 1762 | |
| 1763 | 1763 | $this->save(); |
| 1764 | 1764 | |
| 1765 | - while( true ){ |
|
| 1765 | + while (true) { |
|
| 1766 | 1766 | $s = $this->parseLessSelector(); |
| 1767 | - if( !$s ){ |
|
| 1767 | + if (!$s) { |
|
| 1768 | 1768 | break; |
| 1769 | 1769 | } |
| 1770 | 1770 | $selectors[] = $s; |
| 1771 | 1771 | $this->parseComments(); |
| 1772 | 1772 | |
| 1773 | - if( $s->condition && count($selectors) > 1 ){ |
|
| 1773 | + if ($s->condition && count($selectors)>1) { |
|
| 1774 | 1774 | $this->Error('Guards are only currently allowed on a single selector.'); |
| 1775 | 1775 | } |
| 1776 | 1776 | |
| 1777 | - if( !$this->MatchChar(',') ){ |
|
| 1777 | + if (!$this->MatchChar(',')) { |
|
| 1778 | 1778 | break; |
| 1779 | 1779 | } |
| 1780 | - if( $s->condition ){ |
|
| 1780 | + if ($s->condition) { |
|
| 1781 | 1781 | $this->Error('Guards are only currently allowed on a single selector.'); |
| 1782 | 1782 | } |
| 1783 | 1783 | $this->parseComments(); |
| 1784 | 1784 | } |
| 1785 | 1785 | |
| 1786 | 1786 | |
| 1787 | - if( $selectors ){ |
|
| 1787 | + if ($selectors) { |
|
| 1788 | 1788 | $rules = $this->parseBlock(); |
| 1789 | - if( is_array($rules) ){ |
|
| 1789 | + if (is_array($rules)) { |
|
| 1790 | 1790 | $this->forget(); |
| 1791 | - return $this->NewObj2('Less_Tree_Ruleset',array( $selectors, $rules)); //Less_Environment::$strictImports |
|
| 1791 | + return $this->NewObj2('Less_Tree_Ruleset', array($selectors, $rules)); //Less_Environment::$strictImports |
|
| 1792 | 1792 | } |
| 1793 | 1793 | } |
| 1794 | 1794 | |
@@ -1802,7 +1802,7 @@ discard block |
||
| 1802 | 1802 | * ex: width:100px; |
| 1803 | 1803 | * |
| 1804 | 1804 | */ |
| 1805 | - private function parseNameValue(){ |
|
| 1805 | + private function parseNameValue() { |
|
| 1806 | 1806 | |
| 1807 | 1807 | $index = $this->pos; |
| 1808 | 1808 | $this->save(); |
@@ -1810,55 +1810,55 @@ discard block |
||
| 1810 | 1810 | |
| 1811 | 1811 | //$match = $this->MatchReg('/\\G([a-zA-Z\-]+)\s*:\s*((?:\'")?[a-zA-Z0-9\-% \.,!]+?(?:\'")?)\s*([;}])/'); |
| 1812 | 1812 | $match = $this->MatchReg('/\\G([a-zA-Z\-]+)\s*:\s*([\'"]?[#a-zA-Z0-9\-%\.,]+?[\'"]?) *(! *important)?\s*([;}])/'); |
| 1813 | - if( $match ){ |
|
| 1813 | + if ($match) { |
|
| 1814 | 1814 | |
| 1815 | - if( $match[4] == '}' ){ |
|
| 1816 | - $this->pos = $index + strlen($match[0])-1; |
|
| 1815 | + if ($match[4]=='}') { |
|
| 1816 | + $this->pos = $index+strlen($match[0])-1; |
|
| 1817 | 1817 | } |
| 1818 | 1818 | |
| 1819 | - if( $match[3] ){ |
|
| 1819 | + if ($match[3]) { |
|
| 1820 | 1820 | $match[2] .= ' !important'; |
| 1821 | 1821 | } |
| 1822 | 1822 | |
| 1823 | - return $this->NewObj4('Less_Tree_NameValue',array( $match[1], $match[2], $index, $this->env->currentFileInfo)); |
|
| 1823 | + return $this->NewObj4('Less_Tree_NameValue', array($match[1], $match[2], $index, $this->env->currentFileInfo)); |
|
| 1824 | 1824 | } |
| 1825 | 1825 | |
| 1826 | 1826 | $this->restore(); |
| 1827 | 1827 | } |
| 1828 | 1828 | |
| 1829 | 1829 | |
| 1830 | - private function parseRule( $tryAnonymous = null ){ |
|
| 1830 | + private function parseRule($tryAnonymous = null) { |
|
| 1831 | 1831 | |
| 1832 | 1832 | $merge = false; |
| 1833 | 1833 | $startOfRule = $this->pos; |
| 1834 | 1834 | |
| 1835 | 1835 | $c = $this->input[$this->pos]; |
| 1836 | - if( $c === '.' || $c === '#' || $c === '&' ){ |
|
| 1836 | + if ($c==='.' || $c==='#' || $c==='&') { |
|
| 1837 | 1837 | return; |
| 1838 | 1838 | } |
| 1839 | 1839 | |
| 1840 | 1840 | $this->save(); |
| 1841 | - $name = $this->MatchFuncs( array('parseVariable','parseRuleProperty')); |
|
| 1841 | + $name = $this->MatchFuncs(array('parseVariable', 'parseRuleProperty')); |
|
| 1842 | 1842 | |
| 1843 | - if( $name ){ |
|
| 1843 | + if ($name) { |
|
| 1844 | 1844 | |
| 1845 | 1845 | $isVariable = is_string($name); |
| 1846 | 1846 | |
| 1847 | 1847 | $value = null; |
| 1848 | - if( $isVariable ){ |
|
| 1848 | + if ($isVariable) { |
|
| 1849 | 1849 | $value = $this->parseDetachedRuleset(); |
| 1850 | 1850 | } |
| 1851 | 1851 | |
| 1852 | 1852 | $important = null; |
| 1853 | - if( !$value ){ |
|
| 1853 | + if (!$value) { |
|
| 1854 | 1854 | |
| 1855 | 1855 | // prefer to try to parse first if its a variable or we are compressing |
| 1856 | 1856 | // but always fallback on the other one |
| 1857 | 1857 | //if( !$tryAnonymous && is_string($name) && $name[0] === '@' ){ |
| 1858 | - if( !$tryAnonymous && (Less_Parser::$options['compress'] || $isVariable) ){ |
|
| 1859 | - $value = $this->MatchFuncs( array('parseValue','parseAnonymousValue')); |
|
| 1860 | - }else{ |
|
| 1861 | - $value = $this->MatchFuncs( array('parseAnonymousValue','parseValue')); |
|
| 1858 | + if (!$tryAnonymous && (Less_Parser::$options['compress'] || $isVariable)) { |
|
| 1859 | + $value = $this->MatchFuncs(array('parseValue', 'parseAnonymousValue')); |
|
| 1860 | + }else { |
|
| 1861 | + $value = $this->MatchFuncs(array('parseAnonymousValue', 'parseValue')); |
|
| 1862 | 1862 | } |
| 1863 | 1863 | |
| 1864 | 1864 | $important = $this->parseImportant(); |
@@ -1866,35 +1866,35 @@ discard block |
||
| 1866 | 1866 | // a name returned by this.ruleProperty() is always an array of the form: |
| 1867 | 1867 | // [string-1, ..., string-n, ""] or [string-1, ..., string-n, "+"] |
| 1868 | 1868 | // where each item is a tree.Keyword or tree.Variable |
| 1869 | - if( !$isVariable && is_array($name) ){ |
|
| 1869 | + if (!$isVariable && is_array($name)) { |
|
| 1870 | 1870 | $nm = array_pop($name); |
| 1871 | - if( $nm->value ){ |
|
| 1871 | + if ($nm->value) { |
|
| 1872 | 1872 | $merge = $nm->value; |
| 1873 | 1873 | } |
| 1874 | 1874 | } |
| 1875 | 1875 | } |
| 1876 | 1876 | |
| 1877 | 1877 | |
| 1878 | - if( $value && $this->parseEnd() ){ |
|
| 1878 | + if ($value && $this->parseEnd()) { |
|
| 1879 | 1879 | $this->forget(); |
| 1880 | - return $this->NewObj6('Less_Tree_Rule',array( $name, $value, $important, $merge, $startOfRule, $this->env->currentFileInfo)); |
|
| 1881 | - }else{ |
|
| 1880 | + return $this->NewObj6('Less_Tree_Rule', array($name, $value, $important, $merge, $startOfRule, $this->env->currentFileInfo)); |
|
| 1881 | + }else { |
|
| 1882 | 1882 | $this->furthest = $this->pos; |
| 1883 | 1883 | $this->restore(); |
| 1884 | - if( $value && !$tryAnonymous ){ |
|
| 1884 | + if ($value && !$tryAnonymous) { |
|
| 1885 | 1885 | return $this->parseRule(true); |
| 1886 | 1886 | } |
| 1887 | 1887 | } |
| 1888 | - }else{ |
|
| 1888 | + }else { |
|
| 1889 | 1889 | $this->forget(); |
| 1890 | 1890 | } |
| 1891 | 1891 | } |
| 1892 | 1892 | |
| 1893 | - function parseAnonymousValue(){ |
|
| 1893 | + function parseAnonymousValue() { |
|
| 1894 | 1894 | |
| 1895 | - if( preg_match('/\\G([^@+\/\'"*`(;{}-]*);/',$this->input, $match, 0, $this->pos) ){ |
|
| 1895 | + if (preg_match('/\\G([^@+\/\'"*`(;{}-]*);/', $this->input, $match, 0, $this->pos)) { |
|
| 1896 | 1896 | $this->pos += strlen($match[1]); |
| 1897 | - return $this->NewObj1('Less_Tree_Anonymous',$match[1]); |
|
| 1897 | + return $this->NewObj1('Less_Tree_Anonymous', $match[1]); |
|
| 1898 | 1898 | } |
| 1899 | 1899 | } |
| 1900 | 1900 | |
@@ -1908,25 +1908,25 @@ discard block |
||
| 1908 | 1908 | // file-system operation. The function used for importing is |
| 1909 | 1909 | // stored in `import`, which we pass to the Import constructor. |
| 1910 | 1910 | // |
| 1911 | - private function parseImport(){ |
|
| 1911 | + private function parseImport() { |
|
| 1912 | 1912 | |
| 1913 | 1913 | $this->save(); |
| 1914 | 1914 | |
| 1915 | 1915 | $dir = $this->MatchReg('/\\G@import?\s+/'); |
| 1916 | 1916 | |
| 1917 | - if( $dir ){ |
|
| 1917 | + if ($dir) { |
|
| 1918 | 1918 | $options = $this->parseImportOptions(); |
| 1919 | - $path = $this->MatchFuncs( array('parseEntitiesQuoted','parseEntitiesUrl')); |
|
| 1919 | + $path = $this->MatchFuncs(array('parseEntitiesQuoted', 'parseEntitiesUrl')); |
|
| 1920 | 1920 | |
| 1921 | - if( $path ){ |
|
| 1921 | + if ($path) { |
|
| 1922 | 1922 | $features = $this->parseMediaFeatures(); |
| 1923 | - if( $this->MatchChar(';') ){ |
|
| 1924 | - if( $features ){ |
|
| 1925 | - $features = $this->NewObj1('Less_Tree_Value',$features); |
|
| 1923 | + if ($this->MatchChar(';')) { |
|
| 1924 | + if ($features) { |
|
| 1925 | + $features = $this->NewObj1('Less_Tree_Value', $features); |
|
| 1926 | 1926 | } |
| 1927 | 1927 | |
| 1928 | 1928 | $this->forget(); |
| 1929 | - return $this->NewObj5('Less_Tree_Import',array( $path, $features, $options, $this->pos, $this->env->currentFileInfo)); |
|
| 1929 | + return $this->NewObj5('Less_Tree_Import', array($path, $features, $options, $this->pos, $this->env->currentFileInfo)); |
|
| 1930 | 1930 | } |
| 1931 | 1931 | } |
| 1932 | 1932 | } |
@@ -1934,19 +1934,19 @@ discard block |
||
| 1934 | 1934 | $this->restore(); |
| 1935 | 1935 | } |
| 1936 | 1936 | |
| 1937 | - private function parseImportOptions(){ |
|
| 1937 | + private function parseImportOptions() { |
|
| 1938 | 1938 | |
| 1939 | 1939 | $options = array(); |
| 1940 | 1940 | |
| 1941 | 1941 | // list of options, surrounded by parens |
| 1942 | - if( !$this->MatchChar('(') ){ |
|
| 1942 | + if (!$this->MatchChar('(')) { |
|
| 1943 | 1943 | return $options; |
| 1944 | 1944 | } |
| 1945 | - do{ |
|
| 1945 | + do { |
|
| 1946 | 1946 | $optionName = $this->parseImportOption(); |
| 1947 | - if( $optionName ){ |
|
| 1947 | + if ($optionName) { |
|
| 1948 | 1948 | $value = true; |
| 1949 | - switch( $optionName ){ |
|
| 1949 | + switch ($optionName) { |
|
| 1950 | 1950 | case "css": |
| 1951 | 1951 | $optionName = "less"; |
| 1952 | 1952 | $value = false; |
@@ -1957,16 +1957,16 @@ discard block |
||
| 1957 | 1957 | break; |
| 1958 | 1958 | } |
| 1959 | 1959 | $options[$optionName] = $value; |
| 1960 | - if( !$this->MatchChar(',') ){ break; } |
|
| 1960 | + if (!$this->MatchChar(',')) { break; } |
|
| 1961 | 1961 | } |
| 1962 | - }while( $optionName ); |
|
| 1962 | + } while ($optionName); |
|
| 1963 | 1963 | $this->expectChar(')'); |
| 1964 | 1964 | return $options; |
| 1965 | 1965 | } |
| 1966 | 1966 | |
| 1967 | - private function parseImportOption(){ |
|
| 1967 | + private function parseImportOption() { |
|
| 1968 | 1968 | $opt = $this->MatchReg('/\\G(less|css|multiple|once|inline|reference)/'); |
| 1969 | - if( $opt ){ |
|
| 1969 | + if ($opt) { |
|
| 1970 | 1970 | return $opt[1]; |
| 1971 | 1971 | } |
| 1972 | 1972 | } |
@@ -1974,43 +1974,43 @@ discard block |
||
| 1974 | 1974 | private function parseMediaFeature() { |
| 1975 | 1975 | $nodes = array(); |
| 1976 | 1976 | |
| 1977 | - do{ |
|
| 1978 | - $e = $this->MatchFuncs(array('parseEntitiesKeyword','parseEntitiesVariable')); |
|
| 1979 | - if( $e ){ |
|
| 1977 | + do { |
|
| 1978 | + $e = $this->MatchFuncs(array('parseEntitiesKeyword', 'parseEntitiesVariable')); |
|
| 1979 | + if ($e) { |
|
| 1980 | 1980 | $nodes[] = $e; |
| 1981 | 1981 | } elseif ($this->MatchChar('(')) { |
| 1982 | 1982 | $p = $this->parseProperty(); |
| 1983 | 1983 | $e = $this->parseValue(); |
| 1984 | 1984 | if ($this->MatchChar(')')) { |
| 1985 | 1985 | if ($p && $e) { |
| 1986 | - $r = $this->NewObj7('Less_Tree_Rule', array( $p, $e, null, null, $this->pos, $this->env->currentFileInfo, true)); |
|
| 1987 | - $nodes[] = $this->NewObj1('Less_Tree_Paren',$r); |
|
| 1986 | + $r = $this->NewObj7('Less_Tree_Rule', array($p, $e, null, null, $this->pos, $this->env->currentFileInfo, true)); |
|
| 1987 | + $nodes[] = $this->NewObj1('Less_Tree_Paren', $r); |
|
| 1988 | 1988 | } elseif ($e) { |
| 1989 | - $nodes[] = $this->NewObj1('Less_Tree_Paren',$e); |
|
| 1990 | - } else { |
|
| 1989 | + $nodes[] = $this->NewObj1('Less_Tree_Paren', $e); |
|
| 1990 | + }else { |
|
| 1991 | 1991 | return null; |
| 1992 | 1992 | } |
| 1993 | - } else |
|
| 1993 | + }else |
|
| 1994 | 1994 | return null; |
| 1995 | 1995 | } |
| 1996 | 1996 | } while ($e); |
| 1997 | 1997 | |
| 1998 | 1998 | if ($nodes) { |
| 1999 | - return $this->NewObj1('Less_Tree_Expression',$nodes); |
|
| 1999 | + return $this->NewObj1('Less_Tree_Expression', $nodes); |
|
| 2000 | 2000 | } |
| 2001 | 2001 | } |
| 2002 | 2002 | |
| 2003 | 2003 | private function parseMediaFeatures() { |
| 2004 | 2004 | $features = array(); |
| 2005 | 2005 | |
| 2006 | - do{ |
|
| 2006 | + do { |
|
| 2007 | 2007 | $e = $this->parseMediaFeature(); |
| 2008 | - if( $e ){ |
|
| 2008 | + if ($e) { |
|
| 2009 | 2009 | $features[] = $e; |
| 2010 | 2010 | if (!$this->MatchChar(',')) break; |
| 2011 | - }else{ |
|
| 2011 | + }else { |
|
| 2012 | 2012 | $e = $this->parseEntitiesVariable(); |
| 2013 | - if( $e ){ |
|
| 2013 | + if ($e) { |
|
| 2014 | 2014 | $features[] = $e; |
| 2015 | 2015 | if (!$this->MatchChar(',')) break; |
| 2016 | 2016 | } |
@@ -2021,12 +2021,12 @@ discard block |
||
| 2021 | 2021 | } |
| 2022 | 2022 | |
| 2023 | 2023 | private function parseMedia() { |
| 2024 | - if( $this->MatchReg('/\\G@media/') ){ |
|
| 2024 | + if ($this->MatchReg('/\\G@media/')) { |
|
| 2025 | 2025 | $features = $this->parseMediaFeatures(); |
| 2026 | 2026 | $rules = $this->parseBlock(); |
| 2027 | 2027 | |
| 2028 | - if( is_array($rules) ){ |
|
| 2029 | - return $this->NewObj4('Less_Tree_Media',array( $rules, $features, $this->pos, $this->env->currentFileInfo)); |
|
| 2028 | + if (is_array($rules)) { |
|
| 2029 | + return $this->NewObj4('Less_Tree_Media', array($rules, $features, $this->pos, $this->env->currentFileInfo)); |
|
| 2030 | 2030 | } |
| 2031 | 2031 | } |
| 2032 | 2032 | } |
@@ -2037,9 +2037,9 @@ discard block |
||
| 2037 | 2037 | // |
| 2038 | 2038 | // @charset "utf-8"; |
| 2039 | 2039 | // |
| 2040 | - private function parseDirective(){ |
|
| 2040 | + private function parseDirective() { |
|
| 2041 | 2041 | |
| 2042 | - if( !$this->PeekChar('@') ){ |
|
| 2042 | + if (!$this->PeekChar('@')) { |
|
| 2043 | 2043 | return; |
| 2044 | 2044 | } |
| 2045 | 2045 | |
@@ -2051,8 +2051,8 @@ discard block |
||
| 2051 | 2051 | $hasUnknown = false; |
| 2052 | 2052 | |
| 2053 | 2053 | |
| 2054 | - $value = $this->MatchFuncs(array('parseImport','parseMedia')); |
|
| 2055 | - if( $value ){ |
|
| 2054 | + $value = $this->MatchFuncs(array('parseImport', 'parseMedia')); |
|
| 2055 | + if ($value) { |
|
| 2056 | 2056 | return $value; |
| 2057 | 2057 | } |
| 2058 | 2058 | |
@@ -2060,18 +2060,18 @@ discard block |
||
| 2060 | 2060 | |
| 2061 | 2061 | $name = $this->MatchReg('/\\G@[a-z-]+/'); |
| 2062 | 2062 | |
| 2063 | - if( !$name ) return; |
|
| 2063 | + if (!$name) return; |
|
| 2064 | 2064 | $name = $name[0]; |
| 2065 | 2065 | |
| 2066 | 2066 | |
| 2067 | 2067 | $nonVendorSpecificName = $name; |
| 2068 | - $pos = strpos($name,'-', 2); |
|
| 2069 | - if( $name[1] == '-' && $pos > 0 ){ |
|
| 2070 | - $nonVendorSpecificName = "@" . substr($name, $pos + 1); |
|
| 2068 | + $pos = strpos($name, '-', 2); |
|
| 2069 | + if ($name[1]=='-' && $pos>0) { |
|
| 2070 | + $nonVendorSpecificName = "@".substr($name, $pos+1); |
|
| 2071 | 2071 | } |
| 2072 | 2072 | |
| 2073 | 2073 | |
| 2074 | - switch( $nonVendorSpecificName ){ |
|
| 2074 | + switch ($nonVendorSpecificName) { |
|
| 2075 | 2075 | /* |
| 2076 | 2076 | case "@font-face": |
| 2077 | 2077 | case "@viewport": |
@@ -2113,31 +2113,31 @@ discard block |
||
| 2113 | 2113 | break; |
| 2114 | 2114 | } |
| 2115 | 2115 | |
| 2116 | - if( $hasIdentifier ){ |
|
| 2116 | + if ($hasIdentifier) { |
|
| 2117 | 2117 | $value = $this->parseEntity(); |
| 2118 | - if( !$value ){ |
|
| 2119 | - $this->error("expected " . $name . " identifier"); |
|
| 2118 | + if (!$value) { |
|
| 2119 | + $this->error("expected ".$name." identifier"); |
|
| 2120 | 2120 | } |
| 2121 | - } else if( $hasExpression ){ |
|
| 2121 | + }else if ($hasExpression) { |
|
| 2122 | 2122 | $value = $this->parseExpression(); |
| 2123 | - if( !$value ){ |
|
| 2124 | - $this->error("expected " . $name. " expression"); |
|
| 2123 | + if (!$value) { |
|
| 2124 | + $this->error("expected ".$name." expression"); |
|
| 2125 | 2125 | } |
| 2126 | - } else if ($hasUnknown) { |
|
| 2126 | + }else if ($hasUnknown) { |
|
| 2127 | 2127 | |
| 2128 | 2128 | $value = $this->MatchReg('/\\G[^{;]+/'); |
| 2129 | - if( $value ){ |
|
| 2130 | - $value = $this->NewObj1('Less_Tree_Anonymous',trim($value[0])); |
|
| 2129 | + if ($value) { |
|
| 2130 | + $value = $this->NewObj1('Less_Tree_Anonymous', trim($value[0])); |
|
| 2131 | 2131 | } |
| 2132 | 2132 | } |
| 2133 | 2133 | |
| 2134 | - if( $hasBlock ){ |
|
| 2134 | + if ($hasBlock) { |
|
| 2135 | 2135 | $rules = $this->parseBlockRuleset(); |
| 2136 | 2136 | } |
| 2137 | 2137 | |
| 2138 | - if( $rules || (!$hasBlock && $value && $this->MatchChar(';'))) { |
|
| 2138 | + if ($rules || (!$hasBlock && $value && $this->MatchChar(';'))) { |
|
| 2139 | 2139 | $this->forget(); |
| 2140 | - return $this->NewObj5('Less_Tree_Directive',array($name, $value, $rules, $index, $this->env->currentFileInfo)); |
|
| 2140 | + return $this->NewObj5('Less_Tree_Directive', array($name, $value, $rules, $index, $this->env->currentFileInfo)); |
|
| 2141 | 2141 | } |
| 2142 | 2142 | |
| 2143 | 2143 | $this->restore(); |
@@ -2152,37 +2152,37 @@ discard block |
||
| 2152 | 2152 | // In a Rule, a Value represents everything after the `:`, |
| 2153 | 2153 | // and before the `;`. |
| 2154 | 2154 | // |
| 2155 | - private function parseValue(){ |
|
| 2155 | + private function parseValue() { |
|
| 2156 | 2156 | $expressions = array(); |
| 2157 | 2157 | |
| 2158 | - do{ |
|
| 2158 | + do { |
|
| 2159 | 2159 | $e = $this->parseExpression(); |
| 2160 | - if( $e ){ |
|
| 2160 | + if ($e) { |
|
| 2161 | 2161 | $expressions[] = $e; |
| 2162 | - if (! $this->MatchChar(',')) { |
|
| 2162 | + if (!$this->MatchChar(',')) { |
|
| 2163 | 2163 | break; |
| 2164 | 2164 | } |
| 2165 | 2165 | } |
| 2166 | - }while($e); |
|
| 2166 | + } while ($e); |
|
| 2167 | 2167 | |
| 2168 | - if( $expressions ){ |
|
| 2169 | - return $this->NewObj1('Less_Tree_Value',$expressions); |
|
| 2168 | + if ($expressions) { |
|
| 2169 | + return $this->NewObj1('Less_Tree_Value', $expressions); |
|
| 2170 | 2170 | } |
| 2171 | 2171 | } |
| 2172 | 2172 | |
| 2173 | - private function parseImportant (){ |
|
| 2174 | - if( $this->PeekChar('!') && $this->MatchReg('/\\G! *important/') ){ |
|
| 2173 | + private function parseImportant() { |
|
| 2174 | + if ($this->PeekChar('!') && $this->MatchReg('/\\G! *important/')) { |
|
| 2175 | 2175 | return ' !important'; |
| 2176 | 2176 | } |
| 2177 | 2177 | } |
| 2178 | 2178 | |
| 2179 | - private function parseSub (){ |
|
| 2179 | + private function parseSub() { |
|
| 2180 | 2180 | |
| 2181 | - if( $this->MatchChar('(') ){ |
|
| 2181 | + if ($this->MatchChar('(')) { |
|
| 2182 | 2182 | $a = $this->parseAddition(); |
| 2183 | - if( $a ){ |
|
| 2183 | + if ($a) { |
|
| 2184 | 2184 | $this->expectChar(')'); |
| 2185 | - return $this->NewObj2('Less_Tree_Expression',array( array($a), true) ); //instead of $e->parens = true so the value is cached |
|
| 2185 | + return $this->NewObj2('Less_Tree_Expression', array(array($a), true)); //instead of $e->parens = true so the value is cached |
|
| 2186 | 2186 | } |
| 2187 | 2187 | } |
| 2188 | 2188 | } |
@@ -2193,33 +2193,33 @@ discard block |
||
| 2193 | 2193 | * |
| 2194 | 2194 | * @return Less_Tree_Operation|null |
| 2195 | 2195 | */ |
| 2196 | - function parseMultiplication(){ |
|
| 2196 | + function parseMultiplication() { |
|
| 2197 | 2197 | |
| 2198 | 2198 | $return = $m = $this->parseOperand(); |
| 2199 | - if( $return ){ |
|
| 2200 | - while( true ){ |
|
| 2199 | + if ($return) { |
|
| 2200 | + while (true) { |
|
| 2201 | 2201 | |
| 2202 | 2202 | $isSpaced = $this->isWhitespace( -1 ); |
| 2203 | 2203 | |
| 2204 | - if( $this->PeekReg('/\\G\/[*\/]/') ){ |
|
| 2204 | + if ($this->PeekReg('/\\G\/[*\/]/')) { |
|
| 2205 | 2205 | break; |
| 2206 | 2206 | } |
| 2207 | 2207 | |
| 2208 | 2208 | $op = $this->MatchChar('/'); |
| 2209 | - if( !$op ){ |
|
| 2209 | + if (!$op) { |
|
| 2210 | 2210 | $op = $this->MatchChar('*'); |
| 2211 | - if( !$op ){ |
|
| 2211 | + if (!$op) { |
|
| 2212 | 2212 | break; |
| 2213 | 2213 | } |
| 2214 | 2214 | } |
| 2215 | 2215 | |
| 2216 | 2216 | $a = $this->parseOperand(); |
| 2217 | 2217 | |
| 2218 | - if(!$a) { break; } |
|
| 2218 | + if (!$a) { break; } |
|
| 2219 | 2219 | |
| 2220 | 2220 | $m->parensInOp = true; |
| 2221 | 2221 | $a->parensInOp = true; |
| 2222 | - $return = $this->NewObj3('Less_Tree_Operation',array( $op, array( $return, $a ), $isSpaced) ); |
|
| 2222 | + $return = $this->NewObj3('Less_Tree_Operation', array($op, array($return, $a), $isSpaced)); |
|
| 2223 | 2223 | } |
| 2224 | 2224 | } |
| 2225 | 2225 | return $return; |
@@ -2232,34 +2232,34 @@ discard block |
||
| 2232 | 2232 | * |
| 2233 | 2233 | * @return Less_Tree_Operation|null |
| 2234 | 2234 | */ |
| 2235 | - private function parseAddition (){ |
|
| 2235 | + private function parseAddition() { |
|
| 2236 | 2236 | |
| 2237 | 2237 | $return = $m = $this->parseMultiplication(); |
| 2238 | - if( $return ){ |
|
| 2239 | - while( true ){ |
|
| 2238 | + if ($return) { |
|
| 2239 | + while (true) { |
|
| 2240 | 2240 | |
| 2241 | 2241 | $isSpaced = $this->isWhitespace( -1 ); |
| 2242 | 2242 | |
| 2243 | 2243 | $op = $this->MatchReg('/\\G[-+]\s+/'); |
| 2244 | - if( $op ){ |
|
| 2244 | + if ($op) { |
|
| 2245 | 2245 | $op = $op[0]; |
| 2246 | - }else{ |
|
| 2247 | - if( !$isSpaced ){ |
|
| 2248 | - $op = $this->match(array('#+','#-')); |
|
| 2246 | + }else { |
|
| 2247 | + if (!$isSpaced) { |
|
| 2248 | + $op = $this->match(array('#+', '#-')); |
|
| 2249 | 2249 | } |
| 2250 | - if( !$op ){ |
|
| 2250 | + if (!$op) { |
|
| 2251 | 2251 | break; |
| 2252 | 2252 | } |
| 2253 | 2253 | } |
| 2254 | 2254 | |
| 2255 | 2255 | $a = $this->parseMultiplication(); |
| 2256 | - if( !$a ){ |
|
| 2256 | + if (!$a) { |
|
| 2257 | 2257 | break; |
| 2258 | 2258 | } |
| 2259 | 2259 | |
| 2260 | 2260 | $m->parensInOp = true; |
| 2261 | 2261 | $a->parensInOp = true; |
| 2262 | - $return = $this->NewObj3('Less_Tree_Operation',array($op, array($return, $a), $isSpaced)); |
|
| 2262 | + $return = $this->NewObj3('Less_Tree_Operation', array($op, array($return, $a), $isSpaced)); |
|
| 2263 | 2263 | } |
| 2264 | 2264 | } |
| 2265 | 2265 | |
@@ -2275,17 +2275,17 @@ discard block |
||
| 2275 | 2275 | private function parseConditions() { |
| 2276 | 2276 | $index = $this->pos; |
| 2277 | 2277 | $return = $a = $this->parseCondition(); |
| 2278 | - if( $a ){ |
|
| 2279 | - while( true ){ |
|
| 2280 | - if( !$this->PeekReg('/\\G,\s*(not\s*)?\(/') || !$this->MatchChar(',') ){ |
|
| 2278 | + if ($a) { |
|
| 2279 | + while (true) { |
|
| 2280 | + if (!$this->PeekReg('/\\G,\s*(not\s*)?\(/') || !$this->MatchChar(',')) { |
|
| 2281 | 2281 | break; |
| 2282 | 2282 | } |
| 2283 | 2283 | $b = $this->parseCondition(); |
| 2284 | - if( !$b ){ |
|
| 2284 | + if (!$b) { |
|
| 2285 | 2285 | break; |
| 2286 | 2286 | } |
| 2287 | 2287 | |
| 2288 | - $return = $this->NewObj4('Less_Tree_Condition',array('or', $return, $b, $index)); |
|
| 2288 | + $return = $this->NewObj4('Less_Tree_Condition', array('or', $return, $b, $index)); |
|
| 2289 | 2289 | } |
| 2290 | 2290 | return $return; |
| 2291 | 2291 | } |
@@ -2298,23 +2298,23 @@ discard block |
||
| 2298 | 2298 | |
| 2299 | 2299 | if ($this->MatchReg('/\\Gnot/')) $negate = true; |
| 2300 | 2300 | $this->expectChar('('); |
| 2301 | - $a = $this->MatchFuncs(array('parseAddition','parseEntitiesKeyword','parseEntitiesQuoted')); |
|
| 2301 | + $a = $this->MatchFuncs(array('parseAddition', 'parseEntitiesKeyword', 'parseEntitiesQuoted')); |
|
| 2302 | 2302 | |
| 2303 | - if( $a ){ |
|
| 2303 | + if ($a) { |
|
| 2304 | 2304 | $op = $this->MatchReg('/\\G(?:>=|<=|=<|[<=>])/'); |
| 2305 | - if( $op ){ |
|
| 2306 | - $b = $this->MatchFuncs(array('parseAddition','parseEntitiesKeyword','parseEntitiesQuoted')); |
|
| 2307 | - if( $b ){ |
|
| 2308 | - $c = $this->NewObj5('Less_Tree_Condition',array($op[0], $a, $b, $index, $negate)); |
|
| 2309 | - } else { |
|
| 2305 | + if ($op) { |
|
| 2306 | + $b = $this->MatchFuncs(array('parseAddition', 'parseEntitiesKeyword', 'parseEntitiesQuoted')); |
|
| 2307 | + if ($b) { |
|
| 2308 | + $c = $this->NewObj5('Less_Tree_Condition', array($op[0], $a, $b, $index, $negate)); |
|
| 2309 | + }else { |
|
| 2310 | 2310 | $this->Error('Unexpected expression'); |
| 2311 | 2311 | } |
| 2312 | - } else { |
|
| 2313 | - $k = $this->NewObj1('Less_Tree_Keyword','true'); |
|
| 2314 | - $c = $this->NewObj5('Less_Tree_Condition',array('=', $a, $k, $index, $negate)); |
|
| 2312 | + }else { |
|
| 2313 | + $k = $this->NewObj1('Less_Tree_Keyword', 'true'); |
|
| 2314 | + $c = $this->NewObj5('Less_Tree_Condition', array('=', $a, $k, $index, $negate)); |
|
| 2315 | 2315 | } |
| 2316 | 2316 | $this->expectChar(')'); |
| 2317 | - return $this->MatchReg('/\\Gand/') ? $this->NewObj3('Less_Tree_Condition',array('and', $c, $this->parseCondition())) : $c; |
|
| 2317 | + return $this->MatchReg('/\\Gand/') ? $this->NewObj3('Less_Tree_Condition', array('and', $c, $this->parseCondition())) : $c; |
|
| 2318 | 2318 | } |
| 2319 | 2319 | } |
| 2320 | 2320 | |
@@ -2323,23 +2323,23 @@ discard block |
||
| 2323 | 2323 | * such as a Color, or a Variable |
| 2324 | 2324 | * |
| 2325 | 2325 | */ |
| 2326 | - private function parseOperand (){ |
|
| 2326 | + private function parseOperand() { |
|
| 2327 | 2327 | |
| 2328 | 2328 | $negate = false; |
| 2329 | 2329 | $offset = $this->pos+1; |
| 2330 | - if( $offset >= $this->input_len ){ |
|
| 2330 | + if ($offset>=$this->input_len) { |
|
| 2331 | 2331 | return; |
| 2332 | 2332 | } |
| 2333 | 2333 | $char = $this->input[$offset]; |
| 2334 | - if( $char === '@' || $char === '(' ){ |
|
| 2334 | + if ($char==='@' || $char==='(') { |
|
| 2335 | 2335 | $negate = $this->MatchChar('-'); |
| 2336 | 2336 | } |
| 2337 | 2337 | |
| 2338 | - $o = $this->MatchFuncs(array('parseSub','parseEntitiesDimension','parseEntitiesColor','parseEntitiesVariable','parseEntitiesCall')); |
|
| 2338 | + $o = $this->MatchFuncs(array('parseSub', 'parseEntitiesDimension', 'parseEntitiesColor', 'parseEntitiesVariable', 'parseEntitiesCall')); |
|
| 2339 | 2339 | |
| 2340 | - if( $negate ){ |
|
| 2340 | + if ($negate) { |
|
| 2341 | 2341 | $o->parensInOp = true; |
| 2342 | - $o = $this->NewObj1('Less_Tree_Negative',$o); |
|
| 2342 | + $o = $this->NewObj1('Less_Tree_Negative', $o); |
|
| 2343 | 2343 | } |
| 2344 | 2344 | |
| 2345 | 2345 | return $o; |
@@ -2355,25 +2355,25 @@ discard block |
||
| 2355 | 2355 | * |
| 2356 | 2356 | * @return Less_Tree_Expression|null |
| 2357 | 2357 | */ |
| 2358 | - private function parseExpression (){ |
|
| 2358 | + private function parseExpression() { |
|
| 2359 | 2359 | $entities = array(); |
| 2360 | 2360 | |
| 2361 | - do{ |
|
| 2362 | - $e = $this->MatchFuncs(array('parseAddition','parseEntity')); |
|
| 2363 | - if( $e ){ |
|
| 2361 | + do { |
|
| 2362 | + $e = $this->MatchFuncs(array('parseAddition', 'parseEntity')); |
|
| 2363 | + if ($e) { |
|
| 2364 | 2364 | $entities[] = $e; |
| 2365 | 2365 | // operations do not allow keyword "/" dimension (e.g. small/20px) so we support that here |
| 2366 | - if( !$this->PeekReg('/\\G\/[\/*]/') ){ |
|
| 2366 | + if (!$this->PeekReg('/\\G\/[\/*]/')) { |
|
| 2367 | 2367 | $delim = $this->MatchChar('/'); |
| 2368 | - if( $delim ){ |
|
| 2369 | - $entities[] = $this->NewObj1('Less_Tree_Anonymous',$delim); |
|
| 2368 | + if ($delim) { |
|
| 2369 | + $entities[] = $this->NewObj1('Less_Tree_Anonymous', $delim); |
|
| 2370 | 2370 | } |
| 2371 | 2371 | } |
| 2372 | 2372 | } |
| 2373 | - }while($e); |
|
| 2373 | + } while ($e); |
|
| 2374 | 2374 | |
| 2375 | - if( $entities ){ |
|
| 2376 | - return $this->NewObj1('Less_Tree_Expression',$entities); |
|
| 2375 | + if ($entities) { |
|
| 2376 | + return $this->NewObj1('Less_Tree_Expression', $entities); |
|
| 2377 | 2377 | } |
| 2378 | 2378 | } |
| 2379 | 2379 | |
@@ -2384,9 +2384,9 @@ discard block |
||
| 2384 | 2384 | * |
| 2385 | 2385 | * @return string |
| 2386 | 2386 | */ |
| 2387 | - private function parseProperty (){ |
|
| 2387 | + private function parseProperty() { |
|
| 2388 | 2388 | $name = $this->MatchReg('/\\G(\*?-?[_a-zA-Z0-9-]+)\s*:/'); |
| 2389 | - if( $name ){ |
|
| 2389 | + if ($name) { |
|
| 2390 | 2390 | return $name[1]; |
| 2391 | 2391 | } |
| 2392 | 2392 | } |
@@ -2398,30 +2398,30 @@ discard block |
||
| 2398 | 2398 | * |
| 2399 | 2399 | * @return string |
| 2400 | 2400 | */ |
| 2401 | - private function parseRuleProperty(){ |
|
| 2401 | + private function parseRuleProperty() { |
|
| 2402 | 2402 | $offset = $this->pos; |
| 2403 | 2403 | $name = array(); |
| 2404 | 2404 | $index = array(); |
| 2405 | 2405 | $length = 0; |
| 2406 | 2406 | |
| 2407 | 2407 | |
| 2408 | - $this->rulePropertyMatch('/\\G(\*?)/', $offset, $length, $index, $name ); |
|
| 2409 | - while( $this->rulePropertyMatch('/\\G((?:[\w-]+)|(?:@\{[\w-]+\}))/', $offset, $length, $index, $name )); // ! |
|
| 2408 | + $this->rulePropertyMatch('/\\G(\*?)/', $offset, $length, $index, $name); |
|
| 2409 | + while ($this->rulePropertyMatch('/\\G((?:[\w-]+)|(?:@\{[\w-]+\}))/', $offset, $length, $index, $name)); // ! |
|
| 2410 | 2410 | |
| 2411 | - if( (count($name) > 1) && $this->rulePropertyMatch('/\\G\s*((?:\+_|\+)?)\s*:/', $offset, $length, $index, $name) ){ |
|
| 2411 | + if ((count($name)>1) && $this->rulePropertyMatch('/\\G\s*((?:\+_|\+)?)\s*:/', $offset, $length, $index, $name)) { |
|
| 2412 | 2412 | // at last, we have the complete match now. move forward, |
| 2413 | 2413 | // convert name particles to tree objects and return: |
| 2414 | 2414 | $this->skipWhitespace($length); |
| 2415 | 2415 | |
| 2416 | - if( $name[0] === '' ){ |
|
| 2416 | + if ($name[0]==='') { |
|
| 2417 | 2417 | array_shift($name); |
| 2418 | 2418 | array_shift($index); |
| 2419 | 2419 | } |
| 2420 | - foreach($name as $k => $s ){ |
|
| 2421 | - if( !$s || $s[0] !== '@' ){ |
|
| 2422 | - $name[$k] = $this->NewObj1('Less_Tree_Keyword',$s); |
|
| 2423 | - }else{ |
|
| 2424 | - $name[$k] = $this->NewObj3('Less_Tree_Variable',array('@' . substr($s,2,-1), $index[$k], $this->env->currentFileInfo)); |
|
| 2420 | + foreach ($name as $k => $s) { |
|
| 2421 | + if (!$s || $s[0]!=='@') { |
|
| 2422 | + $name[$k] = $this->NewObj1('Less_Tree_Keyword', $s); |
|
| 2423 | + }else { |
|
| 2424 | + $name[$k] = $this->NewObj3('Less_Tree_Variable', array('@'.substr($s, 2, -1), $index[$k], $this->env->currentFileInfo)); |
|
| 2425 | 2425 | } |
| 2426 | 2426 | } |
| 2427 | 2427 | return $name; |
@@ -2430,10 +2430,10 @@ discard block |
||
| 2430 | 2430 | |
| 2431 | 2431 | } |
| 2432 | 2432 | |
| 2433 | - private function rulePropertyMatch( $re, &$offset, &$length, &$index, &$name ){ |
|
| 2433 | + private function rulePropertyMatch($re, &$offset, &$length, &$index, &$name) { |
|
| 2434 | 2434 | preg_match($re, $this->input, $a, 0, $offset); |
| 2435 | - if( $a ){ |
|
| 2436 | - $index[] = $this->pos + $length; |
|
| 2435 | + if ($a) { |
|
| 2436 | + $index[] = $this->pos+$length; |
|
| 2437 | 2437 | $length += strlen($a[0]); |
| 2438 | 2438 | $offset += strlen($a[0]); |
| 2439 | 2439 | $name[] = $a[1]; |
@@ -2441,11 +2441,11 @@ discard block |
||
| 2441 | 2441 | } |
| 2442 | 2442 | } |
| 2443 | 2443 | |
| 2444 | - public static function serializeVars( $vars ){ |
|
| 2444 | + public static function serializeVars($vars) { |
|
| 2445 | 2445 | $s = ''; |
| 2446 | 2446 | |
| 2447 | - foreach($vars as $name => $value){ |
|
| 2448 | - $s .= (($name[0] === '@') ? '' : '@') . $name .': '. $value . ((substr($value,-1) === ';') ? '' : ';'); |
|
| 2447 | + foreach ($vars as $name => $value) { |
|
| 2448 | + $s .= (($name[0]==='@') ? '' : '@').$name.': '.$value.((substr($value, -1)===';') ? '' : ';'); |
|
| 2449 | 2449 | } |
| 2450 | 2450 | |
| 2451 | 2451 | return $s; |
@@ -2457,8 +2457,8 @@ discard block |
||
| 2457 | 2457 | * |
| 2458 | 2458 | * @param string $b |
| 2459 | 2459 | */ |
| 2460 | - public static function is_method($a,$b){ |
|
| 2461 | - return is_object($a) && method_exists($a,$b); |
|
| 2460 | + public static function is_method($a, $b) { |
|
| 2461 | + return is_object($a) && method_exists($a, $b); |
|
| 2462 | 2462 | } |
| 2463 | 2463 | |
| 2464 | 2464 | |
@@ -2467,17 +2467,17 @@ discard block |
||
| 2467 | 2467 | * eg: 1.499999 to 1 instead of 2 |
| 2468 | 2468 | * |
| 2469 | 2469 | */ |
| 2470 | - public static function round($i, $precision = 0){ |
|
| 2470 | + public static function round($i, $precision = 0) { |
|
| 2471 | 2471 | |
| 2472 | - $precision = pow(10,$precision); |
|
| 2473 | - $i = $i*$precision; |
|
| 2472 | + $precision = pow(10, $precision); |
|
| 2473 | + $i = $i * $precision; |
|
| 2474 | 2474 | |
| 2475 | 2475 | $ceil = ceil($i); |
| 2476 | 2476 | $floor = floor($i); |
| 2477 | - if( ($ceil - $i) <= ($i - $floor) ){ |
|
| 2478 | - return $ceil/$precision; |
|
| 2479 | - }else{ |
|
| 2480 | - return $floor/$precision; |
|
| 2477 | + if (($ceil-$i)<=($i-$floor)) { |
|
| 2478 | + return $ceil / $precision; |
|
| 2479 | + }else { |
|
| 2480 | + return $floor / $precision; |
|
| 2481 | 2481 | } |
| 2482 | 2482 | } |
| 2483 | 2483 | |
@@ -2487,77 +2487,77 @@ discard block |
||
| 2487 | 2487 | * |
| 2488 | 2488 | * @return mixed |
| 2489 | 2489 | */ |
| 2490 | - public function NewObj0($class){ |
|
| 2490 | + public function NewObj0($class) { |
|
| 2491 | 2491 | $obj = new $class(); |
| 2492 | - if( $this->CacheEnabled() ){ |
|
| 2492 | + if ($this->CacheEnabled()) { |
|
| 2493 | 2493 | $obj->cache_string = ' new '.$class.'()'; |
| 2494 | 2494 | } |
| 2495 | 2495 | return $obj; |
| 2496 | 2496 | } |
| 2497 | 2497 | |
| 2498 | - public function NewObj1($class, $arg){ |
|
| 2499 | - $obj = new $class( $arg ); |
|
| 2500 | - if( $this->CacheEnabled() ){ |
|
| 2498 | + public function NewObj1($class, $arg) { |
|
| 2499 | + $obj = new $class($arg); |
|
| 2500 | + if ($this->CacheEnabled()) { |
|
| 2501 | 2501 | $obj->cache_string = ' new '.$class.'('.Less_Parser::ArgString($arg).')'; |
| 2502 | 2502 | } |
| 2503 | 2503 | return $obj; |
| 2504 | 2504 | } |
| 2505 | 2505 | |
| 2506 | - public function NewObj2($class, $args){ |
|
| 2507 | - $obj = new $class( $args[0], $args[1] ); |
|
| 2508 | - if( $this->CacheEnabled() ){ |
|
| 2509 | - $this->ObjCache( $obj, $class, $args); |
|
| 2506 | + public function NewObj2($class, $args) { |
|
| 2507 | + $obj = new $class($args[0], $args[1]); |
|
| 2508 | + if ($this->CacheEnabled()) { |
|
| 2509 | + $this->ObjCache($obj, $class, $args); |
|
| 2510 | 2510 | } |
| 2511 | 2511 | return $obj; |
| 2512 | 2512 | } |
| 2513 | 2513 | |
| 2514 | - public function NewObj3($class, $args){ |
|
| 2515 | - $obj = new $class( $args[0], $args[1], $args[2] ); |
|
| 2516 | - if( $this->CacheEnabled() ){ |
|
| 2517 | - $this->ObjCache( $obj, $class, $args); |
|
| 2514 | + public function NewObj3($class, $args) { |
|
| 2515 | + $obj = new $class($args[0], $args[1], $args[2]); |
|
| 2516 | + if ($this->CacheEnabled()) { |
|
| 2517 | + $this->ObjCache($obj, $class, $args); |
|
| 2518 | 2518 | } |
| 2519 | 2519 | return $obj; |
| 2520 | 2520 | } |
| 2521 | 2521 | |
| 2522 | - public function NewObj4($class, $args){ |
|
| 2523 | - $obj = new $class( $args[0], $args[1], $args[2], $args[3] ); |
|
| 2524 | - if( $this->CacheEnabled() ){ |
|
| 2525 | - $this->ObjCache( $obj, $class, $args); |
|
| 2522 | + public function NewObj4($class, $args) { |
|
| 2523 | + $obj = new $class($args[0], $args[1], $args[2], $args[3]); |
|
| 2524 | + if ($this->CacheEnabled()) { |
|
| 2525 | + $this->ObjCache($obj, $class, $args); |
|
| 2526 | 2526 | } |
| 2527 | 2527 | return $obj; |
| 2528 | 2528 | } |
| 2529 | 2529 | |
| 2530 | - public function NewObj5($class, $args){ |
|
| 2531 | - $obj = new $class( $args[0], $args[1], $args[2], $args[3], $args[4] ); |
|
| 2532 | - if( $this->CacheEnabled() ){ |
|
| 2533 | - $this->ObjCache( $obj, $class, $args); |
|
| 2530 | + public function NewObj5($class, $args) { |
|
| 2531 | + $obj = new $class($args[0], $args[1], $args[2], $args[3], $args[4]); |
|
| 2532 | + if ($this->CacheEnabled()) { |
|
| 2533 | + $this->ObjCache($obj, $class, $args); |
|
| 2534 | 2534 | } |
| 2535 | 2535 | return $obj; |
| 2536 | 2536 | } |
| 2537 | 2537 | |
| 2538 | - public function NewObj6($class, $args){ |
|
| 2539 | - $obj = new $class( $args[0], $args[1], $args[2], $args[3], $args[4], $args[5] ); |
|
| 2540 | - if( $this->CacheEnabled() ){ |
|
| 2541 | - $this->ObjCache( $obj, $class, $args); |
|
| 2538 | + public function NewObj6($class, $args) { |
|
| 2539 | + $obj = new $class($args[0], $args[1], $args[2], $args[3], $args[4], $args[5]); |
|
| 2540 | + if ($this->CacheEnabled()) { |
|
| 2541 | + $this->ObjCache($obj, $class, $args); |
|
| 2542 | 2542 | } |
| 2543 | 2543 | return $obj; |
| 2544 | 2544 | } |
| 2545 | 2545 | |
| 2546 | - public function NewObj7($class, $args){ |
|
| 2547 | - $obj = new $class( $args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6] ); |
|
| 2548 | - if( $this->CacheEnabled() ){ |
|
| 2549 | - $this->ObjCache( $obj, $class, $args); |
|
| 2546 | + public function NewObj7($class, $args) { |
|
| 2547 | + $obj = new $class($args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6]); |
|
| 2548 | + if ($this->CacheEnabled()) { |
|
| 2549 | + $this->ObjCache($obj, $class, $args); |
|
| 2550 | 2550 | } |
| 2551 | 2551 | return $obj; |
| 2552 | 2552 | } |
| 2553 | 2553 | |
| 2554 | 2554 | //caching |
| 2555 | - public function ObjCache($obj, $class, $args=array()){ |
|
| 2556 | - $obj->cache_string = ' new '.$class.'('. self::ArgCache($args).')'; |
|
| 2555 | + public function ObjCache($obj, $class, $args = array()) { |
|
| 2556 | + $obj->cache_string = ' new '.$class.'('.self::ArgCache($args).')'; |
|
| 2557 | 2557 | } |
| 2558 | 2558 | |
| 2559 | - public function ArgCache($args){ |
|
| 2560 | - return implode(',',array_map( array('Less_Parser','ArgString'),$args)); |
|
| 2559 | + public function ArgCache($args) { |
|
| 2560 | + return implode(',', array_map(array('Less_Parser', 'ArgString'), $args)); |
|
| 2561 | 2561 | } |
| 2562 | 2562 | |
| 2563 | 2563 | |
@@ -2566,36 +2566,36 @@ discard block |
||
| 2566 | 2566 | * |
| 2567 | 2567 | * @return string |
| 2568 | 2568 | */ |
| 2569 | - public static function ArgString($arg){ |
|
| 2569 | + public static function ArgString($arg) { |
|
| 2570 | 2570 | |
| 2571 | 2571 | $type = gettype($arg); |
| 2572 | 2572 | |
| 2573 | - if( $type === 'object'){ |
|
| 2573 | + if ($type==='object') { |
|
| 2574 | 2574 | $string = $arg->cache_string; |
| 2575 | 2575 | unset($arg->cache_string); |
| 2576 | 2576 | return $string; |
| 2577 | 2577 | |
| 2578 | - }elseif( $type === 'array' ){ |
|
| 2578 | + }elseif ($type==='array') { |
|
| 2579 | 2579 | $string = ' Array('; |
| 2580 | - foreach($arg as $k => $a){ |
|
| 2581 | - $string .= var_export($k,true).' => '.self::ArgString($a).','; |
|
| 2580 | + foreach ($arg as $k => $a) { |
|
| 2581 | + $string .= var_export($k, true).' => '.self::ArgString($a).','; |
|
| 2582 | 2582 | } |
| 2583 | - return $string . ')'; |
|
| 2583 | + return $string.')'; |
|
| 2584 | 2584 | } |
| 2585 | 2585 | |
| 2586 | - return var_export($arg,true); |
|
| 2586 | + return var_export($arg, true); |
|
| 2587 | 2587 | } |
| 2588 | 2588 | |
| 2589 | - public function Error($msg){ |
|
| 2589 | + public function Error($msg) { |
|
| 2590 | 2590 | throw new Less_Exception_Parser($msg, null, $this->furthest, $this->env->currentFileInfo); |
| 2591 | 2591 | } |
| 2592 | 2592 | |
| 2593 | - public static function WinPath($path){ |
|
| 2593 | + public static function WinPath($path) { |
|
| 2594 | 2594 | return str_replace('\\', '/', $path); |
| 2595 | 2595 | } |
| 2596 | 2596 | |
| 2597 | - public function CacheEnabled(){ |
|
| 2598 | - return (Less_Parser::$options['cache_method'] && (Less_Cache::$cache_dir || (Less_Parser::$options['cache_method'] == 'callback'))); |
|
| 2597 | + public function CacheEnabled() { |
|
| 2598 | + return (Less_Parser::$options['cache_method'] && (Less_Cache::$cache_dir || (Less_Parser::$options['cache_method']=='callback'))); |
|
| 2599 | 2599 | } |
| 2600 | 2600 | |
| 2601 | 2601 | } |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | // which will then be passed around by reference. |
| 79 | 79 | if( $env instanceof Less_Environment ){ |
| 80 | 80 | $this->env = $env; |
| 81 | - }else{ |
|
| 81 | + } else{ |
|
| 82 | 82 | $this->SetOptions(Less_Parser::$default_options); |
| 83 | 83 | $this->Reset( $env ); |
| 84 | 84 | } |
@@ -157,8 +157,9 @@ discard block |
||
| 157 | 157 | * @param string $name function name |
| 158 | 158 | */ |
| 159 | 159 | public function unregisterFunction($name) { |
| 160 | - if( isset($this->env->functions[$name]) ) |
|
| 161 | - unset($this->env->functions[$name]); |
|
| 160 | + if( isset($this->env->functions[$name]) ) { |
|
| 161 | + unset($this->env->functions[$name]); |
|
| 162 | + } |
|
| 162 | 163 | } |
| 163 | 164 | |
| 164 | 165 | |
@@ -193,7 +194,7 @@ discard block |
||
| 193 | 194 | // will also save file |
| 194 | 195 | // FIXME: should happen somewhere else? |
| 195 | 196 | $css = $generator->generateCSS(); |
| 196 | - }else{ |
|
| 197 | + } else{ |
|
| 197 | 198 | $css = $evaldRoot->toCSS(); |
| 198 | 199 | } |
| 199 | 200 | |
@@ -246,7 +247,7 @@ discard block |
||
| 246 | 247 | |
| 247 | 248 | if( property_exists($plugin,'isPreVisitor') && $plugin->isPreVisitor ){ |
| 248 | 249 | array_unshift( $visitors, $plugin); |
| 249 | - }else{ |
|
| 250 | + } else{ |
|
| 250 | 251 | $visitors[] = $plugin; |
| 251 | 252 | } |
| 252 | 253 | } |
@@ -272,7 +273,7 @@ discard block |
||
| 272 | 273 | if( !$file_uri ){ |
| 273 | 274 | $uri_root = ''; |
| 274 | 275 | $filename = 'anonymous-file-'.Less_Parser::$next_id++.'.less'; |
| 275 | - }else{ |
|
| 276 | + } else{ |
|
| 276 | 277 | $file_uri = self::WinPath($file_uri); |
| 277 | 278 | $filename = basename($file_uri); |
| 278 | 279 | $uri_root = dirname($file_uri); |
@@ -326,7 +327,7 @@ discard block |
||
| 326 | 327 | if( $returnRoot ){ |
| 327 | 328 | $rules = $this->GetRules( $filename ); |
| 328 | 329 | $return = new Less_Tree_Ruleset(array(), $rules ); |
| 329 | - }else{ |
|
| 330 | + } else{ |
|
| 330 | 331 | $this->_parse( $filename ); |
| 331 | 332 | $return = $this; |
| 332 | 333 | } |
@@ -373,7 +374,7 @@ discard block |
||
| 373 | 374 | $currentFileInfo['entryUri'] = $this->env->currentFileInfo['entryUri']; |
| 374 | 375 | $currentFileInfo['rootpath'] = $this->env->currentFileInfo['rootpath']; |
| 375 | 376 | |
| 376 | - }else{ |
|
| 377 | + } else{ |
|
| 377 | 378 | $currentFileInfo['entryPath'] = $dirname; |
| 378 | 379 | $currentFileInfo['entryUri'] = $uri_root; |
| 379 | 380 | $currentFileInfo['rootpath'] = $dirname; |
@@ -406,13 +407,13 @@ discard block |
||
| 406 | 407 | } |
| 407 | 408 | throw new Less_Exception_Parser('Less.php cache directory couldn\'t be created: '.$dir); |
| 408 | 409 | |
| 409 | - }elseif( !is_dir($dir) ){ |
|
| 410 | + } elseif( !is_dir($dir) ){ |
|
| 410 | 411 | throw new Less_Exception_Parser('Less.php cache directory doesn\'t exist: '.$dir); |
| 411 | 412 | |
| 412 | - }elseif( !is_writable($dir) ){ |
|
| 413 | + } elseif( !is_writable($dir) ){ |
|
| 413 | 414 | throw new Less_Exception_Parser('Less.php cache directory isn\'t writable: '.$dir); |
| 414 | 415 | |
| 415 | - }else{ |
|
| 416 | + } else{ |
|
| 416 | 417 | $dir = self::WinPath($dir); |
| 417 | 418 | Less_Cache::$cache_dir = rtrim($dir,'/').'/'; |
| 418 | 419 | return true; |
@@ -489,7 +490,7 @@ discard block |
||
| 489 | 490 | } |
| 490 | 491 | } |
| 491 | 492 | |
| 492 | - }elseif( file_exists($cache_file) ){ |
|
| 493 | + } elseif( file_exists($cache_file) ){ |
|
| 493 | 494 | switch(Less_Parser::$options['cache_method']){ |
| 494 | 495 | |
| 495 | 496 | // Using serialize |
@@ -532,7 +533,7 @@ discard block |
||
| 532 | 533 | ); |
| 533 | 534 | } |
| 534 | 535 | |
| 535 | - }else{ |
|
| 536 | + } else{ |
|
| 536 | 537 | //msg('write cache file'); |
| 537 | 538 | switch(Less_Parser::$options['cache_method']){ |
| 538 | 539 | case 'serialize': |
@@ -667,10 +668,10 @@ discard block |
||
| 667 | 668 | return count($match) === 1 ? $match[0] : $match; |
| 668 | 669 | } |
| 669 | 670 | |
| 670 | - }elseif( $char === '#' ){ |
|
| 671 | + } elseif( $char === '#' ){ |
|
| 671 | 672 | $match = $this->MatchChar($tok[1]); |
| 672 | 673 | |
| 673 | - }else{ |
|
| 674 | + } else{ |
|
| 674 | 675 | // Non-terminal, match using a function call |
| 675 | 676 | $match = $this->$tok(); |
| 676 | 677 | |
@@ -775,7 +776,7 @@ discard block |
||
| 775 | 776 | $result = $this->MatchChar($tok); |
| 776 | 777 | if( !$result ){ |
| 777 | 778 | $this->Error( $msg ? "Expected '" . $tok . "' got '" . $this->input[$this->pos] . "'" : $msg ); |
| 778 | - }else{ |
|
| 779 | + } else{ |
|
| 779 | 780 | return $result; |
| 780 | 781 | } |
| 781 | 782 | } |
@@ -845,7 +846,7 @@ discard block |
||
| 845 | 846 | |
| 846 | 847 | if( $node ){ |
| 847 | 848 | $root[] = $node; |
| 848 | - }elseif( !$this->MatchReg('/\\G[\s\n;]+/') ){ |
|
| 849 | + } elseif( !$this->MatchReg('/\\G[\s\n;]+/') ){ |
|
| 849 | 850 | break; |
| 850 | 851 | } |
| 851 | 852 | |
@@ -1284,7 +1285,7 @@ discard block |
||
| 1284 | 1285 | $returned = $this->parseMixinArgs(true); |
| 1285 | 1286 | $args = $returned['args']; |
| 1286 | 1287 | $this->expectChar(')'); |
| 1287 | - }else{ |
|
| 1288 | + } else{ |
|
| 1288 | 1289 | $args = array(); |
| 1289 | 1290 | } |
| 1290 | 1291 | |
@@ -1346,7 +1347,7 @@ discard block |
||
| 1346 | 1347 | |
| 1347 | 1348 | if( $isSemiColonSeperated ){ |
| 1348 | 1349 | $argsSemiColon[] = array('variadic'=>true); |
| 1349 | - }else{ |
|
| 1350 | + } else{ |
|
| 1350 | 1351 | $argsComma[] = array('variadic'=>true); |
| 1351 | 1352 | } |
| 1352 | 1353 | break; |
@@ -1408,18 +1409,18 @@ discard block |
||
| 1408 | 1409 | } |
| 1409 | 1410 | |
| 1410 | 1411 | $nameLoop = ($name = $val->name); |
| 1411 | - }elseif( !$isCall && $this->MatchReg('/\\G\.{3}/') ){ |
|
| 1412 | + } elseif( !$isCall && $this->MatchReg('/\\G\.{3}/') ){ |
|
| 1412 | 1413 | $returner['variadic'] = true; |
| 1413 | 1414 | if( $this->MatchChar(";") && !$isSemiColonSeperated ){ |
| 1414 | 1415 | $isSemiColonSeperated = true; |
| 1415 | 1416 | } |
| 1416 | 1417 | if( $isSemiColonSeperated ){ |
| 1417 | 1418 | $argsSemiColon[] = array('name'=> $arg->name, 'variadic' => true); |
| 1418 | - }else{ |
|
| 1419 | + } else{ |
|
| 1419 | 1420 | $argsComma[] = array('name'=> $arg->name, 'variadic' => true); |
| 1420 | 1421 | } |
| 1421 | 1422 | break; |
| 1422 | - }elseif( !$isCall ){ |
|
| 1423 | + } elseif( !$isCall ){ |
|
| 1423 | 1424 | $name = $nameLoop = $val->name; |
| 1424 | 1425 | $value = null; |
| 1425 | 1426 | } |
@@ -1525,7 +1526,7 @@ discard block |
||
| 1525 | 1526 | } |
| 1526 | 1527 | |
| 1527 | 1528 | $this->restore(); |
| 1528 | - }else{ |
|
| 1529 | + } else{ |
|
| 1529 | 1530 | $this->forget(); |
| 1530 | 1531 | } |
| 1531 | 1532 | } |
@@ -1562,7 +1563,7 @@ discard block |
||
| 1562 | 1563 | $value = $this->MatchReg('/\\G[0-9]+/'); |
| 1563 | 1564 | if( $value ){ |
| 1564 | 1565 | $value = $value[0]; |
| 1565 | - }else{ |
|
| 1566 | + } else{ |
|
| 1566 | 1567 | $value = $this->parseEntitiesVariable(); |
| 1567 | 1568 | if( !$value ){ |
| 1568 | 1569 | return; |
@@ -1599,10 +1600,10 @@ discard block |
||
| 1599 | 1600 | if( ($v = $this->parseSelector()) && $this->MatchChar(')') ){ |
| 1600 | 1601 | $e = $this->NewObj1('Less_Tree_Paren',$v); |
| 1601 | 1602 | $this->forget(); |
| 1602 | - }else{ |
|
| 1603 | + } else{ |
|
| 1603 | 1604 | $this->restore(); |
| 1604 | 1605 | } |
| 1605 | - }else{ |
|
| 1606 | + } else{ |
|
| 1606 | 1607 | $this->forget(); |
| 1607 | 1608 | } |
| 1608 | 1609 | } |
@@ -1671,11 +1672,11 @@ discard block |
||
| 1671 | 1672 | while( ($isLess && ($extend = $this->parseExtend())) || ($isLess && ($when = $this->MatchReg('/\\Gwhen/') )) || ($e = $this->parseElement()) ){ |
| 1672 | 1673 | if( $when ){ |
| 1673 | 1674 | $condition = $this->expect('parseConditions', 'expected condition'); |
| 1674 | - }elseif( $condition ){ |
|
| 1675 | + } elseif( $condition ){ |
|
| 1675 | 1676 | //error("CSS guard can only be used at the end of selector"); |
| 1676 | - }elseif( $extend ){ |
|
| 1677 | + } elseif( $extend ){ |
|
| 1677 | 1678 | $extendList = array_merge($extendList,$extend); |
| 1678 | - }else{ |
|
| 1679 | + } else{ |
|
| 1679 | 1680 | //if( count($extendList) ){ |
| 1680 | 1681 | //error("Extend can only be used at the end of selector"); |
| 1681 | 1682 | //} |
@@ -1857,7 +1858,7 @@ discard block |
||
| 1857 | 1858 | //if( !$tryAnonymous && is_string($name) && $name[0] === '@' ){ |
| 1858 | 1859 | if( !$tryAnonymous && (Less_Parser::$options['compress'] || $isVariable) ){ |
| 1859 | 1860 | $value = $this->MatchFuncs( array('parseValue','parseAnonymousValue')); |
| 1860 | - }else{ |
|
| 1861 | + } else{ |
|
| 1861 | 1862 | $value = $this->MatchFuncs( array('parseAnonymousValue','parseValue')); |
| 1862 | 1863 | } |
| 1863 | 1864 | |
@@ -1878,14 +1879,14 @@ discard block |
||
| 1878 | 1879 | if( $value && $this->parseEnd() ){ |
| 1879 | 1880 | $this->forget(); |
| 1880 | 1881 | return $this->NewObj6('Less_Tree_Rule',array( $name, $value, $important, $merge, $startOfRule, $this->env->currentFileInfo)); |
| 1881 | - }else{ |
|
| 1882 | + } else{ |
|
| 1882 | 1883 | $this->furthest = $this->pos; |
| 1883 | 1884 | $this->restore(); |
| 1884 | 1885 | if( $value && !$tryAnonymous ){ |
| 1885 | 1886 | return $this->parseRule(true); |
| 1886 | 1887 | } |
| 1887 | 1888 | } |
| 1888 | - }else{ |
|
| 1889 | + } else{ |
|
| 1889 | 1890 | $this->forget(); |
| 1890 | 1891 | } |
| 1891 | 1892 | } |
@@ -1990,8 +1991,9 @@ discard block |
||
| 1990 | 1991 | } else { |
| 1991 | 1992 | return null; |
| 1992 | 1993 | } |
| 1993 | - } else |
|
| 1994 | - return null; |
|
| 1994 | + } else { |
|
| 1995 | + return null; |
|
| 1996 | + } |
|
| 1995 | 1997 | } |
| 1996 | 1998 | } while ($e); |
| 1997 | 1999 | |
@@ -2007,12 +2009,16 @@ discard block |
||
| 2007 | 2009 | $e = $this->parseMediaFeature(); |
| 2008 | 2010 | if( $e ){ |
| 2009 | 2011 | $features[] = $e; |
| 2010 | - if (!$this->MatchChar(',')) break; |
|
| 2011 | - }else{ |
|
| 2012 | + if (!$this->MatchChar(',')) { |
|
| 2013 | + break; |
|
| 2014 | + } |
|
| 2015 | + } else{ |
|
| 2012 | 2016 | $e = $this->parseEntitiesVariable(); |
| 2013 | 2017 | if( $e ){ |
| 2014 | 2018 | $features[] = $e; |
| 2015 | - if (!$this->MatchChar(',')) break; |
|
| 2019 | + if (!$this->MatchChar(',')) { |
|
| 2020 | + break; |
|
| 2021 | + } |
|
| 2016 | 2022 | } |
| 2017 | 2023 | } |
| 2018 | 2024 | } while ($e); |
@@ -2060,7 +2066,9 @@ discard block |
||
| 2060 | 2066 | |
| 2061 | 2067 | $name = $this->MatchReg('/\\G@[a-z-]+/'); |
| 2062 | 2068 | |
| 2063 | - if( !$name ) return; |
|
| 2069 | + if( !$name ) { |
|
| 2070 | + return; |
|
| 2071 | + } |
|
| 2064 | 2072 | $name = $name[0]; |
| 2065 | 2073 | |
| 2066 | 2074 | |
@@ -2243,7 +2251,7 @@ discard block |
||
| 2243 | 2251 | $op = $this->MatchReg('/\\G[-+]\s+/'); |
| 2244 | 2252 | if( $op ){ |
| 2245 | 2253 | $op = $op[0]; |
| 2246 | - }else{ |
|
| 2254 | + } else{ |
|
| 2247 | 2255 | if( !$isSpaced ){ |
| 2248 | 2256 | $op = $this->match(array('#+','#-')); |
| 2249 | 2257 | } |
@@ -2296,7 +2304,9 @@ discard block |
||
| 2296 | 2304 | $negate = false; |
| 2297 | 2305 | $c = null; |
| 2298 | 2306 | |
| 2299 | - if ($this->MatchReg('/\\Gnot/')) $negate = true; |
|
| 2307 | + if ($this->MatchReg('/\\Gnot/')) { |
|
| 2308 | + $negate = true; |
|
| 2309 | + } |
|
| 2300 | 2310 | $this->expectChar('('); |
| 2301 | 2311 | $a = $this->MatchFuncs(array('parseAddition','parseEntitiesKeyword','parseEntitiesQuoted')); |
| 2302 | 2312 | |
@@ -2420,7 +2430,7 @@ discard block |
||
| 2420 | 2430 | foreach($name as $k => $s ){ |
| 2421 | 2431 | if( !$s || $s[0] !== '@' ){ |
| 2422 | 2432 | $name[$k] = $this->NewObj1('Less_Tree_Keyword',$s); |
| 2423 | - }else{ |
|
| 2433 | + } else{ |
|
| 2424 | 2434 | $name[$k] = $this->NewObj3('Less_Tree_Variable',array('@' . substr($s,2,-1), $index[$k], $this->env->currentFileInfo)); |
| 2425 | 2435 | } |
| 2426 | 2436 | } |
@@ -2476,7 +2486,7 @@ discard block |
||
| 2476 | 2486 | $floor = floor($i); |
| 2477 | 2487 | if( ($ceil - $i) <= ($i - $floor) ){ |
| 2478 | 2488 | return $ceil/$precision; |
| 2479 | - }else{ |
|
| 2489 | + } else{ |
|
| 2480 | 2490 | return $floor/$precision; |
| 2481 | 2491 | } |
| 2482 | 2492 | } |
@@ -2575,7 +2585,7 @@ discard block |
||
| 2575 | 2585 | unset($arg->cache_string); |
| 2576 | 2586 | return $string; |
| 2577 | 2587 | |
| 2578 | - }elseif( $type === 'array' ){ |
|
| 2588 | + } elseif( $type === 'array' ){ |
|
| 2579 | 2589 | $string = ' Array('; |
| 2580 | 2590 | foreach($arg as $k => $a){ |
| 2581 | 2591 | $string .= var_export($k,true).' => '.self::ArgString($a).','; |
@@ -191,7 +191,7 @@ |
||
| 191 | 191 | * @param integer $generatedColumn The column number in generated file |
| 192 | 192 | * @param integer $originalLine The line number in original file |
| 193 | 193 | * @param integer $originalColumn The column number in original file |
| 194 | - * @param string $sourceFile The original source file |
|
| 194 | + * @param string $fileInfo |
|
| 195 | 195 | */ |
| 196 | 196 | public function addMapping($generatedLine, $generatedColumn, $originalLine, $originalColumn, $fileInfo ){ |
| 197 | 197 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | * @param Less_Tree_Ruleset $root The root node |
| 86 | 86 | * @param array $options Array of options |
| 87 | 87 | */ |
| 88 | - public function __construct(Less_Tree_Ruleset $root, $contentsMap, $options = array()){ |
|
| 88 | + public function __construct(Less_Tree_Ruleset $root, $contentsMap, $options = array()) { |
|
| 89 | 89 | $this->root = $root; |
| 90 | 90 | $this->contentsMap = $contentsMap; |
| 91 | 91 | $this->encoder = new Less_SourceMap_Base64VLQ(); |
@@ -94,9 +94,9 @@ discard block |
||
| 94 | 94 | |
| 95 | 95 | |
| 96 | 96 | // fix windows paths |
| 97 | - if( !empty($this->options['sourceMapRootpath']) ){ |
|
| 97 | + if (!empty($this->options['sourceMapRootpath'])) { |
|
| 98 | 98 | $this->options['sourceMapRootpath'] = str_replace('\\', '/', $this->options['sourceMapRootpath']); |
| 99 | - $this->options['sourceMapRootpath'] = rtrim($this->options['sourceMapRootpath'],'/').'/'; |
|
| 99 | + $this->options['sourceMapRootpath'] = rtrim($this->options['sourceMapRootpath'], '/').'/'; |
|
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | |
@@ -105,34 +105,34 @@ discard block |
||
| 105 | 105 | * |
| 106 | 106 | * @return string |
| 107 | 107 | */ |
| 108 | - public function generateCSS(){ |
|
| 108 | + public function generateCSS() { |
|
| 109 | 109 | $output = new Less_Output_Mapped($this->contentsMap, $this); |
| 110 | 110 | |
| 111 | 111 | // catch the output |
| 112 | 112 | $this->root->genCSS($output); |
| 113 | 113 | |
| 114 | 114 | |
| 115 | - $sourceMapUrl = $this->getOption('sourceMapURL'); |
|
| 116 | - $sourceMapFilename = $this->getOption('sourceMapFilename'); |
|
| 115 | + $sourceMapUrl = $this->getOption('sourceMapURL'); |
|
| 116 | + $sourceMapFilename = $this->getOption('sourceMapFilename'); |
|
| 117 | 117 | $sourceMapContent = $this->generateJson(); |
| 118 | 118 | $sourceMapWriteTo = $this->getOption('sourceMapWriteTo'); |
| 119 | 119 | |
| 120 | - if( !$sourceMapUrl && $sourceMapFilename ){ |
|
| 120 | + if (!$sourceMapUrl && $sourceMapFilename) { |
|
| 121 | 121 | $sourceMapUrl = $this->normalizeFilename($sourceMapFilename); |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | // write map to a file |
| 125 | - if( $sourceMapWriteTo ){ |
|
| 125 | + if ($sourceMapWriteTo) { |
|
| 126 | 126 | $this->saveMap($sourceMapWriteTo, $sourceMapContent); |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | // inline the map |
| 130 | - if( !$sourceMapUrl ){ |
|
| 130 | + if (!$sourceMapUrl) { |
|
| 131 | 131 | $sourceMapUrl = sprintf('data:application/json,%s', Less_Functions::encodeURIComponent($sourceMapContent)); |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - if( $sourceMapUrl ){ |
|
| 135 | - $output->add( sprintf('/*# sourceMappingURL=%s */', $sourceMapUrl) ); |
|
| 134 | + if ($sourceMapUrl) { |
|
| 135 | + $output->add(sprintf('/*# sourceMappingURL=%s */', $sourceMapUrl)); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | return $output->toString(); |
@@ -145,15 +145,15 @@ discard block |
||
| 145 | 145 | * @param string $content The content to write |
| 146 | 146 | * @throws Exception If the file could not be saved |
| 147 | 147 | */ |
| 148 | - protected function saveMap($file, $content){ |
|
| 148 | + protected function saveMap($file, $content) { |
|
| 149 | 149 | $dir = dirname($file); |
| 150 | 150 | // directory does not exist |
| 151 | - if( !is_dir($dir) ){ |
|
| 151 | + if (!is_dir($dir)) { |
|
| 152 | 152 | // FIXME: create the dir automatically? |
| 153 | 153 | throw new Exception(sprintf('The directory "%s" does not exist. Cannot save the source map.', $dir)); |
| 154 | 154 | } |
| 155 | 155 | // FIXME: proper saving, with dir write check! |
| 156 | - if(file_put_contents($file, $content) === false){ |
|
| 156 | + if (file_put_contents($file, $content)===false) { |
|
| 157 | 157 | throw new Exception(sprintf('Cannot save the source map to "%s"', $file)); |
| 158 | 158 | } |
| 159 | 159 | return true; |
@@ -165,23 +165,23 @@ discard block |
||
| 165 | 165 | * @param string $filename |
| 166 | 166 | * @return string |
| 167 | 167 | */ |
| 168 | - protected function normalizeFilename($filename){ |
|
| 168 | + protected function normalizeFilename($filename) { |
|
| 169 | 169 | |
| 170 | 170 | $filename = str_replace('\\', '/', $filename); |
| 171 | 171 | $rootpath = $this->getOption('sourceMapRootpath'); |
| 172 | 172 | $basePath = $this->getOption('sourceMapBasepath'); |
| 173 | 173 | |
| 174 | 174 | // "Trim" the 'sourceMapBasepath' from the output filename. |
| 175 | - if (strpos($filename, $basePath) === 0) { |
|
| 175 | + if (strpos($filename, $basePath)===0) { |
|
| 176 | 176 | $filename = substr($filename, strlen($basePath)); |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | // Remove extra leading path separators. |
| 180 | - if(strpos($filename, '\\') === 0 || strpos($filename, '/') === 0){ |
|
| 180 | + if (strpos($filename, '\\')===0 || strpos($filename, '/')===0) { |
|
| 181 | 181 | $filename = substr($filename, 1); |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - return $rootpath . $filename; |
|
| 184 | + return $rootpath.$filename; |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | /** |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | * @param integer $originalColumn The column number in original file |
| 194 | 194 | * @param string $sourceFile The original source file |
| 195 | 195 | */ |
| 196 | - public function addMapping($generatedLine, $generatedColumn, $originalLine, $originalColumn, $fileInfo ){ |
|
| 196 | + public function addMapping($generatedLine, $generatedColumn, $originalLine, $originalColumn, $fileInfo) { |
|
| 197 | 197 | |
| 198 | 198 | $this->mappings[] = array( |
| 199 | 199 | 'generated_line' => $generatedLine, |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | * @return string |
| 214 | 214 | * @see https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit# |
| 215 | 215 | */ |
| 216 | - protected function generateJson(){ |
|
| 216 | + protected function generateJson() { |
|
| 217 | 217 | |
| 218 | 218 | $sourceMap = array(); |
| 219 | 219 | $mappings = $this->generateMappings(); |
@@ -224,21 +224,21 @@ discard block |
||
| 224 | 224 | |
| 225 | 225 | // An optional name of the generated code that this source map is associated with. |
| 226 | 226 | $file = $this->getOption('sourceMapFilename'); |
| 227 | - if( $file ){ |
|
| 227 | + if ($file) { |
|
| 228 | 228 | $sourceMap['file'] = $file; |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | |
| 232 | 232 | // An optional source root, useful for relocating source files on a server or removing repeated values in the 'sources' entry. This value is prepended to the individual entries in the 'source' field. |
| 233 | 233 | $root = $this->getOption('sourceRoot'); |
| 234 | - if( $root ){ |
|
| 234 | + if ($root) { |
|
| 235 | 235 | $sourceMap['sourceRoot'] = $root; |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | |
| 239 | 239 | // A list of original sources used by the 'mappings' entry. |
| 240 | 240 | $sourceMap['sources'] = array(); |
| 241 | - foreach($this->sources as $source_uri => $source_filename){ |
|
| 241 | + foreach ($this->sources as $source_uri => $source_filename) { |
|
| 242 | 242 | $sourceMap['sources'][] = $this->normalizeFilename($source_filename); |
| 243 | 243 | } |
| 244 | 244 | |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | // A string with the encoded mapping data. |
| 250 | 250 | $sourceMap['mappings'] = $mappings; |
| 251 | 251 | |
| 252 | - if( $this->getOption('outputSourceFiles') ){ |
|
| 252 | + if ($this->getOption('outputSourceFiles')) { |
|
| 253 | 253 | // An optional list of source content, useful when the 'source' can't be hosted. |
| 254 | 254 | // The contents are listed in the same order as the sources above. |
| 255 | 255 | // 'null' may be used if some original sources should be retrieved by name. |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | // less.js compat fixes |
| 260 | - if( count($sourceMap['sources']) && empty($sourceMap['sourceRoot']) ){ |
|
| 260 | + if (count($sourceMap['sources']) && empty($sourceMap['sourceRoot'])) { |
|
| 261 | 261 | unset($sourceMap['sourceRoot']); |
| 262 | 262 | } |
| 263 | 263 | |
@@ -269,12 +269,12 @@ discard block |
||
| 269 | 269 | * |
| 270 | 270 | * @return array|null |
| 271 | 271 | */ |
| 272 | - protected function getSourcesContent(){ |
|
| 273 | - if(empty($this->sources)){ |
|
| 272 | + protected function getSourcesContent() { |
|
| 273 | + if (empty($this->sources)) { |
|
| 274 | 274 | return; |
| 275 | 275 | } |
| 276 | 276 | $content = array(); |
| 277 | - foreach($this->sources as $sourceFile){ |
|
| 277 | + foreach ($this->sources as $sourceFile) { |
|
| 278 | 278 | $content[] = file_get_contents($sourceFile); |
| 279 | 279 | } |
| 280 | 280 | return $content; |
@@ -285,9 +285,9 @@ discard block |
||
| 285 | 285 | * |
| 286 | 286 | * @return string |
| 287 | 287 | */ |
| 288 | - public function generateMappings(){ |
|
| 288 | + public function generateMappings() { |
|
| 289 | 289 | |
| 290 | - if( !count($this->mappings) ){ |
|
| 290 | + if (!count($this->mappings)) { |
|
| 291 | 291 | return ''; |
| 292 | 292 | } |
| 293 | 293 | |
@@ -296,37 +296,37 @@ discard block |
||
| 296 | 296 | |
| 297 | 297 | // group mappings by generated line number. |
| 298 | 298 | $groupedMap = $groupedMapEncoded = array(); |
| 299 | - foreach($this->mappings as $m){ |
|
| 299 | + foreach ($this->mappings as $m) { |
|
| 300 | 300 | $groupedMap[$m['generated_line']][] = $m; |
| 301 | 301 | } |
| 302 | 302 | ksort($groupedMap); |
| 303 | 303 | |
| 304 | 304 | $lastGeneratedLine = $lastOriginalIndex = $lastOriginalLine = $lastOriginalColumn = 0; |
| 305 | 305 | |
| 306 | - foreach($groupedMap as $lineNumber => $line_map){ |
|
| 307 | - while(++$lastGeneratedLine < $lineNumber){ |
|
| 306 | + foreach ($groupedMap as $lineNumber => $line_map) { |
|
| 307 | + while (++$lastGeneratedLine<$lineNumber) { |
|
| 308 | 308 | $groupedMapEncoded[] = ';'; |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | $lineMapEncoded = array(); |
| 312 | 312 | $lastGeneratedColumn = 0; |
| 313 | 313 | |
| 314 | - foreach($line_map as $m){ |
|
| 315 | - $mapEncoded = $this->encoder->encode($m['generated_column'] - $lastGeneratedColumn); |
|
| 314 | + foreach ($line_map as $m) { |
|
| 315 | + $mapEncoded = $this->encoder->encode($m['generated_column']-$lastGeneratedColumn); |
|
| 316 | 316 | $lastGeneratedColumn = $m['generated_column']; |
| 317 | 317 | |
| 318 | 318 | // find the index |
| 319 | - if( $m['source_file'] ){ |
|
| 319 | + if ($m['source_file']) { |
|
| 320 | 320 | $index = $this->findFileIndex($m['source_file']); |
| 321 | - if( $index !== false ){ |
|
| 322 | - $mapEncoded .= $this->encoder->encode($index - $lastOriginalIndex); |
|
| 321 | + if ($index!==false) { |
|
| 322 | + $mapEncoded .= $this->encoder->encode($index-$lastOriginalIndex); |
|
| 323 | 323 | $lastOriginalIndex = $index; |
| 324 | 324 | |
| 325 | 325 | // lines are stored 0-based in SourceMap spec version 3 |
| 326 | - $mapEncoded .= $this->encoder->encode($m['original_line'] - 1 - $lastOriginalLine); |
|
| 327 | - $lastOriginalLine = $m['original_line'] - 1; |
|
| 326 | + $mapEncoded .= $this->encoder->encode($m['original_line']-1-$lastOriginalLine); |
|
| 327 | + $lastOriginalLine = $m['original_line']-1; |
|
| 328 | 328 | |
| 329 | - $mapEncoded .= $this->encoder->encode($m['original_column'] - $lastOriginalColumn); |
|
| 329 | + $mapEncoded .= $this->encoder->encode($m['original_column']-$lastOriginalColumn); |
|
| 330 | 330 | $lastOriginalColumn = $m['original_column']; |
| 331 | 331 | } |
| 332 | 332 | } |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | $lineMapEncoded[] = $mapEncoded; |
| 335 | 335 | } |
| 336 | 336 | |
| 337 | - $groupedMapEncoded[] = implode(',', $lineMapEncoded) . ';'; |
|
| 337 | + $groupedMapEncoded[] = implode(',', $lineMapEncoded).';'; |
|
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 340 | return rtrim(implode($groupedMapEncoded), ';'); |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | * @param string $filename |
| 347 | 347 | * @return integer|false |
| 348 | 348 | */ |
| 349 | - protected function findFileIndex($filename){ |
|
| 349 | + protected function findFileIndex($filename) { |
|
| 350 | 350 | return $this->source_keys[$filename]; |
| 351 | 351 | } |
| 352 | 352 | |
@@ -197,7 +197,6 @@ |
||
| 197 | 197 | /** |
| 198 | 198 | * Using the import directories, get the full absolute path and uri of the import |
| 199 | 199 | * |
| 200 | - * @param Less_Tree_Import $evald |
|
| 201 | 200 | */ |
| 202 | 201 | public function PathAndUri(){ |
| 203 | 202 | |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | public $root; |
| 28 | 28 | public $type = 'Import'; |
| 29 | 29 | |
| 30 | - public function __construct($path, $features, $options, $index, $currentFileInfo = null ){ |
|
| 30 | + public function __construct($path, $features, $options, $index, $currentFileInfo = null ){ |
|
| 31 | 31 | $this->options = $options; |
| 32 | 32 | $this->index = $index; |
| 33 | 33 | $this->path = $path; |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | // ruleset. |
| 59 | 59 | // |
| 60 | 60 | |
| 61 | - public function accept($visitor){ |
|
| 61 | + public function accept($visitor){ |
|
| 62 | 62 | |
| 63 | 63 | if( $this->features ){ |
| 64 | 64 | $this->features = $visitor->visitObj($this->features); |
@@ -70,10 +70,10 @@ discard block |
||
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * @see Less_Tree::genCSS |
|
| 75 | - */ |
|
| 76 | - public function genCSS( $output ){ |
|
| 73 | + /** |
|
| 74 | + * @see Less_Tree::genCSS |
|
| 75 | + */ |
|
| 76 | + public function genCSS( $output ){ |
|
| 77 | 77 | if( $this->css ){ |
| 78 | 78 | |
| 79 | 79 | $output->add( '@import ', $this->currentFileInfo, $this->index ); |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - public function toCSS(){ |
|
| 90 | + public function toCSS(){ |
|
| 91 | 91 | $features = $this->features ? ' ' . $this->features->toCSS() : ''; |
| 92 | 92 | |
| 93 | 93 | if ($this->css) { |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | /** |
| 101 | 101 | * @return string |
| 102 | 102 | */ |
| 103 | - public function getPath(){ |
|
| 103 | + public function getPath(){ |
|
| 104 | 104 | if ($this->path instanceof Less_Tree_Quoted) { |
| 105 | 105 | $path = $this->path->value; |
| 106 | 106 | $path = ( isset($this->css) || preg_match('/(\.[a-z]*$)|([\?;].*)$/',$path)) ? $path : $path . '.less'; |
@@ -114,11 +114,11 @@ discard block |
||
| 114 | 114 | return preg_replace('/[\?#][^\?]*$/','',$path); |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - public function compileForImport( $env ){ |
|
| 117 | + public function compileForImport( $env ){ |
|
| 118 | 118 | return new Less_Tree_Import( $this->path->compile($env), $this->features, $this->options, $this->index, $this->currentFileInfo); |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - public function compilePath($env) { |
|
| 121 | + public function compilePath($env) { |
|
| 122 | 122 | $path = $this->path->compile($env); |
| 123 | 123 | $rootpath = ''; |
| 124 | 124 | if( $this->currentFileInfo && $this->currentFileInfo['rootpath'] ){ |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | return $path; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - public function compile( $env ){ |
|
| 145 | + public function compile( $env ){ |
|
| 146 | 146 | |
| 147 | 147 | $evald = $this->compileForImport($env); |
| 148 | 148 | |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | * |
| 200 | 200 | * @param Less_Tree_Import $evald |
| 201 | 201 | */ |
| 202 | - public function PathAndUri(){ |
|
| 202 | + public function PathAndUri(){ |
|
| 203 | 203 | |
| 204 | 204 | $evald_path = $this->getPath(); |
| 205 | 205 | |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | * |
| 251 | 251 | * @return Less_Tree_Media|array |
| 252 | 252 | */ |
| 253 | - public function ParseImport( $full_path, $uri, $env ){ |
|
| 253 | + public function ParseImport( $full_path, $uri, $env ){ |
|
| 254 | 254 | |
| 255 | 255 | $import_env = clone $env; |
| 256 | 256 | if( (isset($this->options['reference']) && $this->options['reference']) || isset($this->currentFileInfo['reference']) ){ |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * @package Less |
| 16 | 16 | * @subpackage tree |
| 17 | 17 | */ |
| 18 | -class Less_Tree_Import extends Less_Tree{ |
|
| 18 | +class Less_Tree_Import extends Less_Tree { |
|
| 19 | 19 | |
| 20 | 20 | public $options; |
| 21 | 21 | public $index; |
@@ -27,21 +27,21 @@ discard block |
||
| 27 | 27 | public $root; |
| 28 | 28 | public $type = 'Import'; |
| 29 | 29 | |
| 30 | - public function __construct($path, $features, $options, $index, $currentFileInfo = null ){ |
|
| 30 | + public function __construct($path, $features, $options, $index, $currentFileInfo = null) { |
|
| 31 | 31 | $this->options = $options; |
| 32 | 32 | $this->index = $index; |
| 33 | 33 | $this->path = $path; |
| 34 | 34 | $this->features = $features; |
| 35 | 35 | $this->currentFileInfo = $currentFileInfo; |
| 36 | 36 | |
| 37 | - if( is_array($options) ){ |
|
| 37 | + if (is_array($options)) { |
|
| 38 | 38 | $this->options += array('inline'=>false); |
| 39 | 39 | |
| 40 | - if( isset($this->options['less']) || $this->options['inline'] ){ |
|
| 40 | + if (isset($this->options['less']) || $this->options['inline']) { |
|
| 41 | 41 | $this->css = !isset($this->options['less']) || !$this->options['less'] || $this->options['inline']; |
| 42 | - } else { |
|
| 42 | + }else { |
|
| 43 | 43 | $pathValue = $this->getPath(); |
| 44 | - if( $pathValue && preg_match('/css([\?;].*)?$/',$pathValue) ){ |
|
| 44 | + if ($pathValue && preg_match('/css([\?;].*)?$/', $pathValue)) { |
|
| 45 | 45 | $this->css = true; |
| 46 | 46 | } |
| 47 | 47 | } |
@@ -58,14 +58,14 @@ discard block |
||
| 58 | 58 | // ruleset. |
| 59 | 59 | // |
| 60 | 60 | |
| 61 | - public function accept($visitor){ |
|
| 61 | + public function accept($visitor) { |
|
| 62 | 62 | |
| 63 | - if( $this->features ){ |
|
| 63 | + if ($this->features) { |
|
| 64 | 64 | $this->features = $visitor->visitObj($this->features); |
| 65 | 65 | } |
| 66 | 66 | $this->path = $visitor->visitObj($this->path); |
| 67 | 67 | |
| 68 | - if( !$this->options['inline'] && $this->root ){ |
|
| 68 | + if (!$this->options['inline'] && $this->root) { |
|
| 69 | 69 | $this->root = $visitor->visit($this->root); |
| 70 | 70 | } |
| 71 | 71 | } |
@@ -73,26 +73,26 @@ discard block |
||
| 73 | 73 | /** |
| 74 | 74 | * @see Less_Tree::genCSS |
| 75 | 75 | */ |
| 76 | - public function genCSS( $output ){ |
|
| 77 | - if( $this->css ){ |
|
| 76 | + public function genCSS($output) { |
|
| 77 | + if ($this->css) { |
|
| 78 | 78 | |
| 79 | - $output->add( '@import ', $this->currentFileInfo, $this->index ); |
|
| 79 | + $output->add('@import ', $this->currentFileInfo, $this->index); |
|
| 80 | 80 | |
| 81 | - $this->path->genCSS( $output ); |
|
| 82 | - if( $this->features ){ |
|
| 83 | - $output->add( ' ' ); |
|
| 84 | - $this->features->genCSS( $output ); |
|
| 81 | + $this->path->genCSS($output); |
|
| 82 | + if ($this->features) { |
|
| 83 | + $output->add(' '); |
|
| 84 | + $this->features->genCSS($output); |
|
| 85 | 85 | } |
| 86 | - $output->add( ';' ); |
|
| 86 | + $output->add(';'); |
|
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - public function toCSS(){ |
|
| 91 | - $features = $this->features ? ' ' . $this->features->toCSS() : ''; |
|
| 90 | + public function toCSS() { |
|
| 91 | + $features = $this->features ? ' '.$this->features->toCSS() : ''; |
|
| 92 | 92 | |
| 93 | 93 | if ($this->css) { |
| 94 | - return "@import " . $this->path->toCSS() . $features . ";\n"; |
|
| 95 | - } else { |
|
| 94 | + return "@import ".$this->path->toCSS().$features.";\n"; |
|
| 95 | + }else { |
|
| 96 | 96 | return ""; |
| 97 | 97 | } |
| 98 | 98 | } |
@@ -100,37 +100,37 @@ discard block |
||
| 100 | 100 | /** |
| 101 | 101 | * @return string |
| 102 | 102 | */ |
| 103 | - public function getPath(){ |
|
| 103 | + public function getPath() { |
|
| 104 | 104 | if ($this->path instanceof Less_Tree_Quoted) { |
| 105 | 105 | $path = $this->path->value; |
| 106 | - $path = ( isset($this->css) || preg_match('/(\.[a-z]*$)|([\?;].*)$/',$path)) ? $path : $path . '.less'; |
|
| 107 | - } else if ($this->path instanceof Less_Tree_URL) { |
|
| 106 | + $path = (isset($this->css) || preg_match('/(\.[a-z]*$)|([\?;].*)$/', $path)) ? $path : $path.'.less'; |
|
| 107 | + }else if ($this->path instanceof Less_Tree_URL) { |
|
| 108 | 108 | $path = $this->path->value->value; |
| 109 | - }else{ |
|
| 109 | + }else { |
|
| 110 | 110 | return null; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | //remove query string and fragment |
| 114 | - return preg_replace('/[\?#][^\?]*$/','',$path); |
|
| 114 | + return preg_replace('/[\?#][^\?]*$/', '', $path); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - public function compileForImport( $env ){ |
|
| 118 | - return new Less_Tree_Import( $this->path->compile($env), $this->features, $this->options, $this->index, $this->currentFileInfo); |
|
| 117 | + public function compileForImport($env) { |
|
| 118 | + return new Less_Tree_Import($this->path->compile($env), $this->features, $this->options, $this->index, $this->currentFileInfo); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | public function compilePath($env) { |
| 122 | 122 | $path = $this->path->compile($env); |
| 123 | 123 | $rootpath = ''; |
| 124 | - if( $this->currentFileInfo && $this->currentFileInfo['rootpath'] ){ |
|
| 124 | + if ($this->currentFileInfo && $this->currentFileInfo['rootpath']) { |
|
| 125 | 125 | $rootpath = $this->currentFileInfo['rootpath']; |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | |
| 129 | - if( !($path instanceof Less_Tree_URL) ){ |
|
| 130 | - if( $rootpath ){ |
|
| 129 | + if (!($path instanceof Less_Tree_URL)) { |
|
| 130 | + if ($rootpath) { |
|
| 131 | 131 | $pathValue = $path->value; |
| 132 | 132 | // Add the base path if the import is relative |
| 133 | - if( $pathValue && Less_Environment::isPathRelative($pathValue) ){ |
|
| 133 | + if ($pathValue && Less_Environment::isPathRelative($pathValue)) { |
|
| 134 | 134 | $path->value = $this->currentFileInfo['uri_root'].$pathValue; |
| 135 | 135 | } |
| 136 | 136 | } |
@@ -142,55 +142,55 @@ discard block |
||
| 142 | 142 | return $path; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - public function compile( $env ){ |
|
| 145 | + public function compile($env) { |
|
| 146 | 146 | |
| 147 | 147 | $evald = $this->compileForImport($env); |
| 148 | 148 | |
| 149 | 149 | //get path & uri |
| 150 | 150 | $path_and_uri = null; |
| 151 | - if( is_callable(Less_Parser::$options['import_callback']) ){ |
|
| 152 | - $path_and_uri = call_user_func(Less_Parser::$options['import_callback'],$evald); |
|
| 151 | + if (is_callable(Less_Parser::$options['import_callback'])) { |
|
| 152 | + $path_and_uri = call_user_func(Less_Parser::$options['import_callback'], $evald); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - if( !$path_and_uri ){ |
|
| 155 | + if (!$path_and_uri) { |
|
| 156 | 156 | $path_and_uri = $evald->PathAndUri(); |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | - if( $path_and_uri ){ |
|
| 159 | + if ($path_and_uri) { |
|
| 160 | 160 | list($full_path, $uri) = $path_and_uri; |
| 161 | - }else{ |
|
| 161 | + }else { |
|
| 162 | 162 | $full_path = $uri = $evald->getPath(); |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | |
| 166 | 166 | //import once |
| 167 | - if( $evald->skip( $full_path, $env) ){ |
|
| 167 | + if ($evald->skip($full_path, $env)) { |
|
| 168 | 168 | return array(); |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - if( $this->options['inline'] ){ |
|
| 171 | + if ($this->options['inline']) { |
|
| 172 | 172 | //todo needs to reference css file not import |
| 173 | 173 | //$contents = new Less_Tree_Anonymous($this->root, 0, array('filename'=>$this->importedFilename), true ); |
| 174 | 174 | |
| 175 | 175 | Less_Parser::AddParsedFile($full_path); |
| 176 | - $contents = new Less_Tree_Anonymous( file_get_contents($full_path), 0, array(), true ); |
|
| 176 | + $contents = new Less_Tree_Anonymous(file_get_contents($full_path), 0, array(), true); |
|
| 177 | 177 | |
| 178 | - if( $this->features ){ |
|
| 179 | - return new Less_Tree_Media( array($contents), $this->features->value ); |
|
| 178 | + if ($this->features) { |
|
| 179 | + return new Less_Tree_Media(array($contents), $this->features->value); |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | - return array( $contents ); |
|
| 182 | + return array($contents); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | |
| 186 | 186 | // css ? |
| 187 | - if( $evald->css ){ |
|
| 188 | - $features = ( $evald->features ? $evald->features->compile($env) : null ); |
|
| 189 | - return new Less_Tree_Import( $this->compilePath( $env), $features, $this->options, $this->index); |
|
| 187 | + if ($evald->css) { |
|
| 188 | + $features = ($evald->features ? $evald->features->compile($env) : null); |
|
| 189 | + return new Less_Tree_Import($this->compilePath($env), $features, $this->options, $this->index); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | |
| 193 | - return $this->ParseImport( $full_path, $uri, $env ); |
|
| 193 | + return $this->ParseImport($full_path, $uri, $env); |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | |
@@ -199,45 +199,45 @@ discard block |
||
| 199 | 199 | * |
| 200 | 200 | * @param Less_Tree_Import $evald |
| 201 | 201 | */ |
| 202 | - public function PathAndUri(){ |
|
| 202 | + public function PathAndUri() { |
|
| 203 | 203 | |
| 204 | 204 | $evald_path = $this->getPath(); |
| 205 | 205 | |
| 206 | - if( $evald_path ){ |
|
| 206 | + if ($evald_path) { |
|
| 207 | 207 | |
| 208 | 208 | $import_dirs = array(); |
| 209 | 209 | |
| 210 | - if( Less_Environment::isPathRelative($evald_path) ){ |
|
| 210 | + if (Less_Environment::isPathRelative($evald_path)) { |
|
| 211 | 211 | //if the path is relative, the file should be in the current directory |
| 212 | - $import_dirs[ $this->currentFileInfo['currentDirectory'] ] = $this->currentFileInfo['uri_root']; |
|
| 212 | + $import_dirs[$this->currentFileInfo['currentDirectory']] = $this->currentFileInfo['uri_root']; |
|
| 213 | 213 | |
| 214 | - }else{ |
|
| 214 | + }else { |
|
| 215 | 215 | //otherwise, the file should be relative to the server root |
| 216 | - $import_dirs[ $this->currentFileInfo['entryPath'] ] = $this->currentFileInfo['entryUri']; |
|
| 216 | + $import_dirs[$this->currentFileInfo['entryPath']] = $this->currentFileInfo['entryUri']; |
|
| 217 | 217 | |
| 218 | 218 | //if the user supplied entryPath isn't the actual root |
| 219 | - $import_dirs[ $_SERVER['DOCUMENT_ROOT'] ] = ''; |
|
| 219 | + $import_dirs[$_SERVER['DOCUMENT_ROOT']] = ''; |
|
| 220 | 220 | |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | // always look in user supplied import directories |
| 224 | - $import_dirs = array_merge( $import_dirs, Less_Parser::$options['import_dirs'] ); |
|
| 224 | + $import_dirs = array_merge($import_dirs, Less_Parser::$options['import_dirs']); |
|
| 225 | 225 | |
| 226 | 226 | |
| 227 | - foreach( $import_dirs as $rootpath => $rooturi){ |
|
| 228 | - if( is_callable($rooturi) ){ |
|
| 227 | + foreach ($import_dirs as $rootpath => $rooturi) { |
|
| 228 | + if (is_callable($rooturi)) { |
|
| 229 | 229 | list($path, $uri) = call_user_func($rooturi, $evald_path); |
| 230 | - if( is_string($path) ){ |
|
| 230 | + if (is_string($path)) { |
|
| 231 | 231 | $full_path = $path; |
| 232 | - return array( $full_path, $uri ); |
|
| 232 | + return array($full_path, $uri); |
|
| 233 | 233 | } |
| 234 | - }else{ |
|
| 235 | - $path = rtrim($rootpath,'/\\').'/'.ltrim($evald_path,'/\\'); |
|
| 234 | + }else { |
|
| 235 | + $path = rtrim($rootpath, '/\\').'/'.ltrim($evald_path, '/\\'); |
|
| 236 | 236 | |
| 237 | - if( file_exists($path) ){ |
|
| 237 | + if (file_exists($path)) { |
|
| 238 | 238 | $full_path = Less_Environment::normalizePath($path); |
| 239 | 239 | $uri = Less_Environment::normalizePath(dirname($rooturi.$evald_path)); |
| 240 | - return array( $full_path, $uri ); |
|
| 240 | + return array($full_path, $uri); |
|
| 241 | 241 | } |
| 242 | 242 | } |
| 243 | 243 | } |
@@ -250,14 +250,14 @@ discard block |
||
| 250 | 250 | * |
| 251 | 251 | * @return Less_Tree_Media|array |
| 252 | 252 | */ |
| 253 | - public function ParseImport( $full_path, $uri, $env ){ |
|
| 253 | + public function ParseImport($full_path, $uri, $env) { |
|
| 254 | 254 | |
| 255 | 255 | $import_env = clone $env; |
| 256 | - if( (isset($this->options['reference']) && $this->options['reference']) || isset($this->currentFileInfo['reference']) ){ |
|
| 256 | + if ((isset($this->options['reference']) && $this->options['reference']) || isset($this->currentFileInfo['reference'])) { |
|
| 257 | 257 | $import_env->currentFileInfo['reference'] = true; |
| 258 | 258 | } |
| 259 | 259 | |
| 260 | - if( (isset($this->options['multiple']) && $this->options['multiple']) ){ |
|
| 260 | + if ((isset($this->options['multiple']) && $this->options['multiple'])) { |
|
| 261 | 261 | $import_env->importMultiple = true; |
| 262 | 262 | } |
| 263 | 263 | |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | $root = $parser->parseFile($full_path, $uri, true); |
| 266 | 266 | |
| 267 | 267 | |
| 268 | - $ruleset = new Less_Tree_Ruleset(array(), $root->rules ); |
|
| 268 | + $ruleset = new Less_Tree_Ruleset(array(), $root->rules); |
|
| 269 | 269 | $ruleset->evalImports($import_env); |
| 270 | 270 | |
| 271 | 271 | return $this->features ? new Less_Tree_Media($ruleset->rules, $this->features->value) : $ruleset->rules; |
@@ -277,13 +277,13 @@ discard block |
||
| 277 | 277 | * |
| 278 | 278 | * @return boolean|null |
| 279 | 279 | */ |
| 280 | - private function Skip($path, $env){ |
|
| 280 | + private function Skip($path, $env) { |
|
| 281 | 281 | |
| 282 | 282 | $path = realpath($path); |
| 283 | 283 | |
| 284 | - if( $path && Less_Parser::FileParsed($path) ){ |
|
| 284 | + if ($path && Less_Parser::FileParsed($path)) { |
|
| 285 | 285 | |
| 286 | - if( isset($this->currentFileInfo['reference']) ){ |
|
| 286 | + if (isset($this->currentFileInfo['reference'])) { |
|
| 287 | 287 | return true; |
| 288 | 288 | } |
| 289 | 289 | |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | $path = ( isset($this->css) || preg_match('/(\.[a-z]*$)|([\?;].*)$/',$path)) ? $path : $path . '.less'; |
| 107 | 107 | } else if ($this->path instanceof Less_Tree_URL) { |
| 108 | 108 | $path = $this->path->value->value; |
| 109 | - }else{ |
|
| 109 | + } else{ |
|
| 110 | 110 | return null; |
| 111 | 111 | } |
| 112 | 112 | |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | |
| 159 | 159 | if( $path_and_uri ){ |
| 160 | 160 | list($full_path, $uri) = $path_and_uri; |
| 161 | - }else{ |
|
| 161 | + } else{ |
|
| 162 | 162 | $full_path = $uri = $evald->getPath(); |
| 163 | 163 | } |
| 164 | 164 | |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | //if the path is relative, the file should be in the current directory |
| 212 | 212 | $import_dirs[ $this->currentFileInfo['currentDirectory'] ] = $this->currentFileInfo['uri_root']; |
| 213 | 213 | |
| 214 | - }else{ |
|
| 214 | + } else{ |
|
| 215 | 215 | //otherwise, the file should be relative to the server root |
| 216 | 216 | $import_dirs[ $this->currentFileInfo['entryPath'] ] = $this->currentFileInfo['entryUri']; |
| 217 | 217 | |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | $full_path = $path; |
| 232 | 232 | return array( $full_path, $uri ); |
| 233 | 233 | } |
| 234 | - }else{ |
|
| 234 | + } else{ |
|
| 235 | 235 | $path = rtrim($rootpath,'/\\').'/'.ltrim($evald_path,'/\\'); |
| 236 | 236 | |
| 237 | 237 | if( file_exists($path) ){ |
@@ -148,6 +148,9 @@ |
||
| 148 | 148 | return new Less_Tree_Mixin_Definition($this->name, $this->params, $this->rules, $this->condition, $this->variadic, $env->frames ); |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | + /** |
|
| 152 | + * @param boolean $important |
|
| 153 | + */ |
|
| 151 | 154 | public function evalCall($env, $args = NULL, $important = NULL) { |
| 152 | 155 | |
| 153 | 156 | Less_Environment::$mixin_stack++; |
@@ -1,33 +1,33 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -class Less_Tree_Mixin_Definition extends Less_Tree_Ruleset{ |
|
| 3 | +class Less_Tree_Mixin_Definition extends Less_Tree_Ruleset { |
|
| 4 | 4 | public $name; |
| 5 | 5 | public $selectors; |
| 6 | 6 | public $params; |
| 7 | - public $arity = 0; |
|
| 7 | + public $arity = 0; |
|
| 8 | 8 | public $rules; |
| 9 | 9 | public $lookups = array(); |
| 10 | 10 | public $required = 0; |
| 11 | - public $frames = array(); |
|
| 11 | + public $frames = array(); |
|
| 12 | 12 | public $condition; |
| 13 | 13 | public $variadic; |
| 14 | - public $type = 'MixinDefinition'; |
|
| 14 | + public $type = 'MixinDefinition'; |
|
| 15 | 15 | |
| 16 | 16 | |
| 17 | 17 | // less.js : /lib/less/tree/mixin.js : tree.mixin.Definition |
| 18 | - public function __construct($name, $params, $rules, $condition, $variadic = false, $frames = array() ){ |
|
| 18 | + public function __construct($name, $params, $rules, $condition, $variadic = false, $frames = array()) { |
|
| 19 | 19 | $this->name = $name; |
| 20 | - $this->selectors = array(new Less_Tree_Selector(array( new Less_Tree_Element(null, $name)))); |
|
| 20 | + $this->selectors = array(new Less_Tree_Selector(array(new Less_Tree_Element(null, $name)))); |
|
| 21 | 21 | |
| 22 | 22 | $this->params = $params; |
| 23 | 23 | $this->condition = $condition; |
| 24 | 24 | $this->variadic = $variadic; |
| 25 | 25 | $this->rules = $rules; |
| 26 | 26 | |
| 27 | - if( $params ){ |
|
| 27 | + if ($params) { |
|
| 28 | 28 | $this->arity = count($params); |
| 29 | - foreach( $params as $p ){ |
|
| 30 | - if (! isset($p['name']) || ($p['name'] && !isset($p['value']))) { |
|
| 29 | + foreach ($params as $p) { |
|
| 30 | + if (!isset($p['name']) || ($p['name'] && !isset($p['value']))) { |
|
| 31 | 31 | $this->required++; |
| 32 | 32 | } |
| 33 | 33 | } |
@@ -46,29 +46,29 @@ discard block |
||
| 46 | 46 | //} |
| 47 | 47 | |
| 48 | 48 | |
| 49 | - public function toCSS(){ |
|
| 49 | + public function toCSS() { |
|
| 50 | 50 | return ''; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | // less.js : /lib/less/tree/mixin.js : tree.mixin.Definition.evalParams |
| 54 | - public function compileParams($env, $mixinFrames, $args = array() , &$evaldArguments = array() ){ |
|
| 54 | + public function compileParams($env, $mixinFrames, $args = array(), &$evaldArguments = array()) { |
|
| 55 | 55 | $frame = new Less_Tree_Ruleset(null, array()); |
| 56 | 56 | $params = $this->params; |
| 57 | 57 | $mixinEnv = null; |
| 58 | 58 | $argsLength = 0; |
| 59 | 59 | |
| 60 | - if( $args ){ |
|
| 60 | + if ($args) { |
|
| 61 | 61 | $argsLength = count($args); |
| 62 | - for($i = 0; $i < $argsLength; $i++ ){ |
|
| 62 | + for ($i = 0; $i<$argsLength; $i++) { |
|
| 63 | 63 | $arg = $args[$i]; |
| 64 | 64 | |
| 65 | - if( $arg && $arg['name'] ){ |
|
| 65 | + if ($arg && $arg['name']) { |
|
| 66 | 66 | $isNamedFound = false; |
| 67 | 67 | |
| 68 | - foreach($params as $j => $param){ |
|
| 69 | - if( !isset($evaldArguments[$j]) && $arg['name'] === $params[$j]['name']) { |
|
| 68 | + foreach ($params as $j => $param) { |
|
| 69 | + if (!isset($evaldArguments[$j]) && $arg['name']===$params[$j]['name']) { |
|
| 70 | 70 | $evaldArguments[$j] = $arg['value']->compile($env); |
| 71 | - array_unshift($frame->rules, new Less_Tree_Rule( $arg['name'], $arg['value']->compile($env) ) ); |
|
| 71 | + array_unshift($frame->rules, new Less_Tree_Rule($arg['name'], $arg['value']->compile($env))); |
|
| 72 | 72 | $isNamedFound = true; |
| 73 | 73 | break; |
| 74 | 74 | } |
@@ -78,48 +78,48 @@ discard block |
||
| 78 | 78 | $i--; |
| 79 | 79 | $argsLength--; |
| 80 | 80 | continue; |
| 81 | - } else { |
|
| 82 | - throw new Less_Exception_Compiler("Named argument for " . $this->name .' '.$args[$i]['name'] . ' not found'); |
|
| 81 | + }else { |
|
| 82 | + throw new Less_Exception_Compiler("Named argument for ".$this->name.' '.$args[$i]['name'].' not found'); |
|
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | $argIndex = 0; |
| 89 | - foreach($params as $i => $param){ |
|
| 89 | + foreach ($params as $i => $param) { |
|
| 90 | 90 | |
| 91 | - if ( isset($evaldArguments[$i]) ){ continue; } |
|
| 91 | + if (isset($evaldArguments[$i])) { continue; } |
|
| 92 | 92 | |
| 93 | 93 | $arg = null; |
| 94 | - if( isset($args[$argIndex]) ){ |
|
| 94 | + if (isset($args[$argIndex])) { |
|
| 95 | 95 | $arg = $args[$argIndex]; |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | if (isset($param['name']) && $param['name']) { |
| 99 | 99 | |
| 100 | - if( isset($param['variadic']) ){ |
|
| 100 | + if (isset($param['variadic'])) { |
|
| 101 | 101 | $varargs = array(); |
| 102 | - for ($j = $argIndex; $j < $argsLength; $j++) { |
|
| 102 | + for ($j = $argIndex; $j<$argsLength; $j++) { |
|
| 103 | 103 | $varargs[] = $args[$j]['value']->compile($env); |
| 104 | 104 | } |
| 105 | 105 | $expression = new Less_Tree_Expression($varargs); |
| 106 | 106 | array_unshift($frame->rules, new Less_Tree_Rule($param['name'], $expression->compile($env))); |
| 107 | - }else{ |
|
| 107 | + }else { |
|
| 108 | 108 | $val = ($arg && $arg['value']) ? $arg['value'] : false; |
| 109 | 109 | |
| 110 | 110 | if ($val) { |
| 111 | 111 | $val = $val->compile($env); |
| 112 | - } else if ( isset($param['value']) ) { |
|
| 112 | + }else if (isset($param['value'])) { |
|
| 113 | 113 | |
| 114 | - if( !$mixinEnv ){ |
|
| 114 | + if (!$mixinEnv) { |
|
| 115 | 115 | $mixinEnv = new Less_Environment(); |
| 116 | - $mixinEnv->frames = array_merge( array($frame), $mixinFrames); |
|
| 116 | + $mixinEnv->frames = array_merge(array($frame), $mixinFrames); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | $val = $param['value']->compile($mixinEnv); |
| 120 | 120 | $frame->resetCache(); |
| 121 | - } else { |
|
| 122 | - throw new Less_Exception_Compiler("Wrong number of arguments for " . $this->name . " (" . $argsLength . ' for ' . $this->arity . ")"); |
|
| 121 | + }else { |
|
| 122 | + throw new Less_Exception_Compiler("Wrong number of arguments for ".$this->name." (".$argsLength.' for '.$this->arity.")"); |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | array_unshift($frame->rules, new Less_Tree_Rule($param['name'], $val)); |
@@ -127,8 +127,8 @@ discard block |
||
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - if ( isset($param['variadic']) && $args) { |
|
| 131 | - for ($j = $argIndex; $j < $argsLength; $j++) { |
|
| 130 | + if (isset($param['variadic']) && $args) { |
|
| 131 | + for ($j = $argIndex; $j<$argsLength; $j++) { |
|
| 132 | 132 | $evaldArguments[$j] = $args[$j]['value']->compile($env); |
| 133 | 133 | } |
| 134 | 134 | } |
@@ -142,10 +142,10 @@ discard block |
||
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | public function compile($env) { |
| 145 | - if( $this->frames ){ |
|
| 146 | - return new Less_Tree_Mixin_Definition($this->name, $this->params, $this->rules, $this->condition, $this->variadic, $this->frames ); |
|
| 145 | + if ($this->frames) { |
|
| 146 | + return new Less_Tree_Mixin_Definition($this->name, $this->params, $this->rules, $this->condition, $this->variadic, $this->frames); |
|
| 147 | 147 | } |
| 148 | - return new Less_Tree_Mixin_Definition($this->name, $this->params, $this->rules, $this->condition, $this->variadic, $env->frames ); |
|
| 148 | + return new Less_Tree_Mixin_Definition($this->name, $this->params, $this->rules, $this->condition, $this->variadic, $env->frames); |
|
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | public function evalCall($env, $args = NULL, $important = NULL) { |
@@ -154,9 +154,9 @@ discard block |
||
| 154 | 154 | |
| 155 | 155 | $_arguments = array(); |
| 156 | 156 | |
| 157 | - if( $this->frames ){ |
|
| 157 | + if ($this->frames) { |
|
| 158 | 158 | $mixinFrames = array_merge($this->frames, $env->frames); |
| 159 | - }else{ |
|
| 159 | + }else { |
|
| 160 | 160 | $mixinFrames = $env->frames; |
| 161 | 161 | } |
| 162 | 162 | |
@@ -171,10 +171,10 @@ discard block |
||
| 171 | 171 | |
| 172 | 172 | |
| 173 | 173 | $ruleSetEnv = new Less_Environment(); |
| 174 | - $ruleSetEnv->frames = array_merge( array($this, $frame), $mixinFrames ); |
|
| 175 | - $ruleset = $ruleset->compile( $ruleSetEnv ); |
|
| 174 | + $ruleSetEnv->frames = array_merge(array($this, $frame), $mixinFrames); |
|
| 175 | + $ruleset = $ruleset->compile($ruleSetEnv); |
|
| 176 | 176 | |
| 177 | - if( $important ){ |
|
| 177 | + if ($important) { |
|
| 178 | 178 | $ruleset = $ruleset->makeImportant(); |
| 179 | 179 | } |
| 180 | 180 | |
@@ -186,11 +186,11 @@ discard block |
||
| 186 | 186 | |
| 187 | 187 | public function matchCondition($args, $env) { |
| 188 | 188 | |
| 189 | - if( !$this->condition ){ |
|
| 189 | + if (!$this->condition) { |
|
| 190 | 190 | return true; |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - $frame = $this->compileParams($env, array_merge($this->frames,$env->frames), $args ); |
|
| 193 | + $frame = $this->compileParams($env, array_merge($this->frames, $env->frames), $args); |
|
| 194 | 194 | |
| 195 | 195 | $compile_env = new Less_Environment(); |
| 196 | 196 | $compile_env->frames = array_merge( |
@@ -202,27 +202,27 @@ discard block |
||
| 202 | 202 | return (bool)$this->condition->compile($compile_env); |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - public function matchArgs($args, $env = NULL){ |
|
| 205 | + public function matchArgs($args, $env = NULL) { |
|
| 206 | 206 | $argsLength = count($args); |
| 207 | 207 | |
| 208 | - if( !$this->variadic ){ |
|
| 209 | - if( $argsLength < $this->required ){ |
|
| 208 | + if (!$this->variadic) { |
|
| 209 | + if ($argsLength<$this->required) { |
|
| 210 | 210 | return false; |
| 211 | 211 | } |
| 212 | - if( $argsLength > count($this->params) ){ |
|
| 212 | + if ($argsLength>count($this->params)) { |
|
| 213 | 213 | return false; |
| 214 | 214 | } |
| 215 | - }else{ |
|
| 216 | - if( $argsLength < ($this->required - 1)){ |
|
| 215 | + }else { |
|
| 216 | + if ($argsLength<($this->required-1)) { |
|
| 217 | 217 | return false; |
| 218 | 218 | } |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | $len = min($argsLength, $this->arity); |
| 222 | 222 | |
| 223 | - for( $i = 0; $i < $len; $i++ ){ |
|
| 224 | - if( !isset($this->params[$i]['name']) && !isset($this->params[$i]['variadic']) ){ |
|
| 225 | - if( $args[$i]['value']->compile($env)->toCSS() != $this->params[$i]['value']->compile($env)->toCSS() ){ |
|
| 223 | + for ($i = 0; $i<$len; $i++) { |
|
| 224 | + if (!isset($this->params[$i]['name']) && !isset($this->params[$i]['variadic'])) { |
|
| 225 | + if ($args[$i]['value']->compile($env)->toCSS()!=$this->params[$i]['value']->compile($env)->toCSS()) { |
|
| 226 | 226 | return false; |
| 227 | 227 | } |
| 228 | 228 | } |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | } |
| 105 | 105 | $expression = new Less_Tree_Expression($varargs); |
| 106 | 106 | array_unshift($frame->rules, new Less_Tree_Rule($param['name'], $expression->compile($env))); |
| 107 | - }else{ |
|
| 107 | + } else{ |
|
| 108 | 108 | $val = ($arg && $arg['value']) ? $arg['value'] : false; |
| 109 | 109 | |
| 110 | 110 | if ($val) { |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | |
| 157 | 157 | if( $this->frames ){ |
| 158 | 158 | $mixinFrames = array_merge($this->frames, $env->frames); |
| 159 | - }else{ |
|
| 159 | + } else{ |
|
| 160 | 160 | $mixinFrames = $env->frames; |
| 161 | 161 | } |
| 162 | 162 | |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | if( $argsLength > count($this->params) ){ |
| 213 | 213 | return false; |
| 214 | 214 | } |
| 215 | - }else{ |
|
| 215 | + } else{ |
|
| 216 | 216 | if( $argsLength < ($this->required - 1)){ |
| 217 | 217 | return false; |
| 218 | 218 | } |