@@ -1,132 +1,132 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | $TYPO3_CONF_VARS['FE']['addRootLineFields'].= ',tx_realurl_pathsegment'; |
| 3 | 3 | $TYPO3_CONF_VARS['EXTCONF']['realurl']['_DEFAULT'] = array( |
| 4 | - 'pagePath' => array( |
|
| 5 | - 'type' => 'user', |
|
| 6 | - 'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main', |
|
| 7 | - 'spaceCharacter' => '-', |
|
| 8 | - 'languageGetVar' => 'L', |
|
| 9 | - 'expireDays' => '3', |
|
| 10 | - 'firstHitPathCache'=>1 |
|
| 11 | - ), |
|
| 12 | - 'init' => array( |
|
| 13 | - 'enableCHashCache' => TRUE, |
|
| 14 | - 'respectSimulateStaticURLs' => 0, |
|
| 15 | - 'appendMissingSlash' => 'ifNotFile', |
|
| 16 | - 'enableUrlDecodeCache' => TRUE, |
|
| 17 | - 'enableUrlEncodeCache' => TRUE, |
|
| 18 | - 'emptyUrlReturnValue' => \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL'), |
|
| 19 | - ), |
|
| 20 | - 'preVars' => array( |
|
| 21 | - array( |
|
| 22 | - 'GETvar' => 'L', |
|
| 23 | - 'valueMap' => array( |
|
| 24 | - 'en' => '1', |
|
| 25 | - ), |
|
| 26 | - 'noMatch' => 'bypass', |
|
| 27 | - ), |
|
| 28 | - array( |
|
| 29 | - 'GETvar' => 'no_cache', |
|
| 30 | - 'valueMap' => array( |
|
| 31 | - 'nc' => 1, |
|
| 32 | - ), |
|
| 33 | - 'noMatch' => 'bypass', |
|
| 34 | - ), |
|
| 35 | - ), |
|
| 36 | - 'fixedPostVars' => array( |
|
| 37 | - ), |
|
| 38 | - 'fileName' => array ( |
|
| 39 | - 'index' => array( |
|
| 40 | - '_DEFAULT' => array( |
|
| 41 | - 'keyValues' => array( |
|
| 42 | - ) |
|
| 43 | - ), |
|
| 44 | - 'sitemap.xml' => array( |
|
| 45 | - 'keyValues' => array( |
|
| 46 | - 'type' => 1234, |
|
| 47 | - ), |
|
| 48 | - ), |
|
| 49 | - ), |
|
| 50 | - 'defaultToHTMLsuffixOnPrev' => '.html', |
|
| 51 | - ), |
|
| 52 | - 'postVarSets' => array( |
|
| 53 | - '_DEFAULT' => array( |
|
| 54 | - 'controller' => array( |
|
| 55 | - array( |
|
| 56 | - 'GETvar' => 'tx_mooxnews_pi1[action]', |
|
| 57 | - 'noMatch' => 'bypass' |
|
| 58 | - ), |
|
| 59 | - array( |
|
| 60 | - 'GETvar' => 'tx_mooxnews_pi1[controller]', |
|
| 61 | - 'noMatch' => 'bypass' |
|
| 62 | - ) |
|
| 63 | - ), |
|
| 64 | - 'dateFilter' => array( |
|
| 65 | - array( |
|
| 66 | - 'GETvar' => 'tx_mooxnews_pi1[overwriteDemand][year]', |
|
| 67 | - ), |
|
| 68 | - array( |
|
| 69 | - 'GETvar' => 'tx_mooxnews_pi1[overwriteDemand][month]', |
|
| 70 | - ), |
|
| 71 | - ), |
|
| 72 | - 'archive' => array ( |
|
| 73 | - '0' => array ( |
|
| 74 | - 'GETvar' => 'tx_mooxnews_pi1[year]', |
|
| 75 | - ), |
|
| 76 | - '1' => array ( |
|
| 77 | - 'GETvar' => 'tx_mooxnews_pi1[month]', |
|
| 78 | - 'valueMap' => array ( |
|
| 79 | - 'january' => '01', |
|
| 80 | - 'february' => '02', |
|
| 81 | - 'march' => '03', |
|
| 82 | - 'april' => '04', |
|
| 83 | - 'may' => '05', |
|
| 84 | - 'june' => '06', |
|
| 85 | - 'july' => '07', |
|
| 86 | - 'august' => '08', |
|
| 87 | - 'september' => '09', |
|
| 88 | - 'october' => '10', |
|
| 89 | - 'november' => '11', |
|
| 90 | - 'december' => '12', |
|
| 91 | - ), |
|
| 92 | - ), |
|
| 93 | - ), |
|
| 94 | - 'browse' => array ( |
|
| 95 | - '0' => array ( |
|
| 96 | - 'GETvar' => 'tx_mooxnews_pi1[pointer]', |
|
| 97 | - ), |
|
| 98 | - ), |
|
| 99 | - 'select_category' => array ( |
|
| 100 | - '0' => array ( |
|
| 101 | - 'GETvar' => 'tx_mooxnews_pi1[cat]', |
|
| 102 | - ), |
|
| 103 | - ), |
|
| 104 | - 'article' => array ( |
|
| 105 | - '0' => array ( |
|
| 106 | - 'GETvar' => 'tx_mooxnews_pi1[news]', |
|
| 107 | - 'lookUpTable' => array ( |
|
| 108 | - 'table' => 'tx_mooxnews_domain_model_news', |
|
| 109 | - 'id_field' => 'uid', |
|
| 110 | - 'alias_field' => 'title', |
|
| 111 | - 'addWhereClause' => ' AND NOT deleted', |
|
| 112 | - 'useUniqueCache' => '1', |
|
| 113 | - 'useUniqueCache_conf' => array ( |
|
| 114 | - 'strtolower' => '1', |
|
| 115 | - 'spaceCharacter' => '-', |
|
| 116 | - ), |
|
| 117 | - ), |
|
| 118 | - ), |
|
| 119 | - '1' => array ( |
|
| 120 | - 'GETvar' => 'tx_mooxnews_pi1[swords]', |
|
| 121 | - ), |
|
| 122 | - ), |
|
| 123 | - 'page' => array( |
|
| 124 | - array( |
|
| 125 | - 'GETvar' => 'tx_mooxnews_pi1[@widget_0][currentPage]', |
|
| 126 | - ), |
|
| 127 | - ), |
|
| 128 | - ), |
|
| 129 | - ), |
|
| 4 | + 'pagePath' => array( |
|
| 5 | + 'type' => 'user', |
|
| 6 | + 'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main', |
|
| 7 | + 'spaceCharacter' => '-', |
|
| 8 | + 'languageGetVar' => 'L', |
|
| 9 | + 'expireDays' => '3', |
|
| 10 | + 'firstHitPathCache'=>1 |
|
| 11 | + ), |
|
| 12 | + 'init' => array( |
|
| 13 | + 'enableCHashCache' => TRUE, |
|
| 14 | + 'respectSimulateStaticURLs' => 0, |
|
| 15 | + 'appendMissingSlash' => 'ifNotFile', |
|
| 16 | + 'enableUrlDecodeCache' => TRUE, |
|
| 17 | + 'enableUrlEncodeCache' => TRUE, |
|
| 18 | + 'emptyUrlReturnValue' => \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL'), |
|
| 19 | + ), |
|
| 20 | + 'preVars' => array( |
|
| 21 | + array( |
|
| 22 | + 'GETvar' => 'L', |
|
| 23 | + 'valueMap' => array( |
|
| 24 | + 'en' => '1', |
|
| 25 | + ), |
|
| 26 | + 'noMatch' => 'bypass', |
|
| 27 | + ), |
|
| 28 | + array( |
|
| 29 | + 'GETvar' => 'no_cache', |
|
| 30 | + 'valueMap' => array( |
|
| 31 | + 'nc' => 1, |
|
| 32 | + ), |
|
| 33 | + 'noMatch' => 'bypass', |
|
| 34 | + ), |
|
| 35 | + ), |
|
| 36 | + 'fixedPostVars' => array( |
|
| 37 | + ), |
|
| 38 | + 'fileName' => array ( |
|
| 39 | + 'index' => array( |
|
| 40 | + '_DEFAULT' => array( |
|
| 41 | + 'keyValues' => array( |
|
| 42 | + ) |
|
| 43 | + ), |
|
| 44 | + 'sitemap.xml' => array( |
|
| 45 | + 'keyValues' => array( |
|
| 46 | + 'type' => 1234, |
|
| 47 | + ), |
|
| 48 | + ), |
|
| 49 | + ), |
|
| 50 | + 'defaultToHTMLsuffixOnPrev' => '.html', |
|
| 51 | + ), |
|
| 52 | + 'postVarSets' => array( |
|
| 53 | + '_DEFAULT' => array( |
|
| 54 | + 'controller' => array( |
|
| 55 | + array( |
|
| 56 | + 'GETvar' => 'tx_mooxnews_pi1[action]', |
|
| 57 | + 'noMatch' => 'bypass' |
|
| 58 | + ), |
|
| 59 | + array( |
|
| 60 | + 'GETvar' => 'tx_mooxnews_pi1[controller]', |
|
| 61 | + 'noMatch' => 'bypass' |
|
| 62 | + ) |
|
| 63 | + ), |
|
| 64 | + 'dateFilter' => array( |
|
| 65 | + array( |
|
| 66 | + 'GETvar' => 'tx_mooxnews_pi1[overwriteDemand][year]', |
|
| 67 | + ), |
|
| 68 | + array( |
|
| 69 | + 'GETvar' => 'tx_mooxnews_pi1[overwriteDemand][month]', |
|
| 70 | + ), |
|
| 71 | + ), |
|
| 72 | + 'archive' => array ( |
|
| 73 | + '0' => array ( |
|
| 74 | + 'GETvar' => 'tx_mooxnews_pi1[year]', |
|
| 75 | + ), |
|
| 76 | + '1' => array ( |
|
| 77 | + 'GETvar' => 'tx_mooxnews_pi1[month]', |
|
| 78 | + 'valueMap' => array ( |
|
| 79 | + 'january' => '01', |
|
| 80 | + 'february' => '02', |
|
| 81 | + 'march' => '03', |
|
| 82 | + 'april' => '04', |
|
| 83 | + 'may' => '05', |
|
| 84 | + 'june' => '06', |
|
| 85 | + 'july' => '07', |
|
| 86 | + 'august' => '08', |
|
| 87 | + 'september' => '09', |
|
| 88 | + 'october' => '10', |
|
| 89 | + 'november' => '11', |
|
| 90 | + 'december' => '12', |
|
| 91 | + ), |
|
| 92 | + ), |
|
| 93 | + ), |
|
| 94 | + 'browse' => array ( |
|
| 95 | + '0' => array ( |
|
| 96 | + 'GETvar' => 'tx_mooxnews_pi1[pointer]', |
|
| 97 | + ), |
|
| 98 | + ), |
|
| 99 | + 'select_category' => array ( |
|
| 100 | + '0' => array ( |
|
| 101 | + 'GETvar' => 'tx_mooxnews_pi1[cat]', |
|
| 102 | + ), |
|
| 103 | + ), |
|
| 104 | + 'article' => array ( |
|
| 105 | + '0' => array ( |
|
| 106 | + 'GETvar' => 'tx_mooxnews_pi1[news]', |
|
| 107 | + 'lookUpTable' => array ( |
|
| 108 | + 'table' => 'tx_mooxnews_domain_model_news', |
|
| 109 | + 'id_field' => 'uid', |
|
| 110 | + 'alias_field' => 'title', |
|
| 111 | + 'addWhereClause' => ' AND NOT deleted', |
|
| 112 | + 'useUniqueCache' => '1', |
|
| 113 | + 'useUniqueCache_conf' => array ( |
|
| 114 | + 'strtolower' => '1', |
|
| 115 | + 'spaceCharacter' => '-', |
|
| 116 | + ), |
|
| 117 | + ), |
|
| 118 | + ), |
|
| 119 | + '1' => array ( |
|
| 120 | + 'GETvar' => 'tx_mooxnews_pi1[swords]', |
|
| 121 | + ), |
|
| 122 | + ), |
|
| 123 | + 'page' => array( |
|
| 124 | + array( |
|
| 125 | + 'GETvar' => 'tx_mooxnews_pi1[@widget_0][currentPage]', |
|
| 126 | + ), |
|
| 127 | + ), |
|
| 128 | + ), |
|
| 129 | + ), |
|
| 130 | 130 | ); |
| 131 | 131 | |
| 132 | 132 | ?> |
| 133 | 133 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -$TYPO3_CONF_VARS['FE']['addRootLineFields'].= ',tx_realurl_pathsegment'; |
|
| 2 | +$TYPO3_CONF_VARS['FE']['addRootLineFields'] .= ',tx_realurl_pathsegment'; |
|
| 3 | 3 | $TYPO3_CONF_VARS['EXTCONF']['realurl']['_DEFAULT'] = array( |
| 4 | 4 | 'pagePath' => array( |
| 5 | 5 | 'type' => 'user', |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | ), |
| 36 | 36 | 'fixedPostVars' => array( |
| 37 | 37 | ), |
| 38 | - 'fileName' => array ( |
|
| 38 | + 'fileName' => array( |
|
| 39 | 39 | 'index' => array( |
| 40 | 40 | '_DEFAULT' => array( |
| 41 | 41 | 'keyValues' => array( |
@@ -69,13 +69,13 @@ discard block |
||
| 69 | 69 | 'GETvar' => 'tx_mooxnews_pi1[overwriteDemand][month]', |
| 70 | 70 | ), |
| 71 | 71 | ), |
| 72 | - 'archive' => array ( |
|
| 73 | - '0' => array ( |
|
| 72 | + 'archive' => array( |
|
| 73 | + '0' => array( |
|
| 74 | 74 | 'GETvar' => 'tx_mooxnews_pi1[year]', |
| 75 | 75 | ), |
| 76 | - '1' => array ( |
|
| 76 | + '1' => array( |
|
| 77 | 77 | 'GETvar' => 'tx_mooxnews_pi1[month]', |
| 78 | - 'valueMap' => array ( |
|
| 78 | + 'valueMap' => array( |
|
| 79 | 79 | 'january' => '01', |
| 80 | 80 | 'february' => '02', |
| 81 | 81 | 'march' => '03', |
@@ -91,32 +91,32 @@ discard block |
||
| 91 | 91 | ), |
| 92 | 92 | ), |
| 93 | 93 | ), |
| 94 | - 'browse' => array ( |
|
| 95 | - '0' => array ( |
|
| 94 | + 'browse' => array( |
|
| 95 | + '0' => array( |
|
| 96 | 96 | 'GETvar' => 'tx_mooxnews_pi1[pointer]', |
| 97 | 97 | ), |
| 98 | 98 | ), |
| 99 | - 'select_category' => array ( |
|
| 100 | - '0' => array ( |
|
| 99 | + 'select_category' => array( |
|
| 100 | + '0' => array( |
|
| 101 | 101 | 'GETvar' => 'tx_mooxnews_pi1[cat]', |
| 102 | 102 | ), |
| 103 | 103 | ), |
| 104 | - 'article' => array ( |
|
| 105 | - '0' => array ( |
|
| 104 | + 'article' => array( |
|
| 105 | + '0' => array( |
|
| 106 | 106 | 'GETvar' => 'tx_mooxnews_pi1[news]', |
| 107 | - 'lookUpTable' => array ( |
|
| 107 | + 'lookUpTable' => array( |
|
| 108 | 108 | 'table' => 'tx_mooxnews_domain_model_news', |
| 109 | 109 | 'id_field' => 'uid', |
| 110 | 110 | 'alias_field' => 'title', |
| 111 | 111 | 'addWhereClause' => ' AND NOT deleted', |
| 112 | 112 | 'useUniqueCache' => '1', |
| 113 | - 'useUniqueCache_conf' => array ( |
|
| 113 | + 'useUniqueCache_conf' => array( |
|
| 114 | 114 | 'strtolower' => '1', |
| 115 | 115 | 'spaceCharacter' => '-', |
| 116 | 116 | ), |
| 117 | 117 | ), |
| 118 | 118 | ), |
| 119 | - '1' => array ( |
|
| 119 | + '1' => array( |
|
| 120 | 120 | 'GETvar' => 'tx_mooxnews_pi1[swords]', |
| 121 | 121 | ), |
| 122 | 122 | ), |
@@ -10,6 +10,6 @@ |
||
| 10 | 10 | |
| 11 | 11 | const version = '1.7.0.2'; // The current build number of less.php |
| 12 | 12 | const less_version = '1.7'; // The less.js version that this build should be compatible with |
| 13 | - const cache_version = '170'; // The parser cache version |
|
| 13 | + const cache_version = '170'; // The parser cache version |
|
| 14 | 14 | |
| 15 | 15 | } |
| 16 | 16 | \ No newline at end of file |
@@ -6,10 +6,10 @@ |
||
| 6 | 6 | * @package Less |
| 7 | 7 | * @subpackage version |
| 8 | 8 | */ |
| 9 | -class Less_Version{ |
|
| 9 | +class Less_Version { |
|
| 10 | 10 | |
| 11 | - const version = '1.7.0.5'; // The current build number of less.php |
|
| 12 | - const less_version = '1.7'; // The less.js version that this build should be compatible with |
|
| 13 | - const cache_version = '170'; // The parser cache version |
|
| 11 | + const version = '1.7.0.5'; // The current build number of less.php |
|
| 12 | + const less_version = '1.7'; // The less.js version that this build should be compatible with |
|
| 13 | + const cache_version = '170'; // The parser cache version |
|
| 14 | 14 | |
| 15 | 15 | } |
| 16 | 16 | \ No newline at end of file |
@@ -53,7 +53,7 @@ |
||
| 53 | 53 | */ |
| 54 | 54 | public function testNoopAction($action) { |
| 55 | 55 | $instance = new CoreContentController(); |
| 56 | - $actionMethod = $action . 'Action'; |
|
| 56 | + $actionMethod = $action.'Action'; |
|
| 57 | 57 | $result = $instance->$actionMethod(); |
| 58 | 58 | $this->assertNull($result); |
| 59 | 59 | } |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | $service->expects($this->once())->method('getDefaults')->willReturn($defaults); |
| 116 | 116 | $instance->injectConfigurationService($service); |
| 117 | 117 | $result = $this->callInaccessibleMethod($instance, 'getVariant', $row); |
| 118 | - $this->assertEquals(NULL === $expected ? $defaults['variant'] : $expected, $result); |
|
| 118 | + $this->assertEquals(NULL===$expected ? $defaults['variant'] : $expected, $result); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | /** |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | $service->expects($this->once())->method('getDefaults')->willReturn($defaults); |
| 131 | 131 | $instance->injectConfigurationService($service); |
| 132 | 132 | $result = $this->callInaccessibleMethod($instance, 'getVersion', $row); |
| 133 | - $this->assertEquals(NULL === $expected ? $defaults['version'] : $expected, $result); |
|
| 133 | + $this->assertEquals(NULL===$expected ? $defaults['version'] : $expected, $result); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | /** |
@@ -1,19 +1,19 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // Register composer autoloader |
| 3 | -if (!file_exists(__DIR__ . '/../vendor/autoload.php')) { |
|
| 3 | +if (!file_exists(__DIR__.'/../vendor/autoload.php')) { |
|
| 4 | 4 | throw new \RuntimeException( |
| 5 | 5 | 'Could not find vendor/autoload.php, make sure you ran composer.' |
| 6 | 6 | ); |
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | /** @var Composer\Autoload\ClassLoader $autoloader */ |
| 10 | -$autoloader = require __DIR__ . '/../vendor/autoload.php'; |
|
| 11 | -$autoloader->addPsr4('FluidTYPO3\\FluidcontentCore\\Tests\\Fixtures\\', __DIR__ . '/Fixtures/'); |
|
| 12 | -$autoloader->addPsr4('FluidTYPO3\\FluidcontentCore\\Tests\\Unit\\', __DIR__ . '/Unit/'); |
|
| 13 | -$autoloader->addPsr4('TYPO3\\CMS\\Core\\', __DIR__ . '/../vendor/typo3/cms/typo3/sysext/core/Classes/'); |
|
| 14 | -$autoloader->addPsr4('TYPO3\\CMS\\Extbase\\', __DIR__ . '/../vendor/typo3/cms/typo3/sysext/extbase/Classes/'); |
|
| 15 | -$autoloader->addPsr4('TYPO3\\CMS\\Fluid\\', __DIR__ . '/../vendor/typo3/cms/typo3/sysext/fluid/Classes/'); |
|
| 16 | -$autoloader->addPsr4('TYPO3\\CMS\\Frontend\\', __DIR__ . '/../vendor/typo3/cms/typo3/sysext/frontend/Classes/'); |
|
| 10 | +$autoloader = require __DIR__.'/../vendor/autoload.php'; |
|
| 11 | +$autoloader->addPsr4('FluidTYPO3\\FluidcontentCore\\Tests\\Fixtures\\', __DIR__.'/Fixtures/'); |
|
| 12 | +$autoloader->addPsr4('FluidTYPO3\\FluidcontentCore\\Tests\\Unit\\', __DIR__.'/Unit/'); |
|
| 13 | +$autoloader->addPsr4('TYPO3\\CMS\\Core\\', __DIR__.'/../vendor/typo3/cms/typo3/sysext/core/Classes/'); |
|
| 14 | +$autoloader->addPsr4('TYPO3\\CMS\\Extbase\\', __DIR__.'/../vendor/typo3/cms/typo3/sysext/extbase/Classes/'); |
|
| 15 | +$autoloader->addPsr4('TYPO3\\CMS\\Fluid\\', __DIR__.'/../vendor/typo3/cms/typo3/sysext/fluid/Classes/'); |
|
| 16 | +$autoloader->addPsr4('TYPO3\\CMS\\Frontend\\', __DIR__.'/../vendor/typo3/cms/typo3/sysext/frontend/Classes/'); |
|
| 17 | 17 | |
| 18 | 18 | \FluidTYPO3\Development\Bootstrap::initialize(array( |
| 19 | 19 | 'fluid_template' => \FluidTYPO3\Development\Bootstrap::CACHE_PHP_NULL, |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -$extensionPath = PATH_site . 'typo3conf/ext/moox_core/'; |
|
| 3 | +$extensionPath = PATH_site.'typo3conf/ext/moox_core/'; |
|
| 4 | 4 | return array( |
| 5 | - 'Less_Autoloader' => $extensionPath . 'Contrib/less.php/Autoloader.php', |
|
| 5 | + 'Less_Autoloader' => $extensionPath.'Contrib/less.php/Autoloader.php', |
|
| 6 | 6 | ); |
@@ -222,6 +222,7 @@ discard block |
||
| 222 | 222 | /** |
| 223 | 223 | * Run pre-compile visitors |
| 224 | 224 | * |
| 225 | + * @param Less_Tree_Ruleset $root |
|
| 225 | 226 | */ |
| 226 | 227 | private function PreVisitors($root){ |
| 227 | 228 | |
@@ -238,6 +239,7 @@ discard block |
||
| 238 | 239 | /** |
| 239 | 240 | * Run post-compile visitors |
| 240 | 241 | * |
| 242 | + * @param Less_Tree_Ruleset $evaldRoot |
|
| 241 | 243 | */ |
| 242 | 244 | private function PostVisitors($evaldRoot){ |
| 243 | 245 | |
@@ -275,8 +277,7 @@ discard block |
||
| 275 | 277 | * Parse a Less string into css |
| 276 | 278 | * |
| 277 | 279 | * @param string $str The string to convert |
| 278 | - * @param string $uri_root The url of the file |
|
| 279 | - * @return Less_Tree_Ruleset|Less_Parser |
|
| 280 | + * @return Less_Parser |
|
| 280 | 281 | */ |
| 281 | 282 | public function parse( $str, $file_uri = null ){ |
| 282 | 283 | |
@@ -574,6 +575,7 @@ discard block |
||
| 574 | 575 | /** |
| 575 | 576 | * Set up the input buffer |
| 576 | 577 | * |
| 578 | + * @param string|null $file_path |
|
| 577 | 579 | */ |
| 578 | 580 | public function SetInput( $file_path ){ |
| 579 | 581 | |
@@ -606,6 +608,9 @@ discard block |
||
| 606 | 608 | } |
| 607 | 609 | |
| 608 | 610 | |
| 611 | + /** |
|
| 612 | + * @param string|null $file_path |
|
| 613 | + */ |
|
| 609 | 614 | public function CacheFile( $file_path ){ |
| 610 | 615 | |
| 611 | 616 | if( $file_path && $this->CacheEnabled() ){ |
@@ -661,7 +666,7 @@ discard block |
||
| 661 | 666 | /** |
| 662 | 667 | * Parse from a token, regexp or string, and move forward if match |
| 663 | 668 | * |
| 664 | - * @param array $toks |
|
| 669 | + * @param string[] $toks |
|
| 665 | 670 | * @return array |
| 666 | 671 | */ |
| 667 | 672 | private function match($toks){ |
@@ -2446,6 +2451,9 @@ discard block |
||
| 2446 | 2451 | |
| 2447 | 2452 | } |
| 2448 | 2453 | |
| 2454 | + /** |
|
| 2455 | + * @param string $re |
|
| 2456 | + */ |
|
| 2449 | 2457 | private function rulePropertyMatch( $re, &$offset, &$length, &$index, &$name ){ |
| 2450 | 2458 | preg_match($re, $this->input, $a, 0, $offset); |
| 2451 | 2459 | if( $a ){ |
@@ -2511,6 +2519,9 @@ discard block |
||
| 2511 | 2519 | return $obj; |
| 2512 | 2520 | } |
| 2513 | 2521 | |
| 2522 | + /** |
|
| 2523 | + * @param string $class |
|
| 2524 | + */ |
|
| 2514 | 2525 | public function NewObj1($class, $arg){ |
| 2515 | 2526 | $obj = new $class( $arg ); |
| 2516 | 2527 | if( $this->CacheEnabled() ){ |
@@ -2519,6 +2530,9 @@ discard block |
||
| 2519 | 2530 | return $obj; |
| 2520 | 2531 | } |
| 2521 | 2532 | |
| 2533 | + /** |
|
| 2534 | + * @param string $class |
|
| 2535 | + */ |
|
| 2522 | 2536 | public function NewObj2($class, $args){ |
| 2523 | 2537 | $obj = new $class( $args[0], $args[1] ); |
| 2524 | 2538 | if( $this->CacheEnabled() ){ |
@@ -2527,6 +2541,9 @@ discard block |
||
| 2527 | 2541 | return $obj; |
| 2528 | 2542 | } |
| 2529 | 2543 | |
| 2544 | + /** |
|
| 2545 | + * @param string $class |
|
| 2546 | + */ |
|
| 2530 | 2547 | public function NewObj3($class, $args){ |
| 2531 | 2548 | $obj = new $class( $args[0], $args[1], $args[2] ); |
| 2532 | 2549 | if( $this->CacheEnabled() ){ |
@@ -2535,6 +2552,9 @@ discard block |
||
| 2535 | 2552 | return $obj; |
| 2536 | 2553 | } |
| 2537 | 2554 | |
| 2555 | + /** |
|
| 2556 | + * @param string $class |
|
| 2557 | + */ |
|
| 2538 | 2558 | public function NewObj4($class, $args){ |
| 2539 | 2559 | $obj = new $class( $args[0], $args[1], $args[2], $args[3] ); |
| 2540 | 2560 | if( $this->CacheEnabled() ){ |
@@ -2543,6 +2563,9 @@ discard block |
||
| 2543 | 2563 | return $obj; |
| 2544 | 2564 | } |
| 2545 | 2565 | |
| 2566 | + /** |
|
| 2567 | + * @param string $class |
|
| 2568 | + */ |
|
| 2546 | 2569 | public function NewObj5($class, $args){ |
| 2547 | 2570 | $obj = new $class( $args[0], $args[1], $args[2], $args[3], $args[4] ); |
| 2548 | 2571 | if( $this->CacheEnabled() ){ |
@@ -2551,6 +2574,9 @@ discard block |
||
| 2551 | 2574 | return $obj; |
| 2552 | 2575 | } |
| 2553 | 2576 | |
| 2577 | + /** |
|
| 2578 | + * @param string $class |
|
| 2579 | + */ |
|
| 2554 | 2580 | public function NewObj6($class, $args){ |
| 2555 | 2581 | $obj = new $class( $args[0], $args[1], $args[2], $args[3], $args[4], $args[5] ); |
| 2556 | 2582 | if( $this->CacheEnabled() ){ |
@@ -2559,6 +2585,9 @@ discard block |
||
| 2559 | 2585 | return $obj; |
| 2560 | 2586 | } |
| 2561 | 2587 | |
| 2588 | + /** |
|
| 2589 | + * @param string $class |
|
| 2590 | + */ |
|
| 2562 | 2591 | public function NewObj7($class, $args){ |
| 2563 | 2592 | $obj = new $class( $args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6] ); |
| 2564 | 2593 | if( $this->CacheEnabled() ){ |
@@ -2777,11 +2806,19 @@ discard block |
||
| 2777 | 2806 | 'yellowgreen'=>'#9acd32' |
| 2778 | 2807 | ); |
| 2779 | 2808 | |
| 2809 | + /** |
|
| 2810 | + * @param string $color |
|
| 2811 | + */ |
|
| 2780 | 2812 | public static function hasOwnProperty($color) { |
| 2781 | 2813 | return isset(self::$colors[$color]); |
| 2782 | 2814 | } |
| 2783 | 2815 | |
| 2784 | 2816 | |
| 2817 | + /** |
|
| 2818 | + * @param string $color |
|
| 2819 | + * |
|
| 2820 | + * @return string |
|
| 2821 | + */ |
|
| 2785 | 2822 | public static function color($color) { |
| 2786 | 2823 | return self::$colors[$color]; |
| 2787 | 2824 | } |
@@ -3020,6 +3057,11 @@ discard block |
||
| 3020 | 3057 | } |
| 3021 | 3058 | } |
| 3022 | 3059 | |
| 3060 | + /** |
|
| 3061 | + * @param integer $r |
|
| 3062 | + * @param integer $g |
|
| 3063 | + * @param integer $b |
|
| 3064 | + */ |
|
| 3023 | 3065 | public function rgb ($r = null, $g = null, $b = null){ |
| 3024 | 3066 | if (is_null($r) || is_null($g) || is_null($b)) { |
| 3025 | 3067 | throw new Less_Exception_Compiler("rgb expects three parameters"); |
@@ -3968,6 +4010,10 @@ discard block |
||
| 3968 | 4010 | // Color Blending |
| 3969 | 4011 | // ref: http://www.w3.org/TR/compositing-1 |
| 3970 | 4012 | |
| 4013 | + /** |
|
| 4014 | + * @param Less_Tree_Color $color1 |
|
| 4015 | + * @param Less_Tree_Color $color2 |
|
| 4016 | + */ |
|
| 3971 | 4017 | public function colorBlend( $mode, $color1, $color2 ){ |
| 3972 | 4018 | $ab = $color1->alpha; // backdrop |
| 3973 | 4019 | $as = $color2->alpha; // source |
@@ -4332,6 +4378,9 @@ discard block |
||
| 4332 | 4378 | $this->_visitFnCache = array_flip($this->_visitFnCache); |
| 4333 | 4379 | } |
| 4334 | 4380 | |
| 4381 | + /** |
|
| 4382 | + * @param Less_Tree_Ruleset $node |
|
| 4383 | + */ |
|
| 4335 | 4384 | public function visitObj( $node ){ |
| 4336 | 4385 | |
| 4337 | 4386 | $funcName = 'visit'.$node->type; |
@@ -4841,6 +4890,9 @@ discard block |
||
| 4841 | 4890 | public $isTransparentKeyword; |
| 4842 | 4891 | public $type = 'Color'; |
| 4843 | 4892 | |
| 4893 | + /** |
|
| 4894 | + * @param boolean $isTransparentKeyword |
|
| 4895 | + */ |
|
| 4844 | 4896 | public function __construct($rgb, $a = 1, $isTransparentKeyword = null ){ |
| 4845 | 4897 | |
| 4846 | 4898 | if( $isTransparentKeyword ){ |
@@ -5202,10 +5254,16 @@ discard block |
||
| 5202 | 5254 | } |
| 5203 | 5255 | } |
| 5204 | 5256 | |
| 5257 | + /** |
|
| 5258 | + * @param integer $v |
|
| 5259 | + */ |
|
| 5205 | 5260 | public static function value( $v ){ |
| 5206 | 5261 | self::$value_ = $v; |
| 5207 | 5262 | } |
| 5208 | 5263 | |
| 5264 | + /** |
|
| 5265 | + * @param string $e |
|
| 5266 | + */ |
|
| 5209 | 5267 | public static function error( $e ){ |
| 5210 | 5268 | self::$error_ = $e; |
| 5211 | 5269 | } |
@@ -6001,7 +6059,6 @@ discard block |
||
| 6001 | 6059 | /** |
| 6002 | 6060 | * Using the import directories, get the full absolute path and uri of the import |
| 6003 | 6061 | * |
| 6004 | - * @param Less_Tree_Import $evald |
|
| 6005 | 6062 | */ |
| 6006 | 6063 | public function PathAndUri(){ |
| 6007 | 6064 | |
@@ -6127,6 +6184,7 @@ discard block |
||
| 6127 | 6184 | /** |
| 6128 | 6185 | * @param boolean $index |
| 6129 | 6186 | * @param boolean $escaped |
| 6187 | + * @param string[] $string |
|
| 6130 | 6188 | */ |
| 6131 | 6189 | public function __construct($string, $index, $escaped){ |
| 6132 | 6190 | $this->escaped = $escaped; |
@@ -7056,6 +7114,9 @@ discard block |
||
| 7056 | 7114 | return isset($this->_variables[$name]) ? $this->_variables[$name] : null; |
| 7057 | 7115 | } |
| 7058 | 7116 | |
| 7117 | + /** |
|
| 7118 | + * @param Less_Tree_Media $self |
|
| 7119 | + */ |
|
| 7059 | 7120 | public function find( $selector, $self = null ){ |
| 7060 | 7121 | |
| 7061 | 7122 | $key = implode(' ',$selector->_oelements); |
@@ -7803,6 +7864,9 @@ discard block |
||
| 7803 | 7864 | public $isEvald; |
| 7804 | 7865 | public $type = 'Url'; |
| 7805 | 7866 | |
| 7867 | + /** |
|
| 7868 | + * @param boolean $isEvald |
|
| 7869 | + */ |
|
| 7806 | 7870 | public function __construct($value, $currentFileInfo = null, $isEvald = null){ |
| 7807 | 7871 | $this->value = $value; |
| 7808 | 7872 | $this->currentFileInfo = $currentFileInfo; |
@@ -8315,6 +8379,9 @@ discard block |
||
| 8315 | 8379 | return new Less_Tree_Mixin_Definition($this->name, $this->params, $this->rules, $this->condition, $this->variadic, $env->frames ); |
| 8316 | 8380 | } |
| 8317 | 8381 | |
| 8382 | + /** |
|
| 8383 | + * @param boolean $important |
|
| 8384 | + */ |
|
| 8318 | 8385 | public function evalCall($env, $args = NULL, $important = NULL) { |
| 8319 | 8386 | |
| 8320 | 8387 | Less_Environment::$mixin_stack++; |
@@ -9478,6 +9545,9 @@ discard block |
||
| 9478 | 9545 | return new Less_Tree_Expression( $mapped ); |
| 9479 | 9546 | } |
| 9480 | 9547 | |
| 9548 | + /** |
|
| 9549 | + * @param Less_Tree_Expression[] $values |
|
| 9550 | + */ |
|
| 9481 | 9551 | public static function toValue($values){ |
| 9482 | 9552 | //return new Less_Tree_Value($values); ?? |
| 9483 | 9553 | |
@@ -9789,11 +9859,17 @@ discard block |
||
| 9789 | 9859 | //$this->emitChunk(true); |
| 9790 | 9860 | } |
| 9791 | 9861 | |
| 9862 | + /** |
|
| 9863 | + * @param integer $pos |
|
| 9864 | + */ |
|
| 9792 | 9865 | public function CharCode($pos){ |
| 9793 | 9866 | return ord($this->input[$pos]); |
| 9794 | 9867 | } |
| 9795 | 9868 | |
| 9796 | 9869 | |
| 9870 | + /** |
|
| 9871 | + * @param integer $index |
|
| 9872 | + */ |
|
| 9797 | 9873 | public function fail( $msg, $index = null ){ |
| 9798 | 9874 | |
| 9799 | 9875 | if( !$index ){ |
@@ -10325,7 +10401,7 @@ discard block |
||
| 10325 | 10401 | * @param integer $generatedColumn The column number in generated file |
| 10326 | 10402 | * @param integer $originalLine The line number in original file |
| 10327 | 10403 | * @param integer $originalColumn The column number in original file |
| 10328 | - * @param string $sourceFile The original source file |
|
| 10404 | + * @param string $fileInfo |
|
| 10329 | 10405 | */ |
| 10330 | 10406 | public function addMapping($generatedLine, $generatedColumn, $originalLine, $originalColumn, $fileInfo ){ |
| 10331 | 10407 | |
@@ -204,8 +204,8 @@ discard block |
||
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | } catch (Exception $exc) { |
| 207 | - // Intentional fall-through so we can reset environment |
|
| 208 | - } |
|
| 207 | + // Intentional fall-through so we can reset environment |
|
| 208 | + } |
|
| 209 | 209 | |
| 210 | 210 | //reset php settings |
| 211 | 211 | @ini_set('precision',$precision); |
@@ -213,8 +213,8 @@ discard block |
||
| 213 | 213 | |
| 214 | 214 | // Rethrow exception after we handled resetting the environment |
| 215 | 215 | if (!empty($exc)) { |
| 216 | - throw $exc; |
|
| 217 | - } |
|
| 216 | + throw $exc; |
|
| 217 | + } |
|
| 218 | 218 | |
| 219 | 219 | return $css; |
| 220 | 220 | } |
@@ -865,7 +865,7 @@ discard block |
||
| 865 | 865 | break; |
| 866 | 866 | } |
| 867 | 867 | |
| 868 | - if( $this->PeekChar('}') ){ |
|
| 868 | + if( $this->PeekChar('}') ){ |
|
| 869 | 869 | break; |
| 870 | 870 | } |
| 871 | 871 | } |
@@ -936,8 +936,8 @@ discard block |
||
| 936 | 936 | $this->MatchChar('~'); |
| 937 | 937 | } |
| 938 | 938 | |
| 939 | - // Fix for #124: match escaped newlines |
|
| 940 | - //$str = $this->MatchReg('/\\G"((?:[^"\\\\\r\n]|\\\\.)*)"|\'((?:[^\'\\\\\r\n]|\\\\.)*)\'/'); |
|
| 939 | + // Fix for #124: match escaped newlines |
|
| 940 | + //$str = $this->MatchReg('/\\G"((?:[^"\\\\\r\n]|\\\\.)*)"|\'((?:[^\'\\\\\r\n]|\\\\.)*)\'/'); |
|
| 941 | 941 | $str = $this->MatchReg('/\\G"((?:[^"\\\\\r\n]|\\\\.|\\\\\r\n|\\\\[\n\r\f])*)"|\'((?:[^\'\\\\\r\n]|\\\\.|\\\\\r\n|\\\\[\n\r\f])*)\'/'); |
| 942 | 942 | |
| 943 | 943 | if( $str ){ |
@@ -2861,8 +2861,8 @@ discard block |
||
| 2861 | 2861 | '~' => '~', |
| 2862 | 2862 | '>' => '>', |
| 2863 | 2863 | '|' => '|', |
| 2864 | - '^' => '^', |
|
| 2865 | - '^^' => '^^' |
|
| 2864 | + '^' => '^', |
|
| 2865 | + '^^' => '^^' |
|
| 2866 | 2866 | ); |
| 2867 | 2867 | |
| 2868 | 2868 | }else{ |
@@ -2877,8 +2877,8 @@ discard block |
||
| 2877 | 2877 | '~' => ' ~ ', |
| 2878 | 2878 | '>' => ' > ', |
| 2879 | 2879 | '|' => '|', |
| 2880 | - '^' => ' ^ ', |
|
| 2881 | - '^^' => ' ^^ ' |
|
| 2880 | + '^' => ' ^ ', |
|
| 2881 | + '^^' => ' ^^ ' |
|
| 2882 | 2882 | ); |
| 2883 | 2883 | |
| 2884 | 2884 | } |
@@ -2975,7 +2975,7 @@ discard block |
||
| 2975 | 2975 | /** |
| 2976 | 2976 | * @param string $op |
| 2977 | 2977 | */ |
| 2978 | - public static function operate( $op, $a, $b ){ |
|
| 2978 | + public static function operate( $op, $a, $b ){ |
|
| 2979 | 2979 | switch ($op) { |
| 2980 | 2980 | case '+': return $a + $b; |
| 2981 | 2981 | case '-': return $a - $b; |
@@ -3001,7 +3001,7 @@ discard block |
||
| 3001 | 3001 | return $value; |
| 3002 | 3002 | } |
| 3003 | 3003 | |
| 3004 | - public static function number($n){ |
|
| 3004 | + public static function number($n){ |
|
| 3005 | 3005 | |
| 3006 | 3006 | if ($n instanceof Less_Tree_Dimension) { |
| 3007 | 3007 | return floatval( $n->unit->is('%') ? $n->value / 100 : $n->value); |
@@ -3012,7 +3012,7 @@ discard block |
||
| 3012 | 3012 | } |
| 3013 | 3013 | } |
| 3014 | 3014 | |
| 3015 | - public static function scaled($n, $size = 255 ){ |
|
| 3015 | + public static function scaled($n, $size = 255 ){ |
|
| 3016 | 3016 | if( $n instanceof Less_Tree_Dimension && $n->unit->is('%') ){ |
| 3017 | 3017 | return (float)$n->value * $size / 100; |
| 3018 | 3018 | } else { |
@@ -3504,7 +3504,7 @@ discard block |
||
| 3504 | 3504 | return new Less_Tree_Quoted( $string->quote , $result, $string->escaped); |
| 3505 | 3505 | } |
| 3506 | 3506 | |
| 3507 | - public function unit( $val, $unit = null) { |
|
| 3507 | + public function unit( $val, $unit = null) { |
|
| 3508 | 3508 | if( !($val instanceof Less_Tree_Dimension) ){ |
| 3509 | 3509 | throw new Less_Exception_Compiler('The first argument to unit must be a number' . ($val instanceof Less_Tree_Operation ? '. Have you forgotten parenthesis?' : '.') ); |
| 3510 | 3510 | } |
@@ -3519,7 +3519,7 @@ discard block |
||
| 3519 | 3519 | $unit = ""; |
| 3520 | 3520 | } |
| 3521 | 3521 | return new Less_Tree_Dimension($val->value, $unit ); |
| 3522 | - } |
|
| 3522 | + } |
|
| 3523 | 3523 | |
| 3524 | 3524 | public function convert($val, $unit){ |
| 3525 | 3525 | return $val->convertTo($unit->value); |
@@ -4149,18 +4149,18 @@ discard block |
||
| 4149 | 4149 | // this map is intentionally incomplete |
| 4150 | 4150 | // if you want more, install 'mime' dep |
| 4151 | 4151 | static $_types = array( |
| 4152 | - '.htm' => 'text/html', |
|
| 4153 | - '.html'=> 'text/html', |
|
| 4154 | - '.gif' => 'image/gif', |
|
| 4155 | - '.jpg' => 'image/jpeg', |
|
| 4156 | - '.jpeg'=> 'image/jpeg', |
|
| 4157 | - '.png' => 'image/png', |
|
| 4158 | - '.ttf' => 'application/x-font-ttf', |
|
| 4159 | - '.otf' => 'application/x-font-otf', |
|
| 4160 | - '.eot' => 'application/vnd.ms-fontobject', |
|
| 4161 | - '.woff' => 'application/x-font-woff', |
|
| 4162 | - '.svg' => 'image/svg+xml', |
|
| 4163 | - ); |
|
| 4152 | + '.htm' => 'text/html', |
|
| 4153 | + '.html'=> 'text/html', |
|
| 4154 | + '.gif' => 'image/gif', |
|
| 4155 | + '.jpg' => 'image/jpeg', |
|
| 4156 | + '.jpeg'=> 'image/jpeg', |
|
| 4157 | + '.png' => 'image/png', |
|
| 4158 | + '.ttf' => 'application/x-font-ttf', |
|
| 4159 | + '.otf' => 'application/x-font-otf', |
|
| 4160 | + '.eot' => 'application/vnd.ms-fontobject', |
|
| 4161 | + '.woff' => 'application/x-font-woff', |
|
| 4162 | + '.svg' => 'image/svg+xml', |
|
| 4163 | + ); |
|
| 4164 | 4164 | |
| 4165 | 4165 | public static function lookup( $filepath ){ |
| 4166 | 4166 | $parts = explode('.',$filepath); |
@@ -4196,13 +4196,13 @@ discard block |
||
| 4196 | 4196 | } |
| 4197 | 4197 | |
| 4198 | 4198 | |
| 4199 | - /** |
|
| 4200 | - * Generate CSS by adding it to the output object |
|
| 4201 | - * |
|
| 4202 | - * @param Less_Output $output The output |
|
| 4203 | - * @return void |
|
| 4204 | - */ |
|
| 4205 | - public function genCSS($output){} |
|
| 4199 | + /** |
|
| 4200 | + * Generate CSS by adding it to the output object |
|
| 4201 | + * |
|
| 4202 | + * @param Less_Output $output The output |
|
| 4203 | + * @return void |
|
| 4204 | + */ |
|
| 4205 | + public function genCSS($output){} |
|
| 4206 | 4206 | |
| 4207 | 4207 | |
| 4208 | 4208 | /** |
@@ -4535,9 +4535,9 @@ discard block |
||
| 4535 | 4535 | return $this; |
| 4536 | 4536 | } |
| 4537 | 4537 | |
| 4538 | - /** |
|
| 4539 | - * @see Less_Tree::genCSS |
|
| 4540 | - */ |
|
| 4538 | + /** |
|
| 4539 | + * @see Less_Tree::genCSS |
|
| 4540 | + */ |
|
| 4541 | 4541 | public function genCSS( $output ){ |
| 4542 | 4542 | |
| 4543 | 4543 | $output->add( "alpha(opacity=" ); |
@@ -4587,7 +4587,7 @@ discard block |
||
| 4587 | 4587 | return new Less_Tree_Anonymous($this->value, $this->index, $this->currentFileInfo, $this->mapLines); |
| 4588 | 4588 | } |
| 4589 | 4589 | |
| 4590 | - public function compare($x){ |
|
| 4590 | + public function compare($x){ |
|
| 4591 | 4591 | if( !is_object($x) ){ |
| 4592 | 4592 | return -1; |
| 4593 | 4593 | } |
@@ -4602,9 +4602,9 @@ discard block |
||
| 4602 | 4602 | return $left < $right ? -1 : 1; |
| 4603 | 4603 | } |
| 4604 | 4604 | |
| 4605 | - /** |
|
| 4606 | - * @see Less_Tree::genCSS |
|
| 4607 | - */ |
|
| 4605 | + /** |
|
| 4606 | + * @see Less_Tree::genCSS |
|
| 4607 | + */ |
|
| 4608 | 4608 | public function genCSS( $output ){ |
| 4609 | 4609 | $output->add( $this->value, $this->currentFileInfo, $this->index, $this->mapLines ); |
| 4610 | 4610 | } |
@@ -4628,12 +4628,12 @@ discard block |
||
| 4628 | 4628 | public $value; |
| 4629 | 4629 | public $type = 'Assignment'; |
| 4630 | 4630 | |
| 4631 | - public function __construct($key, $val) { |
|
| 4631 | + public function __construct($key, $val) { |
|
| 4632 | 4632 | $this->key = $key; |
| 4633 | 4633 | $this->value = $val; |
| 4634 | 4634 | } |
| 4635 | 4635 | |
| 4636 | - public function accept( $visitor ){ |
|
| 4636 | + public function accept( $visitor ){ |
|
| 4637 | 4637 | $this->value = $visitor->visitObj( $this->value ); |
| 4638 | 4638 | } |
| 4639 | 4639 | |
@@ -4641,9 +4641,9 @@ discard block |
||
| 4641 | 4641 | return new Less_Tree_Assignment( $this->key, $this->value->compile($env)); |
| 4642 | 4642 | } |
| 4643 | 4643 | |
| 4644 | - /** |
|
| 4645 | - * @see Less_Tree::genCSS |
|
| 4646 | - */ |
|
| 4644 | + /** |
|
| 4645 | + * @see Less_Tree::genCSS |
|
| 4646 | + */ |
|
| 4647 | 4647 | public function genCSS( $output ){ |
| 4648 | 4648 | $output->add( $this->key . '=' ); |
| 4649 | 4649 | $this->value->genCSS( $output ); |
@@ -4668,13 +4668,13 @@ discard block |
||
| 4668 | 4668 | public $value; |
| 4669 | 4669 | public $type = 'Attribute'; |
| 4670 | 4670 | |
| 4671 | - public function __construct($key, $op, $value){ |
|
| 4671 | + public function __construct($key, $op, $value){ |
|
| 4672 | 4672 | $this->key = $key; |
| 4673 | 4673 | $this->op = $op; |
| 4674 | 4674 | $this->value = $value; |
| 4675 | 4675 | } |
| 4676 | 4676 | |
| 4677 | - public function compile($env){ |
|
| 4677 | + public function compile($env){ |
|
| 4678 | 4678 | |
| 4679 | 4679 | $key_obj = is_object($this->key); |
| 4680 | 4680 | $val_obj = is_object($this->value); |
@@ -4689,14 +4689,14 @@ discard block |
||
| 4689 | 4689 | $val_obj ? $this->value->compile($env) : $this->value); |
| 4690 | 4690 | } |
| 4691 | 4691 | |
| 4692 | - /** |
|
| 4693 | - * @see Less_Tree::genCSS |
|
| 4694 | - */ |
|
| 4695 | - public function genCSS( $output ){ |
|
| 4692 | + /** |
|
| 4693 | + * @see Less_Tree::genCSS |
|
| 4694 | + */ |
|
| 4695 | + public function genCSS( $output ){ |
|
| 4696 | 4696 | $output->add( $this->toCSS() ); |
| 4697 | 4697 | } |
| 4698 | 4698 | |
| 4699 | - public function toCSS(){ |
|
| 4699 | + public function toCSS(){ |
|
| 4700 | 4700 | $value = $this->key; |
| 4701 | 4701 | |
| 4702 | 4702 | if( $this->op ){ |
@@ -4716,13 +4716,13 @@ discard block |
||
| 4716 | 4716 | * @subpackage tree |
| 4717 | 4717 | */ |
| 4718 | 4718 | class Less_Tree_Call extends Less_Tree{ |
| 4719 | - public $value; |
|
| 4719 | + public $value; |
|
| 4720 | 4720 | |
| 4721 | - protected $name; |
|
| 4722 | - protected $args; |
|
| 4723 | - protected $index; |
|
| 4724 | - protected $currentFileInfo; |
|
| 4725 | - public $type = 'Call'; |
|
| 4721 | + protected $name; |
|
| 4722 | + protected $args; |
|
| 4723 | + protected $index; |
|
| 4724 | + protected $currentFileInfo; |
|
| 4725 | + public $type = 'Call'; |
|
| 4726 | 4726 | |
| 4727 | 4727 | public function __construct($name, $args, $index, $currentFileInfo = null ){ |
| 4728 | 4728 | $this->name = $name; |
@@ -4731,23 +4731,23 @@ discard block |
||
| 4731 | 4731 | $this->currentFileInfo = $currentFileInfo; |
| 4732 | 4732 | } |
| 4733 | 4733 | |
| 4734 | - public function accept( $visitor ){ |
|
| 4734 | + public function accept( $visitor ){ |
|
| 4735 | 4735 | $this->args = $visitor->visitArray( $this->args ); |
| 4736 | 4736 | } |
| 4737 | 4737 | |
| 4738 | - // |
|
| 4739 | - // When evaluating a function call, |
|
| 4740 | - // we either find the function in `tree.functions` [1], |
|
| 4741 | - // in which case we call it, passing the evaluated arguments, |
|
| 4742 | - // or we simply print it out as it appeared originally [2]. |
|
| 4743 | - // |
|
| 4744 | - // The *functions.js* file contains the built-in functions. |
|
| 4745 | - // |
|
| 4746 | - // The reason why we evaluate the arguments, is in the case where |
|
| 4747 | - // we try to pass a variable to a function, like: `saturate(@color)`. |
|
| 4748 | - // The function should receive the value, not the variable. |
|
| 4749 | - // |
|
| 4750 | - public function compile($env=null){ |
|
| 4738 | + // |
|
| 4739 | + // When evaluating a function call, |
|
| 4740 | + // we either find the function in `tree.functions` [1], |
|
| 4741 | + // in which case we call it, passing the evaluated arguments, |
|
| 4742 | + // or we simply print it out as it appeared originally [2]. |
|
| 4743 | + // |
|
| 4744 | + // The *functions.js* file contains the built-in functions. |
|
| 4745 | + // |
|
| 4746 | + // The reason why we evaluate the arguments, is in the case where |
|
| 4747 | + // we try to pass a variable to a function, like: `saturate(@color)`. |
|
| 4748 | + // The function should receive the value, not the variable. |
|
| 4749 | + // |
|
| 4750 | + public function compile($env=null){ |
|
| 4751 | 4751 | $args = array(); |
| 4752 | 4752 | foreach($this->args as $a){ |
| 4753 | 4753 | $args[] = $a->compile($env); |
@@ -4802,11 +4802,11 @@ discard block |
||
| 4802 | 4802 | |
| 4803 | 4803 | |
| 4804 | 4804 | return new Less_Tree_Call( $this->name, $args, $this->index, $this->currentFileInfo ); |
| 4805 | - } |
|
| 4805 | + } |
|
| 4806 | 4806 | |
| 4807 | - /** |
|
| 4808 | - * @see Less_Tree::genCSS |
|
| 4809 | - */ |
|
| 4807 | + /** |
|
| 4808 | + * @see Less_Tree::genCSS |
|
| 4809 | + */ |
|
| 4810 | 4810 | public function genCSS( $output ){ |
| 4811 | 4811 | |
| 4812 | 4812 | $output->add( $this->name . '(', $this->currentFileInfo, $this->index ); |
@@ -4822,9 +4822,9 @@ discard block |
||
| 4822 | 4822 | } |
| 4823 | 4823 | |
| 4824 | 4824 | |
| 4825 | - //public function toCSS(){ |
|
| 4826 | - // return $this->compile()->toCSS(); |
|
| 4827 | - //} |
|
| 4825 | + //public function toCSS(){ |
|
| 4826 | + // return $this->compile()->toCSS(); |
|
| 4827 | + //} |
|
| 4828 | 4828 | |
| 4829 | 4829 | } |
| 4830 | 4830 | |
@@ -4977,7 +4977,7 @@ discard block |
||
| 4977 | 4977 | } |
| 4978 | 4978 | |
| 4979 | 4979 | //Adapted from http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript |
| 4980 | - public function toHSV() { |
|
| 4980 | + public function toHSV() { |
|
| 4981 | 4981 | $r = $this->rgb[0] / 255; |
| 4982 | 4982 | $g = $this->rgb[1] / 255; |
| 4983 | 4983 | $b = $this->rgb[2] / 255; |
@@ -5025,7 +5025,7 @@ discard block |
||
| 5025 | 5025 | $x->alpha === $this->alpha) ? 0 : -1; |
| 5026 | 5026 | } |
| 5027 | 5027 | |
| 5028 | - public function toHex( $v ){ |
|
| 5028 | + public function toHex( $v ){ |
|
| 5029 | 5029 | |
| 5030 | 5030 | $ret = '#'; |
| 5031 | 5031 | foreach($v as $c){ |
@@ -5079,9 +5079,9 @@ discard block |
||
| 5079 | 5079 | $this->currentFileInfo = $currentFileInfo; |
| 5080 | 5080 | } |
| 5081 | 5081 | |
| 5082 | - /** |
|
| 5083 | - * @see Less_Tree::genCSS |
|
| 5084 | - */ |
|
| 5082 | + /** |
|
| 5083 | + * @see Less_Tree::genCSS |
|
| 5084 | + */ |
|
| 5085 | 5085 | public function genCSS( $output ){ |
| 5086 | 5086 | //if( $this->debugInfo ){ |
| 5087 | 5087 | //$output->add( tree.debugInfo($env, $this), $this->currentFileInfo, $this->index); |
@@ -5138,7 +5138,7 @@ discard block |
||
| 5138 | 5138 | $this->rvalue = $visitor->visitObj( $this->rvalue ); |
| 5139 | 5139 | } |
| 5140 | 5140 | |
| 5141 | - public function compile($env) { |
|
| 5141 | + public function compile($env) { |
|
| 5142 | 5142 | $a = $this->lvalue->compile($env); |
| 5143 | 5143 | $b = $this->rvalue->compile($env); |
| 5144 | 5144 | |
@@ -5177,7 +5177,7 @@ discard block |
||
| 5177 | 5177 | } |
| 5178 | 5178 | |
| 5179 | 5179 | return $this->negate ? !$result : $result; |
| 5180 | - } |
|
| 5180 | + } |
|
| 5181 | 5181 | |
| 5182 | 5182 | } |
| 5183 | 5183 | |
@@ -5193,7 +5193,7 @@ discard block |
||
| 5193 | 5193 | static $error_; |
| 5194 | 5194 | static $value_; |
| 5195 | 5195 | |
| 5196 | - public static function compile(){ |
|
| 5196 | + public static function compile(){ |
|
| 5197 | 5197 | if( self::$error_ ){ |
| 5198 | 5198 | throw new Exception(self::$error_); |
| 5199 | 5199 | } |
@@ -5202,15 +5202,15 @@ discard block |
||
| 5202 | 5202 | } |
| 5203 | 5203 | } |
| 5204 | 5204 | |
| 5205 | - public static function value( $v ){ |
|
| 5205 | + public static function value( $v ){ |
|
| 5206 | 5206 | self::$value_ = $v; |
| 5207 | 5207 | } |
| 5208 | 5208 | |
| 5209 | - public static function error( $e ){ |
|
| 5209 | + public static function error( $e ){ |
|
| 5210 | 5210 | self::$error_ = $e; |
| 5211 | 5211 | } |
| 5212 | 5212 | |
| 5213 | - public static function reset(){ |
|
| 5213 | + public static function reset(){ |
|
| 5214 | 5214 | self::$value_ = self::$error_ = null; |
| 5215 | 5215 | } |
| 5216 | 5216 | } |
@@ -5227,16 +5227,16 @@ discard block |
||
| 5227 | 5227 | public $frames; |
| 5228 | 5228 | public $type = 'DetachedRuleset'; |
| 5229 | 5229 | |
| 5230 | - public function __construct( $ruleset, $frames = null ){ |
|
| 5230 | + public function __construct( $ruleset, $frames = null ){ |
|
| 5231 | 5231 | $this->ruleset = $ruleset; |
| 5232 | 5232 | $this->frames = $frames; |
| 5233 | 5233 | } |
| 5234 | 5234 | |
| 5235 | - public function accept($visitor) { |
|
| 5235 | + public function accept($visitor) { |
|
| 5236 | 5236 | $this->ruleset = $visitor->visitObj($this->ruleset); |
| 5237 | 5237 | } |
| 5238 | 5238 | |
| 5239 | - public function compile($env){ |
|
| 5239 | + public function compile($env){ |
|
| 5240 | 5240 | if( $this->frames ){ |
| 5241 | 5241 | $frames = $this->frames; |
| 5242 | 5242 | }else{ |
@@ -5245,7 +5245,7 @@ discard block |
||
| 5245 | 5245 | return new Less_Tree_DetachedRuleset($this->ruleset, $frames); |
| 5246 | 5246 | } |
| 5247 | 5247 | |
| 5248 | - public function callEval($env) { |
|
| 5248 | + public function callEval($env) { |
|
| 5249 | 5249 | if( $this->frames ){ |
| 5250 | 5250 | return $this->ruleset->compile( $env->copyEvalEnv( array_merge($this->frames,$env->frames) ) ); |
| 5251 | 5251 | } |
@@ -5267,8 +5267,8 @@ discard block |
||
| 5267 | 5267 | public $unit; |
| 5268 | 5268 | public $type = 'Dimension'; |
| 5269 | 5269 | |
| 5270 | - public function __construct($value, $unit = null){ |
|
| 5271 | - $this->value = floatval($value); |
|
| 5270 | + public function __construct($value, $unit = null){ |
|
| 5271 | + $this->value = floatval($value); |
|
| 5272 | 5272 | |
| 5273 | 5273 | if( $unit && ($unit instanceof Less_Tree_Unit) ){ |
| 5274 | 5274 | $this->unit = $unit; |
@@ -5277,23 +5277,23 @@ discard block |
||
| 5277 | 5277 | }else{ |
| 5278 | 5278 | $this->unit = new Less_Tree_Unit( ); |
| 5279 | 5279 | } |
| 5280 | - } |
|
| 5280 | + } |
|
| 5281 | 5281 | |
| 5282 | - public function accept( $visitor ){ |
|
| 5282 | + public function accept( $visitor ){ |
|
| 5283 | 5283 | $this->unit = $visitor->visitObj( $this->unit ); |
| 5284 | 5284 | } |
| 5285 | 5285 | |
| 5286 | - public function compile(){ |
|
| 5287 | - return $this; |
|
| 5288 | - } |
|
| 5286 | + public function compile(){ |
|
| 5287 | + return $this; |
|
| 5288 | + } |
|
| 5289 | 5289 | |
| 5290 | - public function toColor() { |
|
| 5291 | - return new Less_Tree_Color(array($this->value, $this->value, $this->value)); |
|
| 5292 | - } |
|
| 5290 | + public function toColor() { |
|
| 5291 | + return new Less_Tree_Color(array($this->value, $this->value, $this->value)); |
|
| 5292 | + } |
|
| 5293 | 5293 | |
| 5294 | - /** |
|
| 5295 | - * @see Less_Tree::genCSS |
|
| 5296 | - */ |
|
| 5294 | + /** |
|
| 5295 | + * @see Less_Tree::genCSS |
|
| 5296 | + */ |
|
| 5297 | 5297 | public function genCSS( $output ){ |
| 5298 | 5298 | |
| 5299 | 5299 | if( Less_Parser::$options['strictUnits'] && !$this->unit->isSingular() ){ |
@@ -5326,18 +5326,18 @@ discard block |
||
| 5326 | 5326 | $this->unit->genCSS( $output ); |
| 5327 | 5327 | } |
| 5328 | 5328 | |
| 5329 | - public function __toString(){ |
|
| 5330 | - return $this->toCSS(); |
|
| 5331 | - } |
|
| 5329 | + public function __toString(){ |
|
| 5330 | + return $this->toCSS(); |
|
| 5331 | + } |
|
| 5332 | 5332 | |
| 5333 | - // In an operation between two Dimensions, |
|
| 5334 | - // we default to the first Dimension's unit, |
|
| 5335 | - // so `1px + 2em` will yield `3px`. |
|
| 5333 | + // In an operation between two Dimensions, |
|
| 5334 | + // we default to the first Dimension's unit, |
|
| 5335 | + // so `1px + 2em` will yield `3px`. |
|
| 5336 | 5336 | |
| 5337 | - /** |
|
| 5338 | - * @param string $op |
|
| 5339 | - */ |
|
| 5340 | - public function operate( $op, $other){ |
|
| 5337 | + /** |
|
| 5338 | + * @param string $op |
|
| 5339 | + */ |
|
| 5340 | + public function operate( $op, $other){ |
|
| 5341 | 5341 | |
| 5342 | 5342 | $value = Less_Functions::operate( $op, $this->value, $other->value); |
| 5343 | 5343 | $unit = clone $this->unit; |
@@ -5372,7 +5372,7 @@ discard block |
||
| 5372 | 5372 | $unit->cancel(); |
| 5373 | 5373 | } |
| 5374 | 5374 | return new Less_Tree_Dimension( $value, $unit); |
| 5375 | - } |
|
| 5375 | + } |
|
| 5376 | 5376 | |
| 5377 | 5377 | public function compare($other) { |
| 5378 | 5378 | if ($other instanceof Less_Tree_Dimension) { |
@@ -5402,11 +5402,11 @@ discard block |
||
| 5402 | 5402 | } |
| 5403 | 5403 | } |
| 5404 | 5404 | |
| 5405 | - public function unify() { |
|
| 5405 | + public function unify() { |
|
| 5406 | 5406 | return $this->convertTo(array('length'=> 'px', 'duration'=> 's', 'angle' => 'rad' )); |
| 5407 | 5407 | } |
| 5408 | 5408 | |
| 5409 | - public function convertTo($conversions) { |
|
| 5409 | + public function convertTo($conversions) { |
|
| 5410 | 5410 | $value = $this->value; |
| 5411 | 5411 | $unit = clone $this->unit; |
| 5412 | 5412 | |
@@ -5452,7 +5452,7 @@ discard block |
||
| 5452 | 5452 | $unit->cancel(); |
| 5453 | 5453 | |
| 5454 | 5454 | return new Less_Tree_Dimension( $value, $unit); |
| 5455 | - } |
|
| 5455 | + } |
|
| 5456 | 5456 | } |
| 5457 | 5457 | |
| 5458 | 5458 | |
@@ -5487,7 +5487,7 @@ discard block |
||
| 5487 | 5487 | } |
| 5488 | 5488 | |
| 5489 | 5489 | |
| 5490 | - public function accept( $visitor ){ |
|
| 5490 | + public function accept( $visitor ){ |
|
| 5491 | 5491 | if( $this->rules ){ |
| 5492 | 5492 | $this->rules = $visitor->visitObj( $this->rules ); |
| 5493 | 5493 | } |
@@ -5497,10 +5497,10 @@ discard block |
||
| 5497 | 5497 | } |
| 5498 | 5498 | |
| 5499 | 5499 | |
| 5500 | - /** |
|
| 5501 | - * @see Less_Tree::genCSS |
|
| 5502 | - */ |
|
| 5503 | - public function genCSS( $output ){ |
|
| 5500 | + /** |
|
| 5501 | + * @see Less_Tree::genCSS |
|
| 5502 | + */ |
|
| 5503 | + public function genCSS( $output ){ |
|
| 5504 | 5504 | $value = $this->value; |
| 5505 | 5505 | $rules = $this->rules; |
| 5506 | 5506 | $output->add( $this->name, $this->currentFileInfo, $this->index ); |
@@ -5585,7 +5585,7 @@ discard block |
||
| 5585 | 5585 | $this->currentFileInfo = $currentFileInfo; |
| 5586 | 5586 | } |
| 5587 | 5587 | |
| 5588 | - public function accept( $visitor ){ |
|
| 5588 | + public function accept( $visitor ){ |
|
| 5589 | 5589 | if( $this->value_is_object ){ //object or string |
| 5590 | 5590 | $this->value = $visitor->visitObj( $this->value ); |
| 5591 | 5591 | } |
@@ -5604,9 +5604,9 @@ discard block |
||
| 5604 | 5604 | return $this; |
| 5605 | 5605 | } |
| 5606 | 5606 | |
| 5607 | - /** |
|
| 5608 | - * @see Less_Tree::genCSS |
|
| 5609 | - */ |
|
| 5607 | + /** |
|
| 5608 | + * @see Less_Tree::genCSS |
|
| 5609 | + */ |
|
| 5610 | 5610 | public function genCSS( $output ){ |
| 5611 | 5611 | $output->add( $this->toCSS(), $this->currentFileInfo, $this->index ); |
| 5612 | 5612 | } |
@@ -5649,7 +5649,7 @@ discard block |
||
| 5649 | 5649 | $this->parens = $parens; |
| 5650 | 5650 | } |
| 5651 | 5651 | |
| 5652 | - public function accept( $visitor ){ |
|
| 5652 | + public function accept( $visitor ){ |
|
| 5653 | 5653 | $this->value = $visitor->visitArray( $this->value ); |
| 5654 | 5654 | } |
| 5655 | 5655 | |
@@ -5699,10 +5699,10 @@ discard block |
||
| 5699 | 5699 | return $returnValue; |
| 5700 | 5700 | } |
| 5701 | 5701 | |
| 5702 | - /** |
|
| 5703 | - * @see Less_Tree::genCSS |
|
| 5704 | - */ |
|
| 5705 | - public function genCSS( $output ){ |
|
| 5702 | + /** |
|
| 5703 | + * @see Less_Tree::genCSS |
|
| 5704 | + */ |
|
| 5705 | + public function genCSS( $output ){ |
|
| 5706 | 5706 | $val_len = count($this->value); |
| 5707 | 5707 | for( $i = 0; $i < $val_len; $i++ ){ |
| 5708 | 5708 | $this->value[$i]->genCSS( $output ); |
@@ -5712,7 +5712,7 @@ discard block |
||
| 5712 | 5712 | } |
| 5713 | 5713 | } |
| 5714 | 5714 | |
| 5715 | - public function throwAwayComments() { |
|
| 5715 | + public function throwAwayComments() { |
|
| 5716 | 5716 | |
| 5717 | 5717 | if( is_array($this->value) ){ |
| 5718 | 5718 | $new_value = array(); |
@@ -5753,7 +5753,7 @@ discard block |
||
| 5753 | 5753 | /** |
| 5754 | 5754 | * @param integer $index |
| 5755 | 5755 | */ |
| 5756 | - public function __construct($selector, $option, $index){ |
|
| 5756 | + public function __construct($selector, $option, $index){ |
|
| 5757 | 5757 | static $i = 0; |
| 5758 | 5758 | $this->selector = $selector; |
| 5759 | 5759 | $this->option = $option; |
@@ -5774,18 +5774,18 @@ discard block |
||
| 5774 | 5774 | $this->parent_ids = array($this->object_id); |
| 5775 | 5775 | } |
| 5776 | 5776 | |
| 5777 | - public function accept( $visitor ){ |
|
| 5777 | + public function accept( $visitor ){ |
|
| 5778 | 5778 | $this->selector = $visitor->visitObj( $this->selector ); |
| 5779 | 5779 | } |
| 5780 | 5780 | |
| 5781 | - public function compile( $env ){ |
|
| 5781 | + public function compile( $env ){ |
|
| 5782 | 5782 | Less_Parser::$has_extends = true; |
| 5783 | 5783 | $this->selector = $this->selector->compile($env); |
| 5784 | 5784 | return $this; |
| 5785 | 5785 | //return new Less_Tree_Extend( $this->selector->compile($env), $this->option, $this->index); |
| 5786 | 5786 | } |
| 5787 | 5787 | |
| 5788 | - public function findSelfSelectors( $selectors ){ |
|
| 5788 | + public function findSelfSelectors( $selectors ){ |
|
| 5789 | 5789 | $selfElements = array(); |
| 5790 | 5790 | |
| 5791 | 5791 | |
@@ -5831,7 +5831,7 @@ discard block |
||
| 5831 | 5831 | public $root; |
| 5832 | 5832 | public $type = 'Import'; |
| 5833 | 5833 | |
| 5834 | - public function __construct($path, $features, $options, $index, $currentFileInfo = null ){ |
|
| 5834 | + public function __construct($path, $features, $options, $index, $currentFileInfo = null ){ |
|
| 5835 | 5835 | $this->options = $options; |
| 5836 | 5836 | $this->index = $index; |
| 5837 | 5837 | $this->path = $path; |
@@ -5862,7 +5862,7 @@ discard block |
||
| 5862 | 5862 | // ruleset. |
| 5863 | 5863 | // |
| 5864 | 5864 | |
| 5865 | - public function accept($visitor){ |
|
| 5865 | + public function accept($visitor){ |
|
| 5866 | 5866 | |
| 5867 | 5867 | if( $this->features ){ |
| 5868 | 5868 | $this->features = $visitor->visitObj($this->features); |
@@ -5874,10 +5874,10 @@ discard block |
||
| 5874 | 5874 | } |
| 5875 | 5875 | } |
| 5876 | 5876 | |
| 5877 | - /** |
|
| 5878 | - * @see Less_Tree::genCSS |
|
| 5879 | - */ |
|
| 5880 | - public function genCSS( $output ){ |
|
| 5877 | + /** |
|
| 5878 | + * @see Less_Tree::genCSS |
|
| 5879 | + */ |
|
| 5880 | + public function genCSS( $output ){ |
|
| 5881 | 5881 | if( $this->css ){ |
| 5882 | 5882 | |
| 5883 | 5883 | $output->add( '@import ', $this->currentFileInfo, $this->index ); |
@@ -5891,7 +5891,7 @@ discard block |
||
| 5891 | 5891 | } |
| 5892 | 5892 | } |
| 5893 | 5893 | |
| 5894 | - public function toCSS(){ |
|
| 5894 | + public function toCSS(){ |
|
| 5895 | 5895 | $features = $this->features ? ' ' . $this->features->toCSS() : ''; |
| 5896 | 5896 | |
| 5897 | 5897 | if ($this->css) { |
@@ -5904,7 +5904,7 @@ discard block |
||
| 5904 | 5904 | /** |
| 5905 | 5905 | * @return string |
| 5906 | 5906 | */ |
| 5907 | - public function getPath(){ |
|
| 5907 | + public function getPath(){ |
|
| 5908 | 5908 | if ($this->path instanceof Less_Tree_Quoted) { |
| 5909 | 5909 | $path = $this->path->value; |
| 5910 | 5910 | $path = ( isset($this->css) || preg_match('/(\.[a-z]*$)|([\?;].*)$/',$path)) ? $path : $path . '.less'; |
@@ -5918,11 +5918,11 @@ discard block |
||
| 5918 | 5918 | return preg_replace('/[\?#][^\?]*$/','',$path); |
| 5919 | 5919 | } |
| 5920 | 5920 | |
| 5921 | - public function compileForImport( $env ){ |
|
| 5921 | + public function compileForImport( $env ){ |
|
| 5922 | 5922 | return new Less_Tree_Import( $this->path->compile($env), $this->features, $this->options, $this->index, $this->currentFileInfo); |
| 5923 | 5923 | } |
| 5924 | 5924 | |
| 5925 | - public function compilePath($env) { |
|
| 5925 | + public function compilePath($env) { |
|
| 5926 | 5926 | $path = $this->path->compile($env); |
| 5927 | 5927 | $rootpath = ''; |
| 5928 | 5928 | if( $this->currentFileInfo && $this->currentFileInfo['rootpath'] ){ |
@@ -5946,7 +5946,7 @@ discard block |
||
| 5946 | 5946 | return $path; |
| 5947 | 5947 | } |
| 5948 | 5948 | |
| 5949 | - public function compile( $env ){ |
|
| 5949 | + public function compile( $env ){ |
|
| 5950 | 5950 | |
| 5951 | 5951 | $evald = $this->compileForImport($env); |
| 5952 | 5952 | |
@@ -6003,7 +6003,7 @@ discard block |
||
| 6003 | 6003 | * |
| 6004 | 6004 | * @param Less_Tree_Import $evald |
| 6005 | 6005 | */ |
| 6006 | - public function PathAndUri(){ |
|
| 6006 | + public function PathAndUri(){ |
|
| 6007 | 6007 | |
| 6008 | 6008 | $evald_path = $this->getPath(); |
| 6009 | 6009 | |
@@ -6066,7 +6066,7 @@ discard block |
||
| 6066 | 6066 | * |
| 6067 | 6067 | * @return Less_Tree_Media|array |
| 6068 | 6068 | */ |
| 6069 | - public function ParseImport( $full_path, $uri, $env ){ |
|
| 6069 | + public function ParseImport( $full_path, $uri, $env ){ |
|
| 6070 | 6070 | |
| 6071 | 6071 | $import_env = clone $env; |
| 6072 | 6072 | if( (isset($this->options['reference']) && $this->options['reference']) || isset($this->currentFileInfo['reference']) ){ |
@@ -6163,9 +6163,9 @@ discard block |
||
| 6163 | 6163 | return $this; |
| 6164 | 6164 | } |
| 6165 | 6165 | |
| 6166 | - /** |
|
| 6167 | - * @see Less_Tree::genCSS |
|
| 6168 | - */ |
|
| 6166 | + /** |
|
| 6167 | + * @see Less_Tree::genCSS |
|
| 6168 | + */ |
|
| 6169 | 6169 | public function genCSS( $output ){ |
| 6170 | 6170 | |
| 6171 | 6171 | if( $this->value === '%') { |
@@ -6213,15 +6213,15 @@ discard block |
||
| 6213 | 6213 | $this->rules[0]->allowImports = true; |
| 6214 | 6214 | } |
| 6215 | 6215 | |
| 6216 | - public function accept( $visitor ){ |
|
| 6216 | + public function accept( $visitor ){ |
|
| 6217 | 6217 | $this->features = $visitor->visitObj($this->features); |
| 6218 | 6218 | $this->rules = $visitor->visitArray($this->rules); |
| 6219 | 6219 | } |
| 6220 | 6220 | |
| 6221 | - /** |
|
| 6222 | - * @see Less_Tree::genCSS |
|
| 6223 | - */ |
|
| 6224 | - public function genCSS( $output ){ |
|
| 6221 | + /** |
|
| 6222 | + * @see Less_Tree::genCSS |
|
| 6223 | + */ |
|
| 6224 | + public function genCSS( $output ){ |
|
| 6225 | 6225 | |
| 6226 | 6226 | $output->add( '@media ', $this->currentFileInfo, $this->index ); |
| 6227 | 6227 | $this->features->genCSS( $output ); |
@@ -6269,7 +6269,7 @@ discard block |
||
| 6269 | 6269 | $el = new Less_Tree_Element('','&', $this->index, $this->currentFileInfo ); |
| 6270 | 6270 | $sels = array( new Less_Tree_Selector(array($el), array(), null, $this->index, $this->currentFileInfo) ); |
| 6271 | 6271 | $sels[0]->mediaEmpty = true; |
| 6272 | - return $sels; |
|
| 6272 | + return $sels; |
|
| 6273 | 6273 | } |
| 6274 | 6274 | |
| 6275 | 6275 | public function markReferenced(){ |
@@ -6354,7 +6354,7 @@ discard block |
||
| 6354 | 6354 | return $result; |
| 6355 | 6355 | } |
| 6356 | 6356 | |
| 6357 | - public function bubbleSelectors($selectors) { |
|
| 6357 | + public function bubbleSelectors($selectors) { |
|
| 6358 | 6358 | |
| 6359 | 6359 | if( !$selectors) return; |
| 6360 | 6360 | |
@@ -6389,7 +6389,7 @@ discard block |
||
| 6389 | 6389 | $this->currentFileInfo = $currentFileInfo; |
| 6390 | 6390 | } |
| 6391 | 6391 | |
| 6392 | - public function genCSS( $output ){ |
|
| 6392 | + public function genCSS( $output ){ |
|
| 6393 | 6393 | |
| 6394 | 6394 | $output->add( |
| 6395 | 6395 | $this->name |
@@ -6416,7 +6416,7 @@ discard block |
||
| 6416 | 6416 | public $value; |
| 6417 | 6417 | public $type = 'Negative'; |
| 6418 | 6418 | |
| 6419 | - public function __construct($node){ |
|
| 6419 | + public function __construct($node){ |
|
| 6420 | 6420 | $this->value = $node; |
| 6421 | 6421 | } |
| 6422 | 6422 | |
@@ -6424,15 +6424,15 @@ discard block |
||
| 6424 | 6424 | // $this->value = $visitor->visit($this->value); |
| 6425 | 6425 | //} |
| 6426 | 6426 | |
| 6427 | - /** |
|
| 6428 | - * @see Less_Tree::genCSS |
|
| 6429 | - */ |
|
| 6430 | - public function genCSS( $output ){ |
|
| 6427 | + /** |
|
| 6428 | + * @see Less_Tree::genCSS |
|
| 6429 | + */ |
|
| 6430 | + public function genCSS( $output ){ |
|
| 6431 | 6431 | $output->add( '-' ); |
| 6432 | 6432 | $this->value->genCSS( $output ); |
| 6433 | 6433 | } |
| 6434 | 6434 | |
| 6435 | - public function compile($env) { |
|
| 6435 | + public function compile($env) { |
|
| 6436 | 6436 | if( Less_Environment::isMathOn() ){ |
| 6437 | 6437 | $ret = new Less_Tree_Operation('*', array( new Less_Tree_Dimension(-1), $this->value ) ); |
| 6438 | 6438 | return $ret->compile($env); |
@@ -6463,7 +6463,7 @@ discard block |
||
| 6463 | 6463 | $this->isSpaced = $isSpaced; |
| 6464 | 6464 | } |
| 6465 | 6465 | |
| 6466 | - public function accept($visitor) { |
|
| 6466 | + public function accept($visitor) { |
|
| 6467 | 6467 | $this->operands = $visitor->visitArray($this->operands); |
| 6468 | 6468 | } |
| 6469 | 6469 | |
@@ -6493,10 +6493,10 @@ discard block |
||
| 6493 | 6493 | } |
| 6494 | 6494 | |
| 6495 | 6495 | |
| 6496 | - /** |
|
| 6497 | - * @see Less_Tree::genCSS |
|
| 6498 | - */ |
|
| 6499 | - public function genCSS( $output ){ |
|
| 6496 | + /** |
|
| 6497 | + * @see Less_Tree::genCSS |
|
| 6498 | + */ |
|
| 6499 | + public function genCSS( $output ){ |
|
| 6500 | 6500 | $this->operands[0]->genCSS( $output ); |
| 6501 | 6501 | if( $this->isSpaced ){ |
| 6502 | 6502 | $output->add( " " ); |
@@ -6526,14 +6526,14 @@ discard block |
||
| 6526 | 6526 | $this->value = $value; |
| 6527 | 6527 | } |
| 6528 | 6528 | |
| 6529 | - public function accept($visitor){ |
|
| 6529 | + public function accept($visitor){ |
|
| 6530 | 6530 | $this->value = $visitor->visitObj($this->value); |
| 6531 | 6531 | } |
| 6532 | 6532 | |
| 6533 | - /** |
|
| 6534 | - * @see Less_Tree::genCSS |
|
| 6535 | - */ |
|
| 6536 | - public function genCSS( $output ){ |
|
| 6533 | + /** |
|
| 6534 | + * @see Less_Tree::genCSS |
|
| 6535 | + */ |
|
| 6536 | + public function genCSS( $output ){ |
|
| 6537 | 6537 | $output->add( '(' ); |
| 6538 | 6538 | $this->value->genCSS( $output ); |
| 6539 | 6539 | $output->add( ')' ); |
@@ -6573,18 +6573,18 @@ discard block |
||
| 6573 | 6573 | $this->currentFileInfo = $currentFileInfo; |
| 6574 | 6574 | } |
| 6575 | 6575 | |
| 6576 | - /** |
|
| 6577 | - * @see Less_Tree::genCSS |
|
| 6578 | - */ |
|
| 6579 | - public function genCSS( $output ){ |
|
| 6576 | + /** |
|
| 6577 | + * @see Less_Tree::genCSS |
|
| 6578 | + */ |
|
| 6579 | + public function genCSS( $output ){ |
|
| 6580 | 6580 | if( !$this->escaped ){ |
| 6581 | 6581 | $output->add( $this->quote, $this->currentFileInfo, $this->index ); |
| 6582 | - } |
|
| 6583 | - $output->add( $this->value ); |
|
| 6584 | - if( !$this->escaped ){ |
|
| 6582 | + } |
|
| 6583 | + $output->add( $this->value ); |
|
| 6584 | + if( !$this->escaped ){ |
|
| 6585 | 6585 | $output->add( $this->quote ); |
| 6586 | - } |
|
| 6587 | - } |
|
| 6586 | + } |
|
| 6587 | + } |
|
| 6588 | 6588 | |
| 6589 | 6589 | public function compile($env){ |
| 6590 | 6590 | |
@@ -6609,7 +6609,7 @@ discard block |
||
| 6609 | 6609 | return new Less_Tree_Quoted($this->quote . $value . $this->quote, $value, $this->escaped, $this->index, $this->currentFileInfo); |
| 6610 | 6610 | } |
| 6611 | 6611 | |
| 6612 | - public function compare($x) { |
|
| 6612 | + public function compare($x) { |
|
| 6613 | 6613 | |
| 6614 | 6614 | if( !Less_Parser::is_method($x, 'toCSS') ){ |
| 6615 | 6615 | return -1; |
@@ -6659,14 +6659,14 @@ discard block |
||
| 6659 | 6659 | $this->variable = ( is_string($name) && $name[0] === '@'); |
| 6660 | 6660 | } |
| 6661 | 6661 | |
| 6662 | - public function accept($visitor) { |
|
| 6662 | + public function accept($visitor) { |
|
| 6663 | 6663 | $this->value = $visitor->visitObj( $this->value ); |
| 6664 | 6664 | } |
| 6665 | 6665 | |
| 6666 | - /** |
|
| 6667 | - * @see Less_Tree::genCSS |
|
| 6668 | - */ |
|
| 6669 | - public function genCSS( $output ){ |
|
| 6666 | + /** |
|
| 6667 | + * @see Less_Tree::genCSS |
|
| 6668 | + */ |
|
| 6669 | + public function genCSS( $output ){ |
|
| 6670 | 6670 | |
| 6671 | 6671 | $output->add( $this->name . Less_Environment::$_outputMap[': '], $this->currentFileInfo, $this->index); |
| 6672 | 6672 | try{ |
@@ -6727,7 +6727,7 @@ discard block |
||
| 6727 | 6727 | } |
| 6728 | 6728 | |
| 6729 | 6729 | |
| 6730 | - public function CompileName( $env, $name ){ |
|
| 6730 | + public function CompileName( $env, $name ){ |
|
| 6731 | 6731 | $output = new Less_Output(); |
| 6732 | 6732 | foreach($name as $n){ |
| 6733 | 6733 | $n->compile($env)->genCSS($output); |
@@ -6735,7 +6735,7 @@ discard block |
||
| 6735 | 6735 | return $output->toString(); |
| 6736 | 6736 | } |
| 6737 | 6737 | |
| 6738 | - public function makeImportant(){ |
|
| 6738 | + public function makeImportant(){ |
|
| 6739 | 6739 | return new Less_Tree_Rule($this->name, $this->value, '!important', $this->merge, $this->index, $this->currentFileInfo, $this->inline); |
| 6740 | 6740 | } |
| 6741 | 6741 | |
@@ -6837,14 +6837,14 @@ discard block |
||
| 6837 | 6837 | } |
| 6838 | 6838 | } |
| 6839 | 6839 | |
| 6840 | - // Evaluate everything else |
|
| 6840 | + // Evaluate everything else |
|
| 6841 | 6841 | for( $i=0; $i<$rsRuleCnt; $i++ ){ |
| 6842 | 6842 | $rule = $ruleset->rules[$i]; |
| 6843 | 6843 | |
| 6844 | - // for rulesets, check if it is a css guard and can be removed |
|
| 6844 | + // for rulesets, check if it is a css guard and can be removed |
|
| 6845 | 6845 | if( $rule instanceof Less_Tree_Ruleset && $rule->selectors && count($rule->selectors) === 1 ){ |
| 6846 | 6846 | |
| 6847 | - // check if it can be folded in (e.g. & where) |
|
| 6847 | + // check if it can be folded in (e.g. & where) |
|
| 6848 | 6848 | if( $rule->selectors[0]->isJustParentSelector() ){ |
| 6849 | 6849 | array_splice($ruleset->rules,$i--,1); |
| 6850 | 6850 | $rsRuleCnt--; |
@@ -6857,9 +6857,9 @@ discard block |
||
| 6857 | 6857 | } |
| 6858 | 6858 | } |
| 6859 | 6859 | |
| 6860 | - } |
|
| 6861 | - } |
|
| 6862 | - } |
|
| 6860 | + } |
|
| 6861 | + } |
|
| 6862 | + } |
|
| 6863 | 6863 | |
| 6864 | 6864 | |
| 6865 | 6865 | // Pop the stack |
@@ -7396,13 +7396,13 @@ discard block |
||
| 7396 | 7396 | public $variable; |
| 7397 | 7397 | public $type = "RulesetCall"; |
| 7398 | 7398 | |
| 7399 | - public function __construct($variable){ |
|
| 7399 | + public function __construct($variable){ |
|
| 7400 | 7400 | $this->variable = $variable; |
| 7401 | 7401 | } |
| 7402 | 7402 | |
| 7403 | - public function accept($visitor) {} |
|
| 7403 | + public function accept($visitor) {} |
|
| 7404 | 7404 | |
| 7405 | - public function compile( $env ){ |
|
| 7405 | + public function compile( $env ){ |
|
| 7406 | 7406 | $variable = new Less_Tree_Variable($this->variable); |
| 7407 | 7407 | $detachedRuleset = $variable->compile($env); |
| 7408 | 7408 | return $detachedRuleset->callEval($env); |
@@ -7456,7 +7456,7 @@ discard block |
||
| 7456 | 7456 | $this->CacheElements(); |
| 7457 | 7457 | } |
| 7458 | 7458 | |
| 7459 | - public function accept($visitor) { |
|
| 7459 | + public function accept($visitor) { |
|
| 7460 | 7460 | $this->elements = $visitor->visitArray($this->elements); |
| 7461 | 7461 | $this->extendList = $visitor->visitArray($this->extendList); |
| 7462 | 7462 | if( $this->condition ){ |
@@ -7468,7 +7468,7 @@ discard block |
||
| 7468 | 7468 | } |
| 7469 | 7469 | } |
| 7470 | 7470 | |
| 7471 | - public function createDerived( $elements, $extendList = null, $evaldCondition = null ){ |
|
| 7471 | + public function createDerived( $elements, $extendList = null, $evaldCondition = null ){ |
|
| 7472 | 7472 | $newSelector = new Less_Tree_Selector( $elements, ($extendList ? $extendList : $this->extendList), null, $this->index, $this->currentFileInfo, $this->isReferenced); |
| 7473 | 7473 | $newSelector->evaldCondition = $evaldCondition ? $evaldCondition : $this->evaldCondition; |
| 7474 | 7474 | return $newSelector; |
@@ -7553,7 +7553,7 @@ discard block |
||
| 7553 | 7553 | /** |
| 7554 | 7554 | * @see Less_Tree::genCSS |
| 7555 | 7555 | */ |
| 7556 | - public function genCSS( $output, $firstSelector = true ){ |
|
| 7556 | + public function genCSS( $output, $firstSelector = true ){ |
|
| 7557 | 7557 | |
| 7558 | 7558 | if( !$firstSelector && $this->elements[0]->combinator === "" ){ |
| 7559 | 7559 | $output->add(' ', $this->currentFileInfo, $this->index); |
@@ -7564,15 +7564,15 @@ discard block |
||
| 7564 | 7564 | } |
| 7565 | 7565 | } |
| 7566 | 7566 | |
| 7567 | - public function markReferenced(){ |
|
| 7567 | + public function markReferenced(){ |
|
| 7568 | 7568 | $this->isReferenced = true; |
| 7569 | 7569 | } |
| 7570 | 7570 | |
| 7571 | - public function getIsReferenced(){ |
|
| 7571 | + public function getIsReferenced(){ |
|
| 7572 | 7572 | return !isset($this->currentFileInfo['reference']) || !$this->currentFileInfo['reference'] || $this->isReferenced; |
| 7573 | 7573 | } |
| 7574 | 7574 | |
| 7575 | - public function getIsOutput(){ |
|
| 7575 | + public function getIsOutput(){ |
|
| 7576 | 7576 | return $this->evaldCondition; |
| 7577 | 7577 | } |
| 7578 | 7578 | |
@@ -7594,9 +7594,9 @@ discard block |
||
| 7594 | 7594 | $this->value = $value; |
| 7595 | 7595 | } |
| 7596 | 7596 | |
| 7597 | - /** |
|
| 7598 | - * @see Less_Tree::genCSS |
|
| 7599 | - */ |
|
| 7597 | + /** |
|
| 7598 | + * @see Less_Tree::genCSS |
|
| 7599 | + */ |
|
| 7600 | 7600 | public function genCSS( $output ){ |
| 7601 | 7601 | $output->add( $this->value ); |
| 7602 | 7602 | } |
@@ -7621,19 +7621,19 @@ discard block |
||
| 7621 | 7621 | public $backupUnit; |
| 7622 | 7622 | public $type = 'Unit'; |
| 7623 | 7623 | |
| 7624 | - public function __construct($numerator = array(), $denominator = array(), $backupUnit = null ){ |
|
| 7624 | + public function __construct($numerator = array(), $denominator = array(), $backupUnit = null ){ |
|
| 7625 | 7625 | $this->numerator = $numerator; |
| 7626 | 7626 | $this->denominator = $denominator; |
| 7627 | 7627 | $this->backupUnit = $backupUnit; |
| 7628 | 7628 | } |
| 7629 | 7629 | |
| 7630 | - public function __clone(){ |
|
| 7630 | + public function __clone(){ |
|
| 7631 | 7631 | } |
| 7632 | 7632 | |
| 7633 | - /** |
|
| 7634 | - * @see Less_Tree::genCSS |
|
| 7635 | - */ |
|
| 7636 | - public function genCSS( $output ){ |
|
| 7633 | + /** |
|
| 7634 | + * @see Less_Tree::genCSS |
|
| 7635 | + */ |
|
| 7636 | + public function genCSS( $output ){ |
|
| 7637 | 7637 | |
| 7638 | 7638 | if( $this->numerator ){ |
| 7639 | 7639 | $output->add( $this->numerator[0] ); |
@@ -7645,7 +7645,7 @@ discard block |
||
| 7645 | 7645 | } |
| 7646 | 7646 | } |
| 7647 | 7647 | |
| 7648 | - public function toString(){ |
|
| 7648 | + public function toString(){ |
|
| 7649 | 7649 | $returnStr = implode('*',$this->numerator); |
| 7650 | 7650 | foreach($this->denominator as $d){ |
| 7651 | 7651 | $returnStr .= '/'.$d; |
@@ -7653,7 +7653,7 @@ discard block |
||
| 7653 | 7653 | return $returnStr; |
| 7654 | 7654 | } |
| 7655 | 7655 | |
| 7656 | - public function __toString(){ |
|
| 7656 | + public function __toString(){ |
|
| 7657 | 7657 | return $this->toString(); |
| 7658 | 7658 | } |
| 7659 | 7659 | |
@@ -7661,33 +7661,33 @@ discard block |
||
| 7661 | 7661 | /** |
| 7662 | 7662 | * @param Less_Tree_Unit $other |
| 7663 | 7663 | */ |
| 7664 | - public function compare($other) { |
|
| 7664 | + public function compare($other) { |
|
| 7665 | 7665 | return $this->is( $other->toString() ) ? 0 : -1; |
| 7666 | 7666 | } |
| 7667 | 7667 | |
| 7668 | - public function is($unitString){ |
|
| 7668 | + public function is($unitString){ |
|
| 7669 | 7669 | return $this->toString() === $unitString; |
| 7670 | 7670 | } |
| 7671 | 7671 | |
| 7672 | - public function isLength(){ |
|
| 7672 | + public function isLength(){ |
|
| 7673 | 7673 | $css = $this->toCSS(); |
| 7674 | 7674 | return !!preg_match('/px|em|%|in|cm|mm|pc|pt|ex/',$css); |
| 7675 | 7675 | } |
| 7676 | 7676 | |
| 7677 | - public function isAngle() { |
|
| 7677 | + public function isAngle() { |
|
| 7678 | 7678 | return isset( Less_Tree_UnitConversions::$angle[$this->toCSS()] ); |
| 7679 | 7679 | } |
| 7680 | 7680 | |
| 7681 | - public function isEmpty(){ |
|
| 7681 | + public function isEmpty(){ |
|
| 7682 | 7682 | return !$this->numerator && !$this->denominator; |
| 7683 | 7683 | } |
| 7684 | 7684 | |
| 7685 | - public function isSingular() { |
|
| 7685 | + public function isSingular() { |
|
| 7686 | 7686 | return count($this->numerator) <= 1 && !$this->denominator; |
| 7687 | 7687 | } |
| 7688 | 7688 | |
| 7689 | 7689 | |
| 7690 | - public function usedUnits(){ |
|
| 7690 | + public function usedUnits(){ |
|
| 7691 | 7691 | $result = array(); |
| 7692 | 7692 | |
| 7693 | 7693 | foreach(Less_Tree_UnitConversions::$groups as $groupName){ |
@@ -7709,7 +7709,7 @@ discard block |
||
| 7709 | 7709 | return $result; |
| 7710 | 7710 | } |
| 7711 | 7711 | |
| 7712 | - public function cancel(){ |
|
| 7712 | + public function cancel(){ |
|
| 7713 | 7713 | $counter = array(); |
| 7714 | 7714 | $backup = null; |
| 7715 | 7715 | |
@@ -7809,14 +7809,14 @@ discard block |
||
| 7809 | 7809 | $this->isEvald = $isEvald; |
| 7810 | 7810 | } |
| 7811 | 7811 | |
| 7812 | - public function accept( $visitor ){ |
|
| 7812 | + public function accept( $visitor ){ |
|
| 7813 | 7813 | $this->value = $visitor->visitObj($this->value); |
| 7814 | 7814 | } |
| 7815 | 7815 | |
| 7816 | - /** |
|
| 7817 | - * @see Less_Tree::genCSS |
|
| 7818 | - */ |
|
| 7819 | - public function genCSS( $output ){ |
|
| 7816 | + /** |
|
| 7817 | + * @see Less_Tree::genCSS |
|
| 7818 | + */ |
|
| 7819 | + public function genCSS( $output ){ |
|
| 7820 | 7820 | $output->add( 'url(' ); |
| 7821 | 7821 | $this->value->genCSS( $output ); |
| 7822 | 7822 | $output->add( ')' ); |
@@ -7880,7 +7880,7 @@ discard block |
||
| 7880 | 7880 | $this->value = $value; |
| 7881 | 7881 | } |
| 7882 | 7882 | |
| 7883 | - public function accept($visitor) { |
|
| 7883 | + public function accept($visitor) { |
|
| 7884 | 7884 | $this->value = $visitor->visitArray($this->value); |
| 7885 | 7885 | } |
| 7886 | 7886 | |
@@ -7897,9 +7897,9 @@ discard block |
||
| 7897 | 7897 | return $ret[0]; |
| 7898 | 7898 | } |
| 7899 | 7899 | |
| 7900 | - /** |
|
| 7901 | - * @see Less_Tree::genCSS |
|
| 7902 | - */ |
|
| 7900 | + /** |
|
| 7901 | + * @see Less_Tree::genCSS |
|
| 7902 | + */ |
|
| 7903 | 7903 | function genCSS( $output ){ |
| 7904 | 7904 | $len = count($this->value); |
| 7905 | 7905 | for($i = 0; $i < $len; $i++ ){ |
@@ -7927,14 +7927,14 @@ discard block |
||
| 7927 | 7927 | public $evaluating = false; |
| 7928 | 7928 | public $type = 'Variable'; |
| 7929 | 7929 | |
| 7930 | - /** |
|
| 7931 | - * @param string $name |
|
| 7932 | - */ |
|
| 7933 | - public function __construct($name, $index = null, $currentFileInfo = null) { |
|
| 7934 | - $this->name = $name; |
|
| 7935 | - $this->index = $index; |
|
| 7930 | + /** |
|
| 7931 | + * @param string $name |
|
| 7932 | + */ |
|
| 7933 | + public function __construct($name, $index = null, $currentFileInfo = null) { |
|
| 7934 | + $this->name = $name; |
|
| 7935 | + $this->index = $index; |
|
| 7936 | 7936 | $this->currentFileInfo = $currentFileInfo; |
| 7937 | - } |
|
| 7937 | + } |
|
| 7938 | 7938 | |
| 7939 | 7939 | public function compile($env) { |
| 7940 | 7940 | |
@@ -8359,8 +8359,8 @@ discard block |
||
| 8359 | 8359 | |
| 8360 | 8360 | // set array to prevent error on array_merge |
| 8361 | 8361 | if(!is_array($this->frames)) { |
| 8362 | - $this->frames = array(); |
|
| 8363 | - } |
|
| 8362 | + $this->frames = array(); |
|
| 8363 | + } |
|
| 8364 | 8364 | |
| 8365 | 8365 | $frame = $this->compileParams($env, array_merge($this->frames,$env->frames), $args ); |
| 8366 | 8366 | |
@@ -8429,21 +8429,21 @@ discard block |
||
| 8429 | 8429 | /** |
| 8430 | 8430 | * @param Less_Tree_Ruleset $root |
| 8431 | 8431 | */ |
| 8432 | - public function run($root){ |
|
| 8432 | + public function run($root){ |
|
| 8433 | 8433 | $root = $this->visitObj($root); |
| 8434 | 8434 | $root->allExtends =& $this->allExtendsStack[0]; |
| 8435 | 8435 | return $root; |
| 8436 | 8436 | } |
| 8437 | 8437 | |
| 8438 | - public function visitRule($ruleNode, &$visitDeeper ){ |
|
| 8438 | + public function visitRule($ruleNode, &$visitDeeper ){ |
|
| 8439 | 8439 | $visitDeeper = false; |
| 8440 | 8440 | } |
| 8441 | 8441 | |
| 8442 | - public function visitMixinDefinition( $mixinDefinitionNode, &$visitDeeper ){ |
|
| 8442 | + public function visitMixinDefinition( $mixinDefinitionNode, &$visitDeeper ){ |
|
| 8443 | 8443 | $visitDeeper = false; |
| 8444 | 8444 | } |
| 8445 | 8445 | |
| 8446 | - public function visitRuleset($rulesetNode){ |
|
| 8446 | + public function visitRuleset($rulesetNode){ |
|
| 8447 | 8447 | |
| 8448 | 8448 | if( $rulesetNode->root ){ |
| 8449 | 8449 | return; |
@@ -8479,7 +8479,7 @@ discard block |
||
| 8479 | 8479 | $this->contexts[] = $rulesetNode->selectors; |
| 8480 | 8480 | } |
| 8481 | 8481 | |
| 8482 | - public function allExtendsStackPush($rulesetNode, $selectorPath, $extend, &$j){ |
|
| 8482 | + public function allExtendsStackPush($rulesetNode, $selectorPath, $extend, &$j){ |
|
| 8483 | 8483 | $this->foundExtends = true; |
| 8484 | 8484 | $extend = clone $extend; |
| 8485 | 8485 | $extend->findSelfSelectors( $selectorPath ); |
@@ -8494,27 +8494,27 @@ discard block |
||
| 8494 | 8494 | } |
| 8495 | 8495 | |
| 8496 | 8496 | |
| 8497 | - public function visitRulesetOut( $rulesetNode ){ |
|
| 8497 | + public function visitRulesetOut( $rulesetNode ){ |
|
| 8498 | 8498 | if( !is_object($rulesetNode) || !$rulesetNode->root ){ |
| 8499 | 8499 | array_pop($this->contexts); |
| 8500 | 8500 | } |
| 8501 | 8501 | } |
| 8502 | 8502 | |
| 8503 | - public function visitMedia( $mediaNode ){ |
|
| 8503 | + public function visitMedia( $mediaNode ){ |
|
| 8504 | 8504 | $mediaNode->allExtends = array(); |
| 8505 | 8505 | $this->allExtendsStack[] =& $mediaNode->allExtends; |
| 8506 | 8506 | } |
| 8507 | 8507 | |
| 8508 | - public function visitMediaOut(){ |
|
| 8508 | + public function visitMediaOut(){ |
|
| 8509 | 8509 | array_pop($this->allExtendsStack); |
| 8510 | 8510 | } |
| 8511 | 8511 | |
| 8512 | - public function visitDirective( $directiveNode ){ |
|
| 8512 | + public function visitDirective( $directiveNode ){ |
|
| 8513 | 8513 | $directiveNode->allExtends = array(); |
| 8514 | 8514 | $this->allExtendsStack[] =& $directiveNode->allExtends; |
| 8515 | 8515 | } |
| 8516 | 8516 | |
| 8517 | - public function visitDirectiveOut(){ |
|
| 8517 | + public function visitDirectiveOut(){ |
|
| 8518 | 8518 | array_pop($this->allExtendsStack); |
| 8519 | 8519 | } |
| 8520 | 8520 | } |
@@ -8678,15 +8678,15 @@ discard block |
||
| 8678 | 8678 | return $this->visitObj($root); |
| 8679 | 8679 | } |
| 8680 | 8680 | |
| 8681 | - public function visitRule( $ruleNode, &$visitDeeper ){ |
|
| 8681 | + public function visitRule( $ruleNode, &$visitDeeper ){ |
|
| 8682 | 8682 | $visitDeeper = false; |
| 8683 | 8683 | } |
| 8684 | 8684 | |
| 8685 | - public function visitMixinDefinition( $mixinDefinitionNode, &$visitDeeper ){ |
|
| 8685 | + public function visitMixinDefinition( $mixinDefinitionNode, &$visitDeeper ){ |
|
| 8686 | 8686 | $visitDeeper = false; |
| 8687 | 8687 | } |
| 8688 | 8688 | |
| 8689 | - public function visitRuleset( $rulesetNode ){ |
|
| 8689 | + public function visitRuleset( $rulesetNode ){ |
|
| 8690 | 8690 | |
| 8691 | 8691 | $paths = array(); |
| 8692 | 8692 | |
@@ -8715,11 +8715,11 @@ discard block |
||
| 8715 | 8715 | $this->contexts[] = $paths; //different from less.js. Placed after joinSelectors() so that $this->contexts will get correct $paths |
| 8716 | 8716 | } |
| 8717 | 8717 | |
| 8718 | - public function visitRulesetOut(){ |
|
| 8718 | + public function visitRulesetOut(){ |
|
| 8719 | 8719 | array_pop($this->contexts); |
| 8720 | 8720 | } |
| 8721 | 8721 | |
| 8722 | - public function visitMedia($mediaNode) { |
|
| 8722 | + public function visitMedia($mediaNode) { |
|
| 8723 | 8723 | $context = end($this->contexts); //$context = $this->contexts[ count($this->contexts) - 1]; |
| 8724 | 8724 | |
| 8725 | 8725 | if( !count($context) || (is_object($context[0]) && $context[0]->multiMedia) ){ |
@@ -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,16 +167,16 @@ 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 | 177 | try { |
| 178 | 178 | |
| 179 | - $root = new Less_Tree_Ruleset(array(), $this->rules ); |
|
| 179 | + $root = new Less_Tree_Ruleset(array(), $this->rules); |
|
| 180 | 180 | $root->root = true; |
| 181 | 181 | $root->firstRoot = true; |
| 182 | 182 | |
@@ -190,16 +190,16 @@ discard block |
||
| 190 | 190 | |
| 191 | 191 | $this->PostVisitors($evaldRoot); |
| 192 | 192 | |
| 193 | - if( Less_Parser::$options['sourceMap'] ){ |
|
| 194 | - $generator = new Less_SourceMap_Generator($evaldRoot, Less_Parser::$contentsMap, Less_Parser::$options ); |
|
| 193 | + if (Less_Parser::$options['sourceMap']) { |
|
| 194 | + $generator = new Less_SourceMap_Generator($evaldRoot, Less_Parser::$contentsMap, Less_Parser::$options); |
|
| 195 | 195 | // will also save file |
| 196 | 196 | // FIXME: should happen somewhere else? |
| 197 | 197 | $css = $generator->generateCSS(); |
| 198 | - }else{ |
|
| 198 | + }else { |
|
| 199 | 199 | $css = $evaldRoot->toCSS(); |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | - if( Less_Parser::$options['compress'] ){ |
|
| 202 | + if (Less_Parser::$options['compress']) { |
|
| 203 | 203 | $css = preg_replace('/(^(\s)+)|((\s)+$)/', '', $css); |
| 204 | 204 | } |
| 205 | 205 | |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | //reset php settings |
| 211 | - @ini_set('precision',$precision); |
|
| 211 | + @ini_set('precision', $precision); |
|
| 212 | 212 | setlocale(LC_NUMERIC, $locale); |
| 213 | 213 | |
| 214 | 214 | // Rethrow exception after we handled resetting the environment |
@@ -223,11 +223,11 @@ discard block |
||
| 223 | 223 | * Run pre-compile visitors |
| 224 | 224 | * |
| 225 | 225 | */ |
| 226 | - private function PreVisitors($root){ |
|
| 226 | + private function PreVisitors($root) { |
|
| 227 | 227 | |
| 228 | - if( Less_Parser::$options['plugins'] ){ |
|
| 229 | - foreach(Less_Parser::$options['plugins'] as $plugin){ |
|
| 230 | - if( !empty($plugin->isPreEvalVisitor) ){ |
|
| 228 | + if (Less_Parser::$options['plugins']) { |
|
| 229 | + foreach (Less_Parser::$options['plugins'] as $plugin) { |
|
| 230 | + if (!empty($plugin->isPreEvalVisitor)) { |
|
| 231 | 231 | $plugin->run($root); |
| 232 | 232 | } |
| 233 | 233 | } |
@@ -239,32 +239,32 @@ discard block |
||
| 239 | 239 | * Run post-compile visitors |
| 240 | 240 | * |
| 241 | 241 | */ |
| 242 | - private function PostVisitors($evaldRoot){ |
|
| 242 | + private function PostVisitors($evaldRoot) { |
|
| 243 | 243 | |
| 244 | 244 | $visitors = array(); |
| 245 | 245 | $visitors[] = new Less_Visitor_joinSelector(); |
| 246 | - if( self::$has_extends ){ |
|
| 246 | + if (self::$has_extends) { |
|
| 247 | 247 | $visitors[] = new Less_Visitor_processExtends(); |
| 248 | 248 | } |
| 249 | 249 | $visitors[] = new Less_Visitor_toCSS(); |
| 250 | 250 | |
| 251 | 251 | |
| 252 | - if( Less_Parser::$options['plugins'] ){ |
|
| 253 | - foreach(Less_Parser::$options['plugins'] as $plugin){ |
|
| 254 | - if( property_exists($plugin,'isPreEvalVisitor') && $plugin->isPreEvalVisitor ){ |
|
| 252 | + if (Less_Parser::$options['plugins']) { |
|
| 253 | + foreach (Less_Parser::$options['plugins'] as $plugin) { |
|
| 254 | + if (property_exists($plugin, 'isPreEvalVisitor') && $plugin->isPreEvalVisitor) { |
|
| 255 | 255 | continue; |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | - if( property_exists($plugin,'isPreVisitor') && $plugin->isPreVisitor ){ |
|
| 259 | - array_unshift( $visitors, $plugin); |
|
| 260 | - }else{ |
|
| 258 | + if (property_exists($plugin, 'isPreVisitor') && $plugin->isPreVisitor) { |
|
| 259 | + array_unshift($visitors, $plugin); |
|
| 260 | + }else { |
|
| 261 | 261 | $visitors[] = $plugin; |
| 262 | 262 | } |
| 263 | 263 | } |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | |
| 267 | - for($i = 0; $i < count($visitors); $i++ ){ |
|
| 267 | + for ($i = 0; $i<count($visitors); $i++) { |
|
| 268 | 268 | $visitors[$i]->run($evaldRoot); |
| 269 | 269 | } |
| 270 | 270 | |
@@ -278,12 +278,12 @@ discard block |
||
| 278 | 278 | * @param string $uri_root The url of the file |
| 279 | 279 | * @return Less_Tree_Ruleset|Less_Parser |
| 280 | 280 | */ |
| 281 | - public function parse( $str, $file_uri = null ){ |
|
| 281 | + public function parse($str, $file_uri = null) { |
|
| 282 | 282 | |
| 283 | - if( !$file_uri ){ |
|
| 283 | + if (!$file_uri) { |
|
| 284 | 284 | $uri_root = ''; |
| 285 | 285 | $filename = 'anonymous-file-'.Less_Parser::$next_id++.'.less'; |
| 286 | - }else{ |
|
| 286 | + }else { |
|
| 287 | 287 | $file_uri = self::WinPath($file_uri); |
| 288 | 288 | $filename = $file_uri; |
| 289 | 289 | $uri_root = dirname($file_uri); |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | $this->input = $str; |
| 297 | 297 | $this->_parse(); |
| 298 | 298 | |
| 299 | - if( $previousFileInfo ){ |
|
| 299 | + if ($previousFileInfo) { |
|
| 300 | 300 | $this->env->currentFileInfo = $previousFileInfo; |
| 301 | 301 | } |
| 302 | 302 | |
@@ -313,16 +313,16 @@ discard block |
||
| 313 | 313 | * @param bool $returnRoot Indicates whether the return value should be a css string a root node |
| 314 | 314 | * @return Less_Tree_Ruleset|Less_Parser |
| 315 | 315 | */ |
| 316 | - public function parseFile( $filename, $uri_root = '', $returnRoot = false){ |
|
| 316 | + public function parseFile($filename, $uri_root = '', $returnRoot = false) { |
|
| 317 | 317 | |
| 318 | - if( !file_exists($filename) ){ |
|
| 318 | + if (!file_exists($filename)) { |
|
| 319 | 319 | $this->Error(sprintf('File `%s` not found.', $filename)); |
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | |
| 323 | 323 | // fix uri_root? |
| 324 | 324 | // Instead of The mixture of file path for the first argument and directory path for the second argument has bee |
| 325 | - if( !$returnRoot && !empty($uri_root) && basename($uri_root) == basename($filename) ){ |
|
| 325 | + if (!$returnRoot && !empty($uri_root) && basename($uri_root)==basename($filename)) { |
|
| 326 | 326 | $uri_root = dirname($uri_root); |
| 327 | 327 | } |
| 328 | 328 | |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | $previousFileInfo = $this->env->currentFileInfo; |
| 331 | 331 | |
| 332 | 332 | |
| 333 | - if( $filename ){ |
|
| 333 | + if ($filename) { |
|
| 334 | 334 | $filename = self::WinPath(realpath($filename)); |
| 335 | 335 | } |
| 336 | 336 | $uri_root = self::WinPath($uri_root); |
@@ -339,15 +339,15 @@ discard block |
||
| 339 | 339 | |
| 340 | 340 | self::AddParsedFile($filename); |
| 341 | 341 | |
| 342 | - if( $returnRoot ){ |
|
| 343 | - $rules = $this->GetRules( $filename ); |
|
| 344 | - $return = new Less_Tree_Ruleset(array(), $rules ); |
|
| 345 | - }else{ |
|
| 346 | - $this->_parse( $filename ); |
|
| 342 | + if ($returnRoot) { |
|
| 343 | + $rules = $this->GetRules($filename); |
|
| 344 | + $return = new Less_Tree_Ruleset(array(), $rules); |
|
| 345 | + }else { |
|
| 346 | + $this->_parse($filename); |
|
| 347 | 347 | $return = $this; |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | - if( $previousFileInfo ){ |
|
| 350 | + if ($previousFileInfo) { |
|
| 351 | 351 | $this->env->currentFileInfo = $previousFileInfo; |
| 352 | 352 | } |
| 353 | 353 | |
@@ -360,9 +360,9 @@ discard block |
||
| 360 | 360 | * @param array $vars |
| 361 | 361 | * @return Less_Parser |
| 362 | 362 | */ |
| 363 | - public function ModifyVars( $vars ){ |
|
| 363 | + public function ModifyVars($vars) { |
|
| 364 | 364 | |
| 365 | - $this->input = Less_Parser::serializeVars( $vars ); |
|
| 365 | + $this->input = Less_Parser::serializeVars($vars); |
|
| 366 | 366 | $this->_parse(); |
| 367 | 367 | |
| 368 | 368 | return $this; |
@@ -372,24 +372,24 @@ discard block |
||
| 372 | 372 | /** |
| 373 | 373 | * @param string $filename |
| 374 | 374 | */ |
| 375 | - public function SetFileInfo( $filename, $uri_root = ''){ |
|
| 375 | + public function SetFileInfo($filename, $uri_root = '') { |
|
| 376 | 376 | |
| 377 | 377 | $filename = Less_Environment::normalizePath($filename); |
| 378 | - $dirname = preg_replace('/[^\/\\\\]*$/','',$filename); |
|
| 378 | + $dirname = preg_replace('/[^\/\\\\]*$/', '', $filename); |
|
| 379 | 379 | |
| 380 | - if( !empty($uri_root) ){ |
|
| 381 | - $uri_root = rtrim($uri_root,'/').'/'; |
|
| 380 | + if (!empty($uri_root)) { |
|
| 381 | + $uri_root = rtrim($uri_root, '/').'/'; |
|
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | $currentFileInfo = array(); |
| 385 | 385 | |
| 386 | 386 | //entry info |
| 387 | - if( isset($this->env->currentFileInfo) ){ |
|
| 387 | + if (isset($this->env->currentFileInfo)) { |
|
| 388 | 388 | $currentFileInfo['entryPath'] = $this->env->currentFileInfo['entryPath']; |
| 389 | 389 | $currentFileInfo['entryUri'] = $this->env->currentFileInfo['entryUri']; |
| 390 | 390 | $currentFileInfo['rootpath'] = $this->env->currentFileInfo['rootpath']; |
| 391 | 391 | |
| 392 | - }else{ |
|
| 392 | + }else { |
|
| 393 | 393 | $currentFileInfo['entryPath'] = $dirname; |
| 394 | 394 | $currentFileInfo['entryUri'] = $uri_root; |
| 395 | 395 | $currentFileInfo['rootpath'] = $dirname; |
@@ -402,7 +402,7 @@ discard block |
||
| 402 | 402 | |
| 403 | 403 | |
| 404 | 404 | //inherit reference |
| 405 | - if( isset($this->env->currentFileInfo['reference']) && $this->env->currentFileInfo['reference'] ){ |
|
| 405 | + if (isset($this->env->currentFileInfo['reference']) && $this->env->currentFileInfo['reference']) { |
|
| 406 | 406 | $currentFileInfo['reference'] = true; |
| 407 | 407 | } |
| 408 | 408 | |
@@ -414,23 +414,23 @@ discard block |
||
| 414 | 414 | * @deprecated 1.5.1.2 |
| 415 | 415 | * |
| 416 | 416 | */ |
| 417 | - public function SetCacheDir( $dir ){ |
|
| 417 | + public function SetCacheDir($dir) { |
|
| 418 | 418 | |
| 419 | - if( !file_exists($dir) ){ |
|
| 420 | - if( mkdir($dir) ){ |
|
| 419 | + if (!file_exists($dir)) { |
|
| 420 | + if (mkdir($dir)) { |
|
| 421 | 421 | return true; |
| 422 | 422 | } |
| 423 | 423 | throw new Less_Exception_Parser('Less.php cache directory couldn\'t be created: '.$dir); |
| 424 | 424 | |
| 425 | - }elseif( !is_dir($dir) ){ |
|
| 425 | + }elseif (!is_dir($dir)) { |
|
| 426 | 426 | throw new Less_Exception_Parser('Less.php cache directory doesn\'t exist: '.$dir); |
| 427 | 427 | |
| 428 | - }elseif( !is_writable($dir) ){ |
|
| 428 | + }elseif (!is_writable($dir)) { |
|
| 429 | 429 | throw new Less_Exception_Parser('Less.php cache directory isn\'t writable: '.$dir); |
| 430 | 430 | |
| 431 | - }else{ |
|
| 431 | + }else { |
|
| 432 | 432 | $dir = self::WinPath($dir); |
| 433 | - Less_Cache::$cache_dir = rtrim($dir,'/').'/'; |
|
| 433 | + Less_Cache::$cache_dir = rtrim($dir, '/').'/'; |
|
| 434 | 434 | return true; |
| 435 | 435 | } |
| 436 | 436 | } |
@@ -441,20 +441,20 @@ discard block |
||
| 441 | 441 | * |
| 442 | 442 | * @param array $dirs |
| 443 | 443 | */ |
| 444 | - public function SetImportDirs( $dirs ){ |
|
| 444 | + public function SetImportDirs($dirs) { |
|
| 445 | 445 | Less_Parser::$options['import_dirs'] = array(); |
| 446 | 446 | |
| 447 | - foreach($dirs as $path => $uri_root){ |
|
| 447 | + foreach ($dirs as $path => $uri_root) { |
|
| 448 | 448 | |
| 449 | 449 | $path = self::WinPath($path); |
| 450 | - if( !empty($path) ){ |
|
| 451 | - $path = rtrim($path,'/').'/'; |
|
| 450 | + if (!empty($path)) { |
|
| 451 | + $path = rtrim($path, '/').'/'; |
|
| 452 | 452 | } |
| 453 | 453 | |
| 454 | - if ( !is_callable($uri_root) ){ |
|
| 454 | + if (!is_callable($uri_root)) { |
|
| 455 | 455 | $uri_root = self::WinPath($uri_root); |
| 456 | - if( !empty($uri_root) ){ |
|
| 457 | - $uri_root = rtrim($uri_root,'/').'/'; |
|
| 456 | + if (!empty($uri_root)) { |
|
| 457 | + $uri_root = rtrim($uri_root, '/').'/'; |
|
| 458 | 458 | } |
| 459 | 459 | } |
| 460 | 460 | |
@@ -465,13 +465,13 @@ discard block |
||
| 465 | 465 | /** |
| 466 | 466 | * @param string $file_path |
| 467 | 467 | */ |
| 468 | - private function _parse( $file_path = null ){ |
|
| 468 | + private function _parse($file_path = null) { |
|
| 469 | 469 | if (ini_get("mbstring.func_overload")) { |
| 470 | 470 | $mb_internal_encoding = ini_get("mbstring.internal_encoding"); |
| 471 | 471 | @ini_set("mbstring.internal_encoding", "ascii"); |
| 472 | 472 | } |
| 473 | 473 | |
| 474 | - $this->rules = array_merge($this->rules, $this->GetRules( $file_path )); |
|
| 474 | + $this->rules = array_merge($this->rules, $this->GetRules($file_path)); |
|
| 475 | 475 | |
| 476 | 476 | //reset php settings |
| 477 | 477 | if (isset($mb_internal_encoding)) { |
@@ -486,33 +486,33 @@ discard block |
||
| 486 | 486 | * |
| 487 | 487 | * @param string|null $file_path |
| 488 | 488 | */ |
| 489 | - private function GetRules( $file_path ){ |
|
| 489 | + private function GetRules($file_path) { |
|
| 490 | 490 | |
| 491 | 491 | $this->SetInput($file_path); |
| 492 | 492 | |
| 493 | - $cache_file = $this->CacheFile( $file_path ); |
|
| 494 | - if( $cache_file ){ |
|
| 495 | - if( Less_Parser::$options['cache_method'] == 'callback' ){ |
|
| 496 | - if( is_callable(Less_Parser::$options['cache_callback_get']) ){ |
|
| 493 | + $cache_file = $this->CacheFile($file_path); |
|
| 494 | + if ($cache_file) { |
|
| 495 | + if (Less_Parser::$options['cache_method']=='callback') { |
|
| 496 | + if (is_callable(Less_Parser::$options['cache_callback_get'])) { |
|
| 497 | 497 | $cache = call_user_func_array( |
| 498 | 498 | Less_Parser::$options['cache_callback_get'], |
| 499 | 499 | array($this, $file_path, $cache_file) |
| 500 | 500 | ); |
| 501 | 501 | |
| 502 | - if( $cache ){ |
|
| 502 | + if ($cache) { |
|
| 503 | 503 | $this->UnsetInput(); |
| 504 | 504 | return $cache; |
| 505 | 505 | } |
| 506 | 506 | } |
| 507 | 507 | |
| 508 | - }elseif( file_exists($cache_file) ){ |
|
| 509 | - switch(Less_Parser::$options['cache_method']){ |
|
| 508 | + }elseif (file_exists($cache_file)) { |
|
| 509 | + switch (Less_Parser::$options['cache_method']) { |
|
| 510 | 510 | |
| 511 | 511 | // Using serialize |
| 512 | 512 | // Faster but uses more memory |
| 513 | 513 | case 'serialize': |
| 514 | 514 | $cache = unserialize(file_get_contents($cache_file)); |
| 515 | - if( $cache ){ |
|
| 515 | + if ($cache) { |
|
| 516 | 516 | touch($cache_file); |
| 517 | 517 | $this->UnsetInput(); |
| 518 | 518 | return $cache; |
@@ -531,7 +531,7 @@ discard block |
||
| 531 | 531 | |
| 532 | 532 | $rules = $this->parsePrimary(); |
| 533 | 533 | |
| 534 | - if( $this->pos < $this->input_len ){ |
|
| 534 | + if ($this->pos<$this->input_len) { |
|
| 535 | 535 | throw new Less_Exception_Chunk($this->input, null, $this->furthest, $this->env->currentFileInfo); |
| 536 | 536 | } |
| 537 | 537 | |
@@ -539,27 +539,27 @@ discard block |
||
| 539 | 539 | |
| 540 | 540 | |
| 541 | 541 | //save the cache |
| 542 | - if( $cache_file ){ |
|
| 543 | - if( Less_Parser::$options['cache_method'] == 'callback' ){ |
|
| 544 | - if( is_callable(Less_Parser::$options['cache_callback_set']) ){ |
|
| 542 | + if ($cache_file) { |
|
| 543 | + if (Less_Parser::$options['cache_method']=='callback') { |
|
| 544 | + if (is_callable(Less_Parser::$options['cache_callback_set'])) { |
|
| 545 | 545 | call_user_func_array( |
| 546 | 546 | Less_Parser::$options['cache_callback_set'], |
| 547 | 547 | array($this, $file_path, $cache_file, $rules) |
| 548 | 548 | ); |
| 549 | 549 | } |
| 550 | 550 | |
| 551 | - }else{ |
|
| 551 | + }else { |
|
| 552 | 552 | //msg('write cache file'); |
| 553 | - switch(Less_Parser::$options['cache_method']){ |
|
| 553 | + switch (Less_Parser::$options['cache_method']) { |
|
| 554 | 554 | case 'serialize': |
| 555 | - file_put_contents( $cache_file, serialize($rules) ); |
|
| 555 | + file_put_contents($cache_file, serialize($rules)); |
|
| 556 | 556 | break; |
| 557 | 557 | case 'php': |
| 558 | - file_put_contents( $cache_file, '<?php return '.self::ArgString($rules).'; ?>' ); |
|
| 558 | + file_put_contents($cache_file, '<?php return '.self::ArgString($rules).'; ?>'); |
|
| 559 | 559 | break; |
| 560 | 560 | case 'var_export': |
| 561 | 561 | //Requires __set_state() |
| 562 | - file_put_contents( $cache_file, '<?php return '.var_export($rules,true).'; ?>' ); |
|
| 562 | + file_put_contents($cache_file, '<?php return '.var_export($rules, true).'; ?>'); |
|
| 563 | 563 | break; |
| 564 | 564 | } |
| 565 | 565 | |
@@ -575,10 +575,10 @@ discard block |
||
| 575 | 575 | * Set up the input buffer |
| 576 | 576 | * |
| 577 | 577 | */ |
| 578 | - public function SetInput( $file_path ){ |
|
| 578 | + public function SetInput($file_path) { |
|
| 579 | 579 | |
| 580 | - if( $file_path ){ |
|
| 581 | - $this->input = file_get_contents( $file_path ); |
|
| 580 | + if ($file_path) { |
|
| 581 | + $this->input = file_get_contents($file_path); |
|
| 582 | 582 | } |
| 583 | 583 | |
| 584 | 584 | $this->pos = $this->furthest = 0; |
@@ -588,7 +588,7 @@ discard block |
||
| 588 | 588 | $this->input_len = strlen($this->input); |
| 589 | 589 | |
| 590 | 590 | |
| 591 | - if( Less_Parser::$options['sourceMap'] && $this->env->currentFileInfo ){ |
|
| 591 | + if (Less_Parser::$options['sourceMap'] && $this->env->currentFileInfo) { |
|
| 592 | 592 | $uri = $this->env->currentFileInfo['currentUri']; |
| 593 | 593 | Less_Parser::$contentsMap[$uri] = $this->input; |
| 594 | 594 | } |
@@ -600,44 +600,44 @@ discard block |
||
| 600 | 600 | * Free up some memory |
| 601 | 601 | * |
| 602 | 602 | */ |
| 603 | - public function UnsetInput(){ |
|
| 603 | + public function UnsetInput() { |
|
| 604 | 604 | unset($this->input, $this->pos, $this->input_len, $this->furthest); |
| 605 | 605 | $this->saveStack = array(); |
| 606 | 606 | } |
| 607 | 607 | |
| 608 | 608 | |
| 609 | - public function CacheFile( $file_path ){ |
|
| 609 | + public function CacheFile($file_path) { |
|
| 610 | 610 | |
| 611 | - if( $file_path && $this->CacheEnabled() ){ |
|
| 611 | + if ($file_path && $this->CacheEnabled()) { |
|
| 612 | 612 | |
| 613 | 613 | $env = get_object_vars($this->env); |
| 614 | 614 | unset($env['frames']); |
| 615 | 615 | |
| 616 | 616 | $parts = array(); |
| 617 | 617 | $parts[] = $file_path; |
| 618 | - $parts[] = filesize( $file_path ); |
|
| 619 | - $parts[] = filemtime( $file_path ); |
|
| 618 | + $parts[] = filesize($file_path); |
|
| 619 | + $parts[] = filemtime($file_path); |
|
| 620 | 620 | $parts[] = $env; |
| 621 | 621 | $parts[] = Less_Version::cache_version; |
| 622 | 622 | $parts[] = Less_Parser::$options['cache_method']; |
| 623 | - return Less_Cache::$cache_dir . Less_Cache::$prefix . base_convert( sha1(json_encode($parts) ), 16, 36) . '.lesscache'; |
|
| 623 | + return Less_Cache::$cache_dir.Less_Cache::$prefix.base_convert(sha1(json_encode($parts)), 16, 36).'.lesscache'; |
|
| 624 | 624 | } |
| 625 | 625 | } |
| 626 | 626 | |
| 627 | 627 | |
| 628 | - static function AddParsedFile($file){ |
|
| 628 | + static function AddParsedFile($file) { |
|
| 629 | 629 | self::$imports[] = $file; |
| 630 | 630 | } |
| 631 | 631 | |
| 632 | - static function AllParsedFiles(){ |
|
| 632 | + static function AllParsedFiles() { |
|
| 633 | 633 | return self::$imports; |
| 634 | 634 | } |
| 635 | 635 | |
| 636 | 636 | /** |
| 637 | 637 | * @param string $file |
| 638 | 638 | */ |
| 639 | - static function FileParsed($file){ |
|
| 640 | - return in_array($file,self::$imports); |
|
| 639 | + static function FileParsed($file) { |
|
| 640 | + return in_array($file, self::$imports); |
|
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | |
@@ -649,13 +649,13 @@ discard block |
||
| 649 | 649 | $this->pos = array_pop($this->saveStack); |
| 650 | 650 | } |
| 651 | 651 | |
| 652 | - private function forget(){ |
|
| 652 | + private function forget() { |
|
| 653 | 653 | array_pop($this->saveStack); |
| 654 | 654 | } |
| 655 | 655 | |
| 656 | 656 | |
| 657 | 657 | private function isWhitespace($offset = 0) { |
| 658 | - return preg_match('/\s/',$this->input[ $this->pos + $offset]); |
|
| 658 | + return preg_match('/\s/', $this->input[$this->pos+$offset]); |
|
| 659 | 659 | } |
| 660 | 660 | |
| 661 | 661 | /** |
@@ -664,7 +664,7 @@ discard block |
||
| 664 | 664 | * @param array $toks |
| 665 | 665 | * @return array |
| 666 | 666 | */ |
| 667 | - private function match($toks){ |
|
| 667 | + private function match($toks) { |
|
| 668 | 668 | |
| 669 | 669 | // The match is confirmed, add the match length to `this::pos`, |
| 670 | 670 | // and consume any extra white-space characters (' ' || '\n') |
@@ -672,27 +672,27 @@ discard block |
||
| 672 | 672 | // grammar is mostly white-space insensitive. |
| 673 | 673 | // |
| 674 | 674 | |
| 675 | - foreach($toks as $tok){ |
|
| 675 | + foreach ($toks as $tok) { |
|
| 676 | 676 | |
| 677 | 677 | $char = $tok[0]; |
| 678 | 678 | |
| 679 | - if( $char === '/' ){ |
|
| 679 | + if ($char==='/') { |
|
| 680 | 680 | $match = $this->MatchReg($tok); |
| 681 | 681 | |
| 682 | - if( $match ){ |
|
| 683 | - return count($match) === 1 ? $match[0] : $match; |
|
| 682 | + if ($match) { |
|
| 683 | + return count($match)===1 ? $match[0] : $match; |
|
| 684 | 684 | } |
| 685 | 685 | |
| 686 | - }elseif( $char === '#' ){ |
|
| 686 | + }elseif ($char==='#') { |
|
| 687 | 687 | $match = $this->MatchChar($tok[1]); |
| 688 | 688 | |
| 689 | - }else{ |
|
| 689 | + }else { |
|
| 690 | 690 | // Non-terminal, match using a function call |
| 691 | 691 | $match = $this->$tok(); |
| 692 | 692 | |
| 693 | 693 | } |
| 694 | 694 | |
| 695 | - if( $match ){ |
|
| 695 | + if ($match) { |
|
| 696 | 696 | return $match; |
| 697 | 697 | } |
| 698 | 698 | } |
@@ -703,12 +703,12 @@ discard block |
||
| 703 | 703 | * |
| 704 | 704 | * @return string |
| 705 | 705 | */ |
| 706 | - private function MatchFuncs($toks){ |
|
| 706 | + private function MatchFuncs($toks) { |
|
| 707 | 707 | |
| 708 | - if( $this->pos < $this->input_len ){ |
|
| 709 | - foreach($toks as $tok){ |
|
| 708 | + if ($this->pos<$this->input_len) { |
|
| 709 | + foreach ($toks as $tok) { |
|
| 710 | 710 | $match = $this->$tok(); |
| 711 | - if( $match ){ |
|
| 711 | + if ($match) { |
|
| 712 | 712 | return $match; |
| 713 | 713 | } |
| 714 | 714 | } |
@@ -717,17 +717,17 @@ discard block |
||
| 717 | 717 | } |
| 718 | 718 | |
| 719 | 719 | // Match a single character in the input, |
| 720 | - private function MatchChar($tok){ |
|
| 721 | - if( ($this->pos < $this->input_len) && ($this->input[$this->pos] === $tok) ){ |
|
| 720 | + private function MatchChar($tok) { |
|
| 721 | + if (($this->pos<$this->input_len) && ($this->input[$this->pos]===$tok)) { |
|
| 722 | 722 | $this->skipWhitespace(1); |
| 723 | 723 | return $tok; |
| 724 | 724 | } |
| 725 | 725 | } |
| 726 | 726 | |
| 727 | 727 | // Match a regexp from the current start point |
| 728 | - private function MatchReg($tok){ |
|
| 728 | + private function MatchReg($tok) { |
|
| 729 | 729 | |
| 730 | - if( preg_match($tok, $this->input, $match, 0, $this->pos) ){ |
|
| 730 | + if (preg_match($tok, $this->input, $match, 0, $this->pos)) { |
|
| 731 | 731 | $this->skipWhitespace(strlen($match[0])); |
| 732 | 732 | return $match; |
| 733 | 733 | } |
@@ -741,30 +741,30 @@ discard block |
||
| 741 | 741 | * @param string $tok |
| 742 | 742 | * @return integer |
| 743 | 743 | */ |
| 744 | - public function PeekReg($tok){ |
|
| 744 | + public function PeekReg($tok) { |
|
| 745 | 745 | return preg_match($tok, $this->input, $match, 0, $this->pos); |
| 746 | 746 | } |
| 747 | 747 | |
| 748 | 748 | /** |
| 749 | 749 | * @param string $tok |
| 750 | 750 | */ |
| 751 | - public function PeekChar($tok){ |
|
| 751 | + public function PeekChar($tok) { |
|
| 752 | 752 | //return ($this->input[$this->pos] === $tok ); |
| 753 | - return ($this->pos < $this->input_len) && ($this->input[$this->pos] === $tok ); |
|
| 753 | + return ($this->pos<$this->input_len) && ($this->input[$this->pos]===$tok); |
|
| 754 | 754 | } |
| 755 | 755 | |
| 756 | 756 | |
| 757 | 757 | /** |
| 758 | 758 | * @param integer $length |
| 759 | 759 | */ |
| 760 | - public function skipWhitespace($length){ |
|
| 760 | + public function skipWhitespace($length) { |
|
| 761 | 761 | |
| 762 | 762 | $this->pos += $length; |
| 763 | 763 | |
| 764 | - for(; $this->pos < $this->input_len; $this->pos++ ){ |
|
| 764 | + for (; $this->pos<$this->input_len; $this->pos++) { |
|
| 765 | 765 | $c = $this->input[$this->pos]; |
| 766 | 766 | |
| 767 | - if( ($c !== "\n") && ($c !== "\r") && ($c !== "\t") && ($c !== ' ') ){ |
|
| 767 | + if (($c!=="\n") && ($c!=="\r") && ($c!=="\t") && ($c!==' ')) { |
|
| 768 | 768 | break; |
| 769 | 769 | } |
| 770 | 770 | } |
@@ -776,10 +776,10 @@ discard block |
||
| 776 | 776 | * @param string|null $msg |
| 777 | 777 | */ |
| 778 | 778 | public function expect($tok, $msg = NULL) { |
| 779 | - $result = $this->match( array($tok) ); |
|
| 779 | + $result = $this->match(array($tok)); |
|
| 780 | 780 | if (!$result) { |
| 781 | - $this->Error( $msg ? "Expected '" . $tok . "' got '" . $this->input[$this->pos] . "'" : $msg ); |
|
| 782 | - } else { |
|
| 781 | + $this->Error($msg ? "Expected '".$tok."' got '".$this->input[$this->pos]."'" : $msg); |
|
| 782 | + }else { |
|
| 783 | 783 | return $result; |
| 784 | 784 | } |
| 785 | 785 | } |
@@ -787,11 +787,11 @@ discard block |
||
| 787 | 787 | /** |
| 788 | 788 | * @param string $tok |
| 789 | 789 | */ |
| 790 | - public function expectChar($tok, $msg = null ){ |
|
| 790 | + public function expectChar($tok, $msg = null) { |
|
| 791 | 791 | $result = $this->MatchChar($tok); |
| 792 | - if( !$result ){ |
|
| 793 | - $this->Error( $msg ? "Expected '" . $tok . "' got '" . $this->input[$this->pos] . "'" : $msg ); |
|
| 794 | - }else{ |
|
| 792 | + if (!$result) { |
|
| 793 | + $this->Error($msg ? "Expected '".$tok."' got '".$this->input[$this->pos]."'" : $msg); |
|
| 794 | + }else { |
|
| 795 | 795 | return $result; |
| 796 | 796 | } |
| 797 | 797 | } |
@@ -841,31 +841,31 @@ discard block |
||
| 841 | 841 | // Only at one point is the primary rule not called from the |
| 842 | 842 | // block rule: at the root level. |
| 843 | 843 | // |
| 844 | - private function parsePrimary(){ |
|
| 844 | + private function parsePrimary() { |
|
| 845 | 845 | $root = array(); |
| 846 | 846 | |
| 847 | - while( true ){ |
|
| 847 | + while (true) { |
|
| 848 | 848 | |
| 849 | - if( $this->pos >= $this->input_len ){ |
|
| 849 | + if ($this->pos>=$this->input_len) { |
|
| 850 | 850 | break; |
| 851 | 851 | } |
| 852 | 852 | |
| 853 | 853 | $node = $this->parseExtend(true); |
| 854 | - if( $node ){ |
|
| 855 | - $root = array_merge($root,$node); |
|
| 854 | + if ($node) { |
|
| 855 | + $root = array_merge($root, $node); |
|
| 856 | 856 | continue; |
| 857 | 857 | } |
| 858 | 858 | |
| 859 | 859 | //$node = $this->MatchFuncs( array( 'parseMixinDefinition', 'parseRule', 'parseRuleset', 'parseMixinCall', 'parseComment', 'parseDirective')); |
| 860 | - $node = $this->MatchFuncs( array( 'parseMixinDefinition', 'parseNameValue', 'parseRule', 'parseRuleset', 'parseMixinCall', 'parseComment', 'parseRulesetCall', 'parseDirective')); |
|
| 860 | + $node = $this->MatchFuncs(array('parseMixinDefinition', 'parseNameValue', 'parseRule', 'parseRuleset', 'parseMixinCall', 'parseComment', 'parseRulesetCall', 'parseDirective')); |
|
| 861 | 861 | |
| 862 | - if( $node ){ |
|
| 862 | + if ($node) { |
|
| 863 | 863 | $root[] = $node; |
| 864 | - }elseif( !$this->MatchReg('/\\G[\s\n;]+/') ){ |
|
| 864 | + }elseif (!$this->MatchReg('/\\G[\s\n;]+/')) { |
|
| 865 | 865 | break; |
| 866 | 866 | } |
| 867 | 867 | |
| 868 | - if( $this->PeekChar('}') ){ |
|
| 868 | + if ($this->PeekChar('}')) { |
|
| 869 | 869 | break; |
| 870 | 870 | } |
| 871 | 871 | } |
@@ -878,30 +878,30 @@ discard block |
||
| 878 | 878 | // We create a Comment node for CSS comments `/* */`, |
| 879 | 879 | // but keep the LeSS comments `//` silent, by just skipping |
| 880 | 880 | // over them. |
| 881 | - private function parseComment(){ |
|
| 881 | + private function parseComment() { |
|
| 882 | 882 | |
| 883 | - if( $this->input[$this->pos] !== '/' ){ |
|
| 883 | + if ($this->input[$this->pos]!=='/') { |
|
| 884 | 884 | return; |
| 885 | 885 | } |
| 886 | 886 | |
| 887 | - if( $this->input[$this->pos+1] === '/' ){ |
|
| 887 | + if ($this->input[$this->pos+1]==='/') { |
|
| 888 | 888 | $match = $this->MatchReg('/\\G\/\/.*/'); |
| 889 | - return $this->NewObj4('Less_Tree_Comment',array($match[0], true, $this->pos, $this->env->currentFileInfo)); |
|
| 889 | + return $this->NewObj4('Less_Tree_Comment', array($match[0], true, $this->pos, $this->env->currentFileInfo)); |
|
| 890 | 890 | } |
| 891 | 891 | |
| 892 | 892 | //$comment = $this->MatchReg('/\\G\/\*(?:[^*]|\*+[^\/*])*\*+\/\n?/'); |
| 893 | - $comment = $this->MatchReg('/\\G\/\*(?s).*?\*+\/\n?/');//not the same as less.js to prevent fatal errors |
|
| 894 | - if( $comment ){ |
|
| 895 | - return $this->NewObj4('Less_Tree_Comment',array($comment[0], false, $this->pos, $this->env->currentFileInfo)); |
|
| 893 | + $comment = $this->MatchReg('/\\G\/\*(?s).*?\*+\/\n?/'); //not the same as less.js to prevent fatal errors |
|
| 894 | + if ($comment) { |
|
| 895 | + return $this->NewObj4('Less_Tree_Comment', array($comment[0], false, $this->pos, $this->env->currentFileInfo)); |
|
| 896 | 896 | } |
| 897 | 897 | } |
| 898 | 898 | |
| 899 | - private function parseComments(){ |
|
| 899 | + private function parseComments() { |
|
| 900 | 900 | $comments = array(); |
| 901 | 901 | |
| 902 | - while( $this->pos < $this->input_len ){ |
|
| 902 | + while ($this->pos<$this->input_len) { |
|
| 903 | 903 | $comment = $this->parseComment(); |
| 904 | - if( !$comment ){ |
|
| 904 | + if (!$comment) { |
|
| 905 | 905 | break; |
| 906 | 906 | } |
| 907 | 907 | |
@@ -923,12 +923,12 @@ discard block |
||
| 923 | 923 | $e = false; |
| 924 | 924 | $index = $this->pos; |
| 925 | 925 | |
| 926 | - if( $this->input[$this->pos] === '~' ){ |
|
| 926 | + if ($this->input[$this->pos]==='~') { |
|
| 927 | 927 | $j++; |
| 928 | 928 | $e = true; // Escaped strings |
| 929 | 929 | } |
| 930 | 930 | |
| 931 | - if( $this->input[$j] != '"' && $this->input[$j] !== "'" ){ |
|
| 931 | + if ($this->input[$j]!='"' && $this->input[$j]!=="'") { |
|
| 932 | 932 | return; |
| 933 | 933 | } |
| 934 | 934 | |
@@ -940,9 +940,9 @@ discard block |
||
| 940 | 940 | //$str = $this->MatchReg('/\\G"((?:[^"\\\\\r\n]|\\\\.)*)"|\'((?:[^\'\\\\\r\n]|\\\\.)*)\'/'); |
| 941 | 941 | $str = $this->MatchReg('/\\G"((?:[^"\\\\\r\n]|\\\\.|\\\\\r\n|\\\\[\n\r\f])*)"|\'((?:[^\'\\\\\r\n]|\\\\.|\\\\\r\n|\\\\[\n\r\f])*)\'/'); |
| 942 | 942 | |
| 943 | - if( $str ){ |
|
| 944 | - $result = $str[0][0] == '"' ? $str[1] : $str[2]; |
|
| 945 | - return $this->NewObj5('Less_Tree_Quoted',array($str[0], $result, $e, $index, $this->env->currentFileInfo) ); |
|
| 943 | + if ($str) { |
|
| 944 | + $result = $str[0][0]=='"' ? $str[1] : $str[2]; |
|
| 945 | + return $this->NewObj5('Less_Tree_Quoted', array($str[0], $result, $e, $index, $this->env->currentFileInfo)); |
|
| 946 | 946 | } |
| 947 | 947 | return; |
| 948 | 948 | } |
@@ -953,31 +953,31 @@ discard block |
||
| 953 | 953 | // |
| 954 | 954 | // black border-collapse |
| 955 | 955 | // |
| 956 | - private function parseEntitiesKeyword(){ |
|
| 956 | + private function parseEntitiesKeyword() { |
|
| 957 | 957 | |
| 958 | 958 | //$k = $this->MatchReg('/\\G[_A-Za-z-][_A-Za-z0-9-]*/'); |
| 959 | 959 | $k = $this->MatchReg('/\\G%|\\G[_A-Za-z-][_A-Za-z0-9-]*/'); |
| 960 | - if( $k ){ |
|
| 960 | + if ($k) { |
|
| 961 | 961 | $k = $k[0]; |
| 962 | 962 | $color = $this->fromKeyword($k); |
| 963 | - if( $color ){ |
|
| 963 | + if ($color) { |
|
| 964 | 964 | return $color; |
| 965 | 965 | } |
| 966 | - return $this->NewObj1('Less_Tree_Keyword',$k); |
|
| 966 | + return $this->NewObj1('Less_Tree_Keyword', $k); |
|
| 967 | 967 | } |
| 968 | 968 | } |
| 969 | 969 | |
| 970 | 970 | // duplicate of Less_Tree_Color::FromKeyword |
| 971 | - private function FromKeyword( $keyword ){ |
|
| 971 | + private function FromKeyword($keyword) { |
|
| 972 | 972 | $keyword = strtolower($keyword); |
| 973 | 973 | |
| 974 | - if( Less_Colors::hasOwnProperty($keyword) ){ |
|
| 974 | + if (Less_Colors::hasOwnProperty($keyword)) { |
|
| 975 | 975 | // detect named color |
| 976 | - return $this->NewObj1('Less_Tree_Color',substr(Less_Colors::color($keyword), 1)); |
|
| 976 | + return $this->NewObj1('Less_Tree_Color', substr(Less_Colors::color($keyword), 1)); |
|
| 977 | 977 | } |
| 978 | 978 | |
| 979 | - if( $keyword === 'transparent' ){ |
|
| 980 | - return $this->NewObj3('Less_Tree_Color', array( array(0, 0, 0), 0, true)); |
|
| 979 | + if ($keyword==='transparent') { |
|
| 980 | + return $this->NewObj3('Less_Tree_Color', array(array(0, 0, 0), 0, true)); |
|
| 981 | 981 | } |
| 982 | 982 | } |
| 983 | 983 | |
@@ -991,24 +991,24 @@ discard block |
||
| 991 | 991 | // |
| 992 | 992 | // The arguments are parsed with the `entities.arguments` parser. |
| 993 | 993 | // |
| 994 | - private function parseEntitiesCall(){ |
|
| 994 | + private function parseEntitiesCall() { |
|
| 995 | 995 | $index = $this->pos; |
| 996 | 996 | |
| 997 | - if( !preg_match('/\\G([\w-]+|%|progid:[\w\.]+)\(/', $this->input, $name,0,$this->pos) ){ |
|
| 997 | + if (!preg_match('/\\G([\w-]+|%|progid:[\w\.]+)\(/', $this->input, $name, 0, $this->pos)) { |
|
| 998 | 998 | return; |
| 999 | 999 | } |
| 1000 | 1000 | $name = $name[1]; |
| 1001 | 1001 | $nameLC = strtolower($name); |
| 1002 | 1002 | |
| 1003 | - if ($nameLC === 'url') { |
|
| 1003 | + if ($nameLC==='url') { |
|
| 1004 | 1004 | return null; |
| 1005 | 1005 | } |
| 1006 | 1006 | |
| 1007 | 1007 | $this->pos += strlen($name); |
| 1008 | 1008 | |
| 1009 | - if( $nameLC === 'alpha' ){ |
|
| 1009 | + if ($nameLC==='alpha') { |
|
| 1010 | 1010 | $alpha_ret = $this->parseAlpha(); |
| 1011 | - if( $alpha_ret ){ |
|
| 1011 | + if ($alpha_ret) { |
|
| 1012 | 1012 | return $alpha_ret; |
| 1013 | 1013 | } |
| 1014 | 1014 | } |
@@ -1017,12 +1017,12 @@ discard block |
||
| 1017 | 1017 | |
| 1018 | 1018 | $args = $this->parseEntitiesArguments(); |
| 1019 | 1019 | |
| 1020 | - if( !$this->MatchChar(')') ){ |
|
| 1020 | + if (!$this->MatchChar(')')) { |
|
| 1021 | 1021 | return; |
| 1022 | 1022 | } |
| 1023 | 1023 | |
| 1024 | 1024 | if ($name) { |
| 1025 | - return $this->NewObj4('Less_Tree_Call',array($name, $args, $index, $this->env->currentFileInfo) ); |
|
| 1025 | + return $this->NewObj4('Less_Tree_Call', array($name, $args, $index, $this->env->currentFileInfo)); |
|
| 1026 | 1026 | } |
| 1027 | 1027 | } |
| 1028 | 1028 | |
@@ -1031,25 +1031,25 @@ discard block |
||
| 1031 | 1031 | * |
| 1032 | 1032 | * @return array |
| 1033 | 1033 | */ |
| 1034 | - private function parseEntitiesArguments(){ |
|
| 1034 | + private function parseEntitiesArguments() { |
|
| 1035 | 1035 | |
| 1036 | 1036 | $args = array(); |
| 1037 | - while( true ){ |
|
| 1038 | - $arg = $this->MatchFuncs( array('parseEntitiesAssignment','parseExpression') ); |
|
| 1039 | - if( !$arg ){ |
|
| 1037 | + while (true) { |
|
| 1038 | + $arg = $this->MatchFuncs(array('parseEntitiesAssignment', 'parseExpression')); |
|
| 1039 | + if (!$arg) { |
|
| 1040 | 1040 | break; |
| 1041 | 1041 | } |
| 1042 | 1042 | |
| 1043 | 1043 | $args[] = $arg; |
| 1044 | - if( !$this->MatchChar(',') ){ |
|
| 1044 | + if (!$this->MatchChar(',')) { |
|
| 1045 | 1045 | break; |
| 1046 | 1046 | } |
| 1047 | 1047 | } |
| 1048 | 1048 | return $args; |
| 1049 | 1049 | } |
| 1050 | 1050 | |
| 1051 | - private function parseEntitiesLiteral(){ |
|
| 1052 | - return $this->MatchFuncs( array('parseEntitiesDimension','parseEntitiesColor','parseEntitiesQuoted','parseUnicodeDescriptor') ); |
|
| 1051 | + private function parseEntitiesLiteral() { |
|
| 1052 | + return $this->MatchFuncs(array('parseEntitiesDimension', 'parseEntitiesColor', 'parseEntitiesQuoted', 'parseUnicodeDescriptor')); |
|
| 1053 | 1053 | } |
| 1054 | 1054 | |
| 1055 | 1055 | // Assignments are argument entities for calls. |
@@ -1060,17 +1060,17 @@ discard block |
||
| 1060 | 1060 | private function parseEntitiesAssignment() { |
| 1061 | 1061 | |
| 1062 | 1062 | $key = $this->MatchReg('/\\G\w+(?=\s?=)/'); |
| 1063 | - if( !$key ){ |
|
| 1063 | + if (!$key) { |
|
| 1064 | 1064 | return; |
| 1065 | 1065 | } |
| 1066 | 1066 | |
| 1067 | - if( !$this->MatchChar('=') ){ |
|
| 1067 | + if (!$this->MatchChar('=')) { |
|
| 1068 | 1068 | return; |
| 1069 | 1069 | } |
| 1070 | 1070 | |
| 1071 | 1071 | $value = $this->parseEntity(); |
| 1072 | - if( $value ){ |
|
| 1073 | - return $this->NewObj2('Less_Tree_Assignment',array($key[0], $value)); |
|
| 1072 | + if ($value) { |
|
| 1073 | + return $this->NewObj2('Less_Tree_Assignment', array($key[0], $value)); |
|
| 1074 | 1074 | } |
| 1075 | 1075 | } |
| 1076 | 1076 | |
@@ -1081,15 +1081,15 @@ discard block |
||
| 1081 | 1081 | // standard function calls. The difference is that the argument doesn't have |
| 1082 | 1082 | // to be enclosed within a string, so it can't be parsed as an Expression. |
| 1083 | 1083 | // |
| 1084 | - private function parseEntitiesUrl(){ |
|
| 1084 | + private function parseEntitiesUrl() { |
|
| 1085 | 1085 | |
| 1086 | 1086 | |
| 1087 | - if( $this->input[$this->pos] !== 'u' || !$this->matchReg('/\\Gurl\(/') ){ |
|
| 1087 | + if ($this->input[$this->pos]!=='u' || !$this->matchReg('/\\Gurl\(/')) { |
|
| 1088 | 1088 | return; |
| 1089 | 1089 | } |
| 1090 | 1090 | |
| 1091 | - $value = $this->match( array('parseEntitiesQuoted','parseEntitiesVariable','/\\Gdata\:.*?[^\)]+/','/\\G(?:(?:\\\\[\(\)\'"])|[^\(\)\'"])+/') ); |
|
| 1092 | - if( !$value ){ |
|
| 1091 | + $value = $this->match(array('parseEntitiesQuoted', 'parseEntitiesVariable', '/\\Gdata\:.*?[^\)]+/', '/\\G(?:(?:\\\\[\(\)\'"])|[^\(\)\'"])+/')); |
|
| 1092 | + if (!$value) { |
|
| 1093 | 1093 | $value = ''; |
| 1094 | 1094 | } |
| 1095 | 1095 | |
@@ -1097,11 +1097,11 @@ discard block |
||
| 1097 | 1097 | $this->expectChar(')'); |
| 1098 | 1098 | |
| 1099 | 1099 | |
| 1100 | - if( isset($value->value) || $value instanceof Less_Tree_Variable ){ |
|
| 1101 | - return $this->NewObj2('Less_Tree_Url',array($value, $this->env->currentFileInfo)); |
|
| 1100 | + if (isset($value->value) || $value instanceof Less_Tree_Variable) { |
|
| 1101 | + return $this->NewObj2('Less_Tree_Url', array($value, $this->env->currentFileInfo)); |
|
| 1102 | 1102 | } |
| 1103 | 1103 | |
| 1104 | - return $this->NewObj2('Less_Tree_Url', array( $this->NewObj1('Less_Tree_Anonymous',$value), $this->env->currentFileInfo) ); |
|
| 1104 | + return $this->NewObj2('Less_Tree_Url', array($this->NewObj1('Less_Tree_Anonymous', $value), $this->env->currentFileInfo)); |
|
| 1105 | 1105 | } |
| 1106 | 1106 | |
| 1107 | 1107 | |
@@ -1113,10 +1113,10 @@ discard block |
||
| 1113 | 1113 | // We use a different parser for variable definitions, |
| 1114 | 1114 | // see `parsers.variable`. |
| 1115 | 1115 | // |
| 1116 | - private function parseEntitiesVariable(){ |
|
| 1116 | + private function parseEntitiesVariable() { |
|
| 1117 | 1117 | $index = $this->pos; |
| 1118 | 1118 | if ($this->PeekChar('@') && ($name = $this->MatchReg('/\\G@@?[\w-]+/'))) { |
| 1119 | - return $this->NewObj3('Less_Tree_Variable', array( $name[0], $index, $this->env->currentFileInfo)); |
|
| 1119 | + return $this->NewObj3('Less_Tree_Variable', array($name[0], $index, $this->env->currentFileInfo)); |
|
| 1120 | 1120 | } |
| 1121 | 1121 | } |
| 1122 | 1122 | |
@@ -1125,8 +1125,8 @@ discard block |
||
| 1125 | 1125 | private function parseEntitiesVariableCurly() { |
| 1126 | 1126 | $index = $this->pos; |
| 1127 | 1127 | |
| 1128 | - if( $this->input_len > ($this->pos+1) && $this->input[$this->pos] === '@' && ($curly = $this->MatchReg('/\\G@\{([\w-]+)\}/')) ){ |
|
| 1129 | - return $this->NewObj3('Less_Tree_Variable',array('@'.$curly[1], $index, $this->env->currentFileInfo)); |
|
| 1128 | + if ($this->input_len>($this->pos+1) && $this->input[$this->pos]==='@' && ($curly = $this->MatchReg('/\\G@\{([\w-]+)\}/'))) { |
|
| 1129 | + return $this->NewObj3('Less_Tree_Variable', array('@'.$curly[1], $index, $this->env->currentFileInfo)); |
|
| 1130 | 1130 | } |
| 1131 | 1131 | } |
| 1132 | 1132 | |
@@ -1137,9 +1137,9 @@ discard block |
||
| 1137 | 1137 | // |
| 1138 | 1138 | // `rgb` and `hsl` colors are parsed through the `entities.call` parser. |
| 1139 | 1139 | // |
| 1140 | - private function parseEntitiesColor(){ |
|
| 1140 | + private function parseEntitiesColor() { |
|
| 1141 | 1141 | if ($this->PeekChar('#') && ($rgb = $this->MatchReg('/\\G#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})/'))) { |
| 1142 | - return $this->NewObj1('Less_Tree_Color',$rgb[1]); |
|
| 1142 | + return $this->NewObj1('Less_Tree_Color', $rgb[1]); |
|
| 1143 | 1143 | } |
| 1144 | 1144 | } |
| 1145 | 1145 | |
@@ -1148,22 +1148,22 @@ discard block |
||
| 1148 | 1148 | // |
| 1149 | 1149 | // 0.5em 95% |
| 1150 | 1150 | // |
| 1151 | - private function parseEntitiesDimension(){ |
|
| 1151 | + private function parseEntitiesDimension() { |
|
| 1152 | 1152 | |
| 1153 | 1153 | $c = @ord($this->input[$this->pos]); |
| 1154 | 1154 | |
| 1155 | 1155 | //Is the first char of the dimension 0-9, '.', '+' or '-' |
| 1156 | - if (($c > 57 || $c < 43) || $c === 47 || $c == 44){ |
|
| 1156 | + if (($c>57 || $c<43) || $c===47 || $c==44) { |
|
| 1157 | 1157 | return; |
| 1158 | 1158 | } |
| 1159 | 1159 | |
| 1160 | 1160 | $value = $this->MatchReg('/\\G([+-]?\d*\.?\d+)(%|[a-z]+)?/'); |
| 1161 | - if( $value ){ |
|
| 1161 | + if ($value) { |
|
| 1162 | 1162 | |
| 1163 | - if( isset($value[2]) ){ |
|
| 1164 | - return $this->NewObj2('Less_Tree_Dimension', array($value[1],$value[2])); |
|
| 1163 | + if (isset($value[2])) { |
|
| 1164 | + return $this->NewObj2('Less_Tree_Dimension', array($value[1], $value[2])); |
|
| 1165 | 1165 | } |
| 1166 | - return $this->NewObj1('Less_Tree_Dimension',$value[1]); |
|
| 1166 | + return $this->NewObj1('Less_Tree_Dimension', $value[1]); |
|
| 1167 | 1167 | } |
| 1168 | 1168 | } |
| 1169 | 1169 | |
@@ -1175,7 +1175,7 @@ discard block |
||
| 1175 | 1175 | // |
| 1176 | 1176 | function parseUnicodeDescriptor() { |
| 1177 | 1177 | $ud = $this->MatchReg('/\\G(U\+[0-9a-fA-F?]+)(\-[0-9a-fA-F?]+)?/'); |
| 1178 | - if( $ud ){ |
|
| 1178 | + if ($ud) { |
|
| 1179 | 1179 | return $this->NewObj1('Less_Tree_UnicodeDescriptor', $ud[0]); |
| 1180 | 1180 | } |
| 1181 | 1181 | } |
@@ -1186,21 +1186,21 @@ discard block |
||
| 1186 | 1186 | // |
| 1187 | 1187 | // `window.location.href` |
| 1188 | 1188 | // |
| 1189 | - private function parseEntitiesJavascript(){ |
|
| 1189 | + private function parseEntitiesJavascript() { |
|
| 1190 | 1190 | $e = false; |
| 1191 | 1191 | $j = $this->pos; |
| 1192 | - if( $this->input[$j] === '~' ){ |
|
| 1192 | + if ($this->input[$j]==='~') { |
|
| 1193 | 1193 | $j++; |
| 1194 | 1194 | $e = true; |
| 1195 | 1195 | } |
| 1196 | - if( $this->input[$j] !== '`' ){ |
|
| 1196 | + if ($this->input[$j]!=='`') { |
|
| 1197 | 1197 | return; |
| 1198 | 1198 | } |
| 1199 | - if( $e ){ |
|
| 1199 | + if ($e) { |
|
| 1200 | 1200 | $this->MatchChar('~'); |
| 1201 | 1201 | } |
| 1202 | 1202 | $str = $this->MatchReg('/\\G`([^`]*)`/'); |
| 1203 | - if( $str ){ |
|
| 1203 | + if ($str) { |
|
| 1204 | 1204 | return $this->NewObj3('Less_Tree_Javascript', array($str[1], $this->pos, $e)); |
| 1205 | 1205 | } |
| 1206 | 1206 | } |
@@ -1211,7 +1211,7 @@ discard block |
||
| 1211 | 1211 | // |
| 1212 | 1212 | // @fink: |
| 1213 | 1213 | // |
| 1214 | - private function parseVariable(){ |
|
| 1214 | + private function parseVariable() { |
|
| 1215 | 1215 | if ($this->PeekChar('@') && ($name = $this->MatchReg('/\\G(@[\w-]+)\s*:/'))) { |
| 1216 | 1216 | return $name[1]; |
| 1217 | 1217 | } |
@@ -1223,10 +1223,10 @@ discard block |
||
| 1223 | 1223 | // |
| 1224 | 1224 | // @fink(); |
| 1225 | 1225 | // |
| 1226 | - private function parseRulesetCall(){ |
|
| 1226 | + private function parseRulesetCall() { |
|
| 1227 | 1227 | |
| 1228 | - if( $this->input[$this->pos] === '@' && ($name = $this->MatchReg('/\\G(@[\w-]+)\s*\(\s*\)\s*;/')) ){ |
|
| 1229 | - return $this->NewObj1('Less_Tree_RulesetCall', $name[1] ); |
|
| 1228 | + if ($this->input[$this->pos]==='@' && ($name = $this->MatchReg('/\\G(@[\w-]+)\s*\(\s*\)\s*;/'))) { |
|
| 1229 | + return $this->NewObj1('Less_Tree_RulesetCall', $name[1]); |
|
| 1230 | 1230 | } |
| 1231 | 1231 | } |
| 1232 | 1232 | |
@@ -1234,36 +1234,36 @@ discard block |
||
| 1234 | 1234 | // |
| 1235 | 1235 | // extend syntax - used to extend selectors |
| 1236 | 1236 | // |
| 1237 | - function parseExtend($isRule = false){ |
|
| 1237 | + function parseExtend($isRule = false) { |
|
| 1238 | 1238 | |
| 1239 | 1239 | $index = $this->pos; |
| 1240 | 1240 | $extendList = array(); |
| 1241 | 1241 | |
| 1242 | 1242 | |
| 1243 | - if( !$this->MatchReg( $isRule ? '/\\G&:extend\(/' : '/\\G:extend\(/' ) ){ return; } |
|
| 1243 | + if (!$this->MatchReg($isRule ? '/\\G&:extend\(/' : '/\\G:extend\(/')) { return; } |
|
| 1244 | 1244 | |
| 1245 | - do{ |
|
| 1245 | + do { |
|
| 1246 | 1246 | $option = null; |
| 1247 | 1247 | $elements = array(); |
| 1248 | - while( true ){ |
|
| 1248 | + while (true) { |
|
| 1249 | 1249 | $option = $this->MatchReg('/\\G(all)(?=\s*(\)|,))/'); |
| 1250 | - if( $option ){ break; } |
|
| 1250 | + if ($option) { break; } |
|
| 1251 | 1251 | $e = $this->parseElement(); |
| 1252 | - if( !$e ){ break; } |
|
| 1252 | + if (!$e) { break; } |
|
| 1253 | 1253 | $elements[] = $e; |
| 1254 | 1254 | } |
| 1255 | 1255 | |
| 1256 | - if( $option ){ |
|
| 1256 | + if ($option) { |
|
| 1257 | 1257 | $option = $option[1]; |
| 1258 | 1258 | } |
| 1259 | 1259 | |
| 1260 | - $extendList[] = $this->NewObj3('Less_Tree_Extend', array( $this->NewObj1('Less_Tree_Selector',$elements), $option, $index )); |
|
| 1260 | + $extendList[] = $this->NewObj3('Less_Tree_Extend', array($this->NewObj1('Less_Tree_Selector', $elements), $option, $index)); |
|
| 1261 | 1261 | |
| 1262 | - }while( $this->MatchChar(",") ); |
|
| 1262 | + } while ($this->MatchChar(",")); |
|
| 1263 | 1263 | |
| 1264 | 1264 | $this->expect('/\\G\)/'); |
| 1265 | 1265 | |
| 1266 | - if( $isRule ){ |
|
| 1266 | + if ($isRule) { |
|
| 1267 | 1267 | $this->expect('/\\G;/'); |
| 1268 | 1268 | } |
| 1269 | 1269 | |
@@ -1282,10 +1282,10 @@ discard block |
||
| 1282 | 1282 | // namespaced, but we only support the child and descendant |
| 1283 | 1283 | // selector for now. |
| 1284 | 1284 | // |
| 1285 | - private function parseMixinCall(){ |
|
| 1285 | + private function parseMixinCall() { |
|
| 1286 | 1286 | |
| 1287 | 1287 | $char = $this->input[$this->pos]; |
| 1288 | - if( $char !== '.' && $char !== '#' ){ |
|
| 1288 | + if ($char!=='.' && $char!=='#') { |
|
| 1289 | 1289 | return; |
| 1290 | 1290 | } |
| 1291 | 1291 | |
@@ -1294,21 +1294,21 @@ discard block |
||
| 1294 | 1294 | |
| 1295 | 1295 | $elements = $this->parseMixinCallElements(); |
| 1296 | 1296 | |
| 1297 | - if( $elements ){ |
|
| 1297 | + if ($elements) { |
|
| 1298 | 1298 | |
| 1299 | - if( $this->MatchChar('(') ){ |
|
| 1299 | + if ($this->MatchChar('(')) { |
|
| 1300 | 1300 | $returned = $this->parseMixinArgs(true); |
| 1301 | 1301 | $args = $returned['args']; |
| 1302 | 1302 | $this->expectChar(')'); |
| 1303 | - }else{ |
|
| 1303 | + }else { |
|
| 1304 | 1304 | $args = array(); |
| 1305 | 1305 | } |
| 1306 | 1306 | |
| 1307 | 1307 | $important = $this->parseImportant(); |
| 1308 | 1308 | |
| 1309 | - if( $this->parseEnd() ){ |
|
| 1309 | + if ($this->parseEnd()) { |
|
| 1310 | 1310 | $this->forget(); |
| 1311 | - return $this->NewObj5('Less_Tree_Mixin_Call', array( $elements, $args, $index, $this->env->currentFileInfo, $important)); |
|
| 1311 | + return $this->NewObj5('Less_Tree_Mixin_Call', array($elements, $args, $index, $this->env->currentFileInfo, $important)); |
|
| 1312 | 1312 | } |
| 1313 | 1313 | } |
| 1314 | 1314 | |
@@ -1316,14 +1316,14 @@ discard block |
||
| 1316 | 1316 | } |
| 1317 | 1317 | |
| 1318 | 1318 | |
| 1319 | - private function parseMixinCallElements(){ |
|
| 1319 | + private function parseMixinCallElements() { |
|
| 1320 | 1320 | $elements = array(); |
| 1321 | 1321 | $c = null; |
| 1322 | 1322 | |
| 1323 | - while( true ){ |
|
| 1323 | + while (true) { |
|
| 1324 | 1324 | $elemIndex = $this->pos; |
| 1325 | 1325 | $e = $this->MatchReg('/\\G[#.](?:[\w-]|\\\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/'); |
| 1326 | - if( !$e ){ |
|
| 1326 | + if (!$e) { |
|
| 1327 | 1327 | break; |
| 1328 | 1328 | } |
| 1329 | 1329 | $elements[] = $this->NewObj4('Less_Tree_Element', array($c, $e[0], $elemIndex, $this->env->currentFileInfo)); |
@@ -1338,7 +1338,7 @@ discard block |
||
| 1338 | 1338 | /** |
| 1339 | 1339 | * @param boolean $isCall |
| 1340 | 1340 | */ |
| 1341 | - private function parseMixinArgs( $isCall ){ |
|
| 1341 | + private function parseMixinArgs($isCall) { |
|
| 1342 | 1342 | $expressions = array(); |
| 1343 | 1343 | $argsSemiColon = array(); |
| 1344 | 1344 | $isSemiColonSeperated = null; |
@@ -1349,54 +1349,54 @@ discard block |
||
| 1349 | 1349 | |
| 1350 | 1350 | $this->save(); |
| 1351 | 1351 | |
| 1352 | - while( true ){ |
|
| 1353 | - if( $isCall ){ |
|
| 1354 | - $arg = $this->MatchFuncs( array( 'parseDetachedRuleset','parseExpression' ) ); |
|
| 1355 | - } else { |
|
| 1352 | + while (true) { |
|
| 1353 | + if ($isCall) { |
|
| 1354 | + $arg = $this->MatchFuncs(array('parseDetachedRuleset', 'parseExpression')); |
|
| 1355 | + }else { |
|
| 1356 | 1356 | $this->parseComments(); |
| 1357 | - if( $this->input[ $this->pos ] === '.' && $this->MatchReg('/\\G\.{3}/') ){ |
|
| 1357 | + if ($this->input[$this->pos]==='.' && $this->MatchReg('/\\G\.{3}/')) { |
|
| 1358 | 1358 | $returner['variadic'] = true; |
| 1359 | - if( $this->MatchChar(";") && !$isSemiColonSeperated ){ |
|
| 1359 | + if ($this->MatchChar(";") && !$isSemiColonSeperated) { |
|
| 1360 | 1360 | $isSemiColonSeperated = true; |
| 1361 | 1361 | } |
| 1362 | 1362 | |
| 1363 | - if( $isSemiColonSeperated ){ |
|
| 1363 | + if ($isSemiColonSeperated) { |
|
| 1364 | 1364 | $argsSemiColon[] = array('variadic'=>true); |
| 1365 | - }else{ |
|
| 1365 | + }else { |
|
| 1366 | 1366 | $argsComma[] = array('variadic'=>true); |
| 1367 | 1367 | } |
| 1368 | 1368 | break; |
| 1369 | 1369 | } |
| 1370 | - $arg = $this->MatchFuncs( array('parseEntitiesVariable','parseEntitiesLiteral','parseEntitiesKeyword') ); |
|
| 1370 | + $arg = $this->MatchFuncs(array('parseEntitiesVariable', 'parseEntitiesLiteral', 'parseEntitiesKeyword')); |
|
| 1371 | 1371 | } |
| 1372 | 1372 | |
| 1373 | - if( !$arg ){ |
|
| 1373 | + if (!$arg) { |
|
| 1374 | 1374 | break; |
| 1375 | 1375 | } |
| 1376 | 1376 | |
| 1377 | 1377 | |
| 1378 | 1378 | $nameLoop = null; |
| 1379 | - if( $arg instanceof Less_Tree_Expression ){ |
|
| 1379 | + if ($arg instanceof Less_Tree_Expression) { |
|
| 1380 | 1380 | $arg->throwAwayComments(); |
| 1381 | 1381 | } |
| 1382 | 1382 | $value = $arg; |
| 1383 | 1383 | $val = null; |
| 1384 | 1384 | |
| 1385 | - if( $isCall ){ |
|
| 1385 | + if ($isCall) { |
|
| 1386 | 1386 | // Variable |
| 1387 | - if( property_exists($arg,'value') && count($arg->value) == 1 ){ |
|
| 1387 | + if (property_exists($arg, 'value') && count($arg->value)==1) { |
|
| 1388 | 1388 | $val = $arg->value[0]; |
| 1389 | 1389 | } |
| 1390 | - } else { |
|
| 1390 | + }else { |
|
| 1391 | 1391 | $val = $arg; |
| 1392 | 1392 | } |
| 1393 | 1393 | |
| 1394 | 1394 | |
| 1395 | - if( $val instanceof Less_Tree_Variable ){ |
|
| 1395 | + if ($val instanceof Less_Tree_Variable) { |
|
| 1396 | 1396 | |
| 1397 | - if( $this->MatchChar(':') ){ |
|
| 1398 | - if( $expressions ){ |
|
| 1399 | - if( $isSemiColonSeperated ){ |
|
| 1397 | + if ($this->MatchChar(':')) { |
|
| 1398 | + if ($expressions) { |
|
| 1399 | + if ($isSemiColonSeperated) { |
|
| 1400 | 1400 | $this->Error('Cannot mix ; and , as delimiter types'); |
| 1401 | 1401 | } |
| 1402 | 1402 | $expressionContainsNamed = true; |
@@ -1406,17 +1406,17 @@ discard block |
||
| 1406 | 1406 | // However if we do want to add it, there is nothing blocking it, just don't error |
| 1407 | 1407 | // and remove isCall dependency below |
| 1408 | 1408 | $value = null; |
| 1409 | - if( $isCall ){ |
|
| 1409 | + if ($isCall) { |
|
| 1410 | 1410 | $value = $this->parseDetachedRuleset(); |
| 1411 | 1411 | } |
| 1412 | - if( !$value ){ |
|
| 1412 | + if (!$value) { |
|
| 1413 | 1413 | $value = $this->parseExpression(); |
| 1414 | 1414 | } |
| 1415 | 1415 | |
| 1416 | - if( !$value ){ |
|
| 1417 | - if( $isCall ){ |
|
| 1416 | + if (!$value) { |
|
| 1417 | + if ($isCall) { |
|
| 1418 | 1418 | $this->Error('could not understand value for named argument'); |
| 1419 | - } else { |
|
| 1419 | + }else { |
|
| 1420 | 1420 | $this->restore(); |
| 1421 | 1421 | $returner['args'] = array(); |
| 1422 | 1422 | return $returner; |
@@ -1424,45 +1424,45 @@ discard block |
||
| 1424 | 1424 | } |
| 1425 | 1425 | |
| 1426 | 1426 | $nameLoop = ($name = $val->name); |
| 1427 | - }elseif( !$isCall && $this->MatchReg('/\\G\.{3}/') ){ |
|
| 1427 | + }elseif (!$isCall && $this->MatchReg('/\\G\.{3}/')) { |
|
| 1428 | 1428 | $returner['variadic'] = true; |
| 1429 | - if( $this->MatchChar(";") && !$isSemiColonSeperated ){ |
|
| 1429 | + if ($this->MatchChar(";") && !$isSemiColonSeperated) { |
|
| 1430 | 1430 | $isSemiColonSeperated = true; |
| 1431 | 1431 | } |
| 1432 | - if( $isSemiColonSeperated ){ |
|
| 1432 | + if ($isSemiColonSeperated) { |
|
| 1433 | 1433 | $argsSemiColon[] = array('name'=> $arg->name, 'variadic' => true); |
| 1434 | - }else{ |
|
| 1434 | + }else { |
|
| 1435 | 1435 | $argsComma[] = array('name'=> $arg->name, 'variadic' => true); |
| 1436 | 1436 | } |
| 1437 | 1437 | break; |
| 1438 | - }elseif( !$isCall ){ |
|
| 1438 | + }elseif (!$isCall) { |
|
| 1439 | 1439 | $name = $nameLoop = $val->name; |
| 1440 | 1440 | $value = null; |
| 1441 | 1441 | } |
| 1442 | 1442 | } |
| 1443 | 1443 | |
| 1444 | - if( $value ){ |
|
| 1444 | + if ($value) { |
|
| 1445 | 1445 | $expressions[] = $value; |
| 1446 | 1446 | } |
| 1447 | 1447 | |
| 1448 | - $argsComma[] = array('name'=>$nameLoop, 'value'=>$value ); |
|
| 1448 | + $argsComma[] = array('name'=>$nameLoop, 'value'=>$value); |
|
| 1449 | 1449 | |
| 1450 | - if( $this->MatchChar(',') ){ |
|
| 1450 | + if ($this->MatchChar(',')) { |
|
| 1451 | 1451 | continue; |
| 1452 | 1452 | } |
| 1453 | 1453 | |
| 1454 | - if( $this->MatchChar(';') || $isSemiColonSeperated ){ |
|
| 1454 | + if ($this->MatchChar(';') || $isSemiColonSeperated) { |
|
| 1455 | 1455 | |
| 1456 | - if( $expressionContainsNamed ){ |
|
| 1456 | + if ($expressionContainsNamed) { |
|
| 1457 | 1457 | $this->Error('Cannot mix ; and , as delimiter types'); |
| 1458 | 1458 | } |
| 1459 | 1459 | |
| 1460 | 1460 | $isSemiColonSeperated = true; |
| 1461 | 1461 | |
| 1462 | - if( count($expressions) > 1 ){ |
|
| 1462 | + if (count($expressions)>1) { |
|
| 1463 | 1463 | $value = $this->NewObj1('Less_Tree_Value', $expressions); |
| 1464 | 1464 | } |
| 1465 | - $argsSemiColon[] = array('name'=>$name, 'value'=>$value ); |
|
| 1465 | + $argsSemiColon[] = array('name'=>$name, 'value'=>$value); |
|
| 1466 | 1466 | |
| 1467 | 1467 | $name = null; |
| 1468 | 1468 | $expressions = array(); |
@@ -1496,21 +1496,21 @@ discard block |
||
| 1496 | 1496 | // Once we've got our params list, and a closing `)`, we parse |
| 1497 | 1497 | // the `{...}` block. |
| 1498 | 1498 | // |
| 1499 | - private function parseMixinDefinition(){ |
|
| 1499 | + private function parseMixinDefinition() { |
|
| 1500 | 1500 | $cond = null; |
| 1501 | 1501 | |
| 1502 | 1502 | $char = $this->input[$this->pos]; |
| 1503 | - if( ($char !== '.' && $char !== '#') || ($char === '{' && $this->PeekReg('/\\G[^{]*\}/')) ){ |
|
| 1503 | + if (($char!=='.' && $char!=='#') || ($char==='{' && $this->PeekReg('/\\G[^{]*\}/'))) { |
|
| 1504 | 1504 | return; |
| 1505 | 1505 | } |
| 1506 | 1506 | |
| 1507 | 1507 | $this->save(); |
| 1508 | 1508 | |
| 1509 | 1509 | $match = $this->MatchReg('/\\G([#.](?:[\w-]|\\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+)\s*\(/'); |
| 1510 | - if( $match ){ |
|
| 1510 | + if ($match) { |
|
| 1511 | 1511 | $name = $match[1]; |
| 1512 | 1512 | |
| 1513 | - $argInfo = $this->parseMixinArgs( false ); |
|
| 1513 | + $argInfo = $this->parseMixinArgs(false); |
|
| 1514 | 1514 | $params = $argInfo['args']; |
| 1515 | 1515 | $variadic = $argInfo['variadic']; |
| 1516 | 1516 | |
@@ -1520,7 +1520,7 @@ discard block |
||
| 1520 | 1520 | // also |
| 1521 | 1521 | // .mixincall(@a: {rule: set;}); |
| 1522 | 1522 | // so we have to be nice and restore |
| 1523 | - if( !$this->MatchChar(')') ){ |
|
| 1523 | + if (!$this->MatchChar(')')) { |
|
| 1524 | 1524 | $this->furthest = $this->pos; |
| 1525 | 1525 | $this->restore(); |
| 1526 | 1526 | return; |
@@ -1535,13 +1535,13 @@ discard block |
||
| 1535 | 1535 | |
| 1536 | 1536 | $ruleset = $this->parseBlock(); |
| 1537 | 1537 | |
| 1538 | - if( is_array($ruleset) ){ |
|
| 1538 | + if (is_array($ruleset)) { |
|
| 1539 | 1539 | $this->forget(); |
| 1540 | - return $this->NewObj5('Less_Tree_Mixin_Definition', array( $name, $params, $ruleset, $cond, $variadic)); |
|
| 1540 | + return $this->NewObj5('Less_Tree_Mixin_Definition', array($name, $params, $ruleset, $cond, $variadic)); |
|
| 1541 | 1541 | } |
| 1542 | 1542 | |
| 1543 | 1543 | $this->restore(); |
| 1544 | - }else{ |
|
| 1544 | + }else { |
|
| 1545 | 1545 | $this->forget(); |
| 1546 | 1546 | } |
| 1547 | 1547 | } |
@@ -1550,9 +1550,9 @@ discard block |
||
| 1550 | 1550 | // Entities are the smallest recognized token, |
| 1551 | 1551 | // and can be found inside a rule's value. |
| 1552 | 1552 | // |
| 1553 | - private function parseEntity(){ |
|
| 1553 | + private function parseEntity() { |
|
| 1554 | 1554 | |
| 1555 | - return $this->MatchFuncs( array('parseEntitiesLiteral','parseEntitiesVariable','parseEntitiesUrl','parseEntitiesCall','parseEntitiesKeyword','parseEntitiesJavascript','parseComment') ); |
|
| 1555 | + return $this->MatchFuncs(array('parseEntitiesLiteral', 'parseEntitiesVariable', 'parseEntitiesUrl', 'parseEntitiesCall', 'parseEntitiesKeyword', 'parseEntitiesJavascript', 'parseComment')); |
|
| 1556 | 1556 | } |
| 1557 | 1557 | |
| 1558 | 1558 | // |
@@ -1560,7 +1560,7 @@ discard block |
||
| 1560 | 1560 | // because the `block` rule will be expecting it, but we still need to make sure |
| 1561 | 1561 | // it's there, if ';' was ommitted. |
| 1562 | 1562 | // |
| 1563 | - private function parseEnd(){ |
|
| 1563 | + private function parseEnd() { |
|
| 1564 | 1564 | return $this->MatchChar(';') || $this->PeekChar('}'); |
| 1565 | 1565 | } |
| 1566 | 1566 | |
@@ -1569,24 +1569,24 @@ discard block |
||
| 1569 | 1569 | // |
| 1570 | 1570 | // alpha(opacity=88) |
| 1571 | 1571 | // |
| 1572 | - private function parseAlpha(){ |
|
| 1572 | + private function parseAlpha() { |
|
| 1573 | 1573 | |
| 1574 | - if ( ! $this->MatchReg('/\\G\(opacity=/i')) { |
|
| 1574 | + if (!$this->MatchReg('/\\G\(opacity=/i')) { |
|
| 1575 | 1575 | return; |
| 1576 | 1576 | } |
| 1577 | 1577 | |
| 1578 | 1578 | $value = $this->MatchReg('/\\G[0-9]+/'); |
| 1579 | - if( $value ){ |
|
| 1579 | + if ($value) { |
|
| 1580 | 1580 | $value = $value[0]; |
| 1581 | - }else{ |
|
| 1581 | + }else { |
|
| 1582 | 1582 | $value = $this->parseEntitiesVariable(); |
| 1583 | - if( !$value ){ |
|
| 1583 | + if (!$value) { |
|
| 1584 | 1584 | return; |
| 1585 | 1585 | } |
| 1586 | 1586 | } |
| 1587 | 1587 | |
| 1588 | 1588 | $this->expectChar(')'); |
| 1589 | - return $this->NewObj1('Less_Tree_Alpha',$value); |
|
| 1589 | + return $this->NewObj1('Less_Tree_Alpha', $value); |
|
| 1590 | 1590 | } |
| 1591 | 1591 | |
| 1592 | 1592 | |
@@ -1602,29 +1602,29 @@ discard block |
||
| 1602 | 1602 | // they are made out of a `Combinator` (see combinator rule), |
| 1603 | 1603 | // and an element name, such as a tag a class, or `*`. |
| 1604 | 1604 | // |
| 1605 | - private function parseElement(){ |
|
| 1605 | + private function parseElement() { |
|
| 1606 | 1606 | $c = $this->parseCombinator(); |
| 1607 | 1607 | $index = $this->pos; |
| 1608 | 1608 | |
| 1609 | - $e = $this->match( array('/\\G(?:\d+\.\d+|\d+)%/', '/\\G(?:[.#]?|:*)(?:[\w-]|[^\x00-\x9f]|\\\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/', |
|
| 1610 | - '#*', '#&', 'parseAttribute', '/\\G\([^()@]+\)/', '/\\G[\.#](?=@)/', 'parseEntitiesVariableCurly') ); |
|
| 1609 | + $e = $this->match(array('/\\G(?:\d+\.\d+|\d+)%/', '/\\G(?:[.#]?|:*)(?:[\w-]|[^\x00-\x9f]|\\\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/', |
|
| 1610 | + '#*', '#&', 'parseAttribute', '/\\G\([^()@]+\)/', '/\\G[\.#](?=@)/', 'parseEntitiesVariableCurly')); |
|
| 1611 | 1611 | |
| 1612 | - if( is_null($e) ){ |
|
| 1612 | + if (is_null($e)) { |
|
| 1613 | 1613 | $this->save(); |
| 1614 | - if( $this->MatchChar('(') ){ |
|
| 1615 | - if( ($v = $this->parseSelector()) && $this->MatchChar(')') ){ |
|
| 1616 | - $e = $this->NewObj1('Less_Tree_Paren',$v); |
|
| 1614 | + if ($this->MatchChar('(')) { |
|
| 1615 | + if (($v = $this->parseSelector()) && $this->MatchChar(')')) { |
|
| 1616 | + $e = $this->NewObj1('Less_Tree_Paren', $v); |
|
| 1617 | 1617 | $this->forget(); |
| 1618 | - }else{ |
|
| 1618 | + }else { |
|
| 1619 | 1619 | $this->restore(); |
| 1620 | 1620 | } |
| 1621 | - }else{ |
|
| 1621 | + }else { |
|
| 1622 | 1622 | $this->forget(); |
| 1623 | 1623 | } |
| 1624 | 1624 | } |
| 1625 | 1625 | |
| 1626 | - if( !is_null($e) ){ |
|
| 1627 | - return $this->NewObj4('Less_Tree_Element',array( $c, $e, $index, $this->env->currentFileInfo)); |
|
| 1626 | + if (!is_null($e)) { |
|
| 1627 | + return $this->NewObj4('Less_Tree_Element', array($c, $e, $index, $this->env->currentFileInfo)); |
|
| 1628 | 1628 | } |
| 1629 | 1629 | } |
| 1630 | 1630 | |
@@ -1636,13 +1636,13 @@ discard block |
||
| 1636 | 1636 | // as it's an empty space. We have to check the previous character |
| 1637 | 1637 | // in the input, to see if it's a ` ` character. |
| 1638 | 1638 | // |
| 1639 | - private function parseCombinator(){ |
|
| 1640 | - if( $this->pos < $this->input_len ){ |
|
| 1639 | + private function parseCombinator() { |
|
| 1640 | + if ($this->pos<$this->input_len) { |
|
| 1641 | 1641 | $c = $this->input[$this->pos]; |
| 1642 | - if ($c === '>' || $c === '+' || $c === '~' || $c === '|' || $c === '^' ){ |
|
| 1642 | + if ($c==='>' || $c==='+' || $c==='~' || $c==='|' || $c==='^') { |
|
| 1643 | 1643 | |
| 1644 | 1644 | $this->pos++; |
| 1645 | - if( $this->input[$this->pos] === '^' ){ |
|
| 1645 | + if ($this->input[$this->pos]==='^') { |
|
| 1646 | 1646 | $c = '^^'; |
| 1647 | 1647 | $this->pos++; |
| 1648 | 1648 | } |
@@ -1652,7 +1652,7 @@ discard block |
||
| 1652 | 1652 | return $c; |
| 1653 | 1653 | } |
| 1654 | 1654 | |
| 1655 | - if( $this->pos > 0 && $this->isWhitespace(-1) ){ |
|
| 1655 | + if ($this->pos>0 && $this->isWhitespace(-1)) { |
|
| 1656 | 1656 | return ' '; |
| 1657 | 1657 | } |
| 1658 | 1658 | } |
@@ -1662,7 +1662,7 @@ discard block |
||
| 1662 | 1662 | // A CSS selector (see selector below) |
| 1663 | 1663 | // with less extensions e.g. the ability to extend and guard |
| 1664 | 1664 | // |
| 1665 | - private function parseLessSelector(){ |
|
| 1665 | + private function parseLessSelector() { |
|
| 1666 | 1666 | return $this->parseSelector(true); |
| 1667 | 1667 | } |
| 1668 | 1668 | |
@@ -1674,7 +1674,7 @@ discard block |
||
| 1674 | 1674 | // |
| 1675 | 1675 | // Selectors are made out of one or more Elements, see above. |
| 1676 | 1676 | // |
| 1677 | - private function parseSelector( $isLess = false ){ |
|
| 1677 | + private function parseSelector($isLess = false) { |
|
| 1678 | 1678 | $elements = array(); |
| 1679 | 1679 | $extendList = array(); |
| 1680 | 1680 | $condition = null; |
@@ -1684,127 +1684,127 @@ discard block |
||
| 1684 | 1684 | $c = null; |
| 1685 | 1685 | $index = $this->pos; |
| 1686 | 1686 | |
| 1687 | - while( ($isLess && ($extend = $this->parseExtend())) || ($isLess && ($when = $this->MatchReg('/\\Gwhen/') )) || ($e = $this->parseElement()) ){ |
|
| 1688 | - if( $when ){ |
|
| 1687 | + while (($isLess && ($extend = $this->parseExtend())) || ($isLess && ($when = $this->MatchReg('/\\Gwhen/'))) || ($e = $this->parseElement())) { |
|
| 1688 | + if ($when) { |
|
| 1689 | 1689 | $condition = $this->expect('parseConditions', 'expected condition'); |
| 1690 | - }elseif( $condition ){ |
|
| 1690 | + }elseif ($condition) { |
|
| 1691 | 1691 | //error("CSS guard can only be used at the end of selector"); |
| 1692 | - }elseif( $extend ){ |
|
| 1693 | - $extendList = array_merge($extendList,$extend); |
|
| 1694 | - }else{ |
|
| 1692 | + }elseif ($extend) { |
|
| 1693 | + $extendList = array_merge($extendList, $extend); |
|
| 1694 | + }else { |
|
| 1695 | 1695 | //if( count($extendList) ){ |
| 1696 | 1696 | //error("Extend can only be used at the end of selector"); |
| 1697 | 1697 | //} |
| 1698 | - if( $this->pos < $this->input_len ){ |
|
| 1699 | - $c = $this->input[ $this->pos ]; |
|
| 1698 | + if ($this->pos<$this->input_len) { |
|
| 1699 | + $c = $this->input[$this->pos]; |
|
| 1700 | 1700 | } |
| 1701 | 1701 | $elements[] = $e; |
| 1702 | 1702 | $e = null; |
| 1703 | 1703 | } |
| 1704 | 1704 | |
| 1705 | - if( $c === '{' || $c === '}' || $c === ';' || $c === ',' || $c === ')') { break; } |
|
| 1705 | + if ($c==='{' || $c==='}' || $c===';' || $c===',' || $c===')') { break; } |
|
| 1706 | 1706 | } |
| 1707 | 1707 | |
| 1708 | - if( $elements ){ |
|
| 1709 | - return $this->NewObj5('Less_Tree_Selector',array($elements, $extendList, $condition, $index, $this->env->currentFileInfo)); |
|
| 1708 | + if ($elements) { |
|
| 1709 | + return $this->NewObj5('Less_Tree_Selector', array($elements, $extendList, $condition, $index, $this->env->currentFileInfo)); |
|
| 1710 | 1710 | } |
| 1711 | - if( $extendList ) { |
|
| 1711 | + if ($extendList) { |
|
| 1712 | 1712 | $this->Error('Extend must be used to extend a selector, it cannot be used on its own'); |
| 1713 | 1713 | } |
| 1714 | 1714 | } |
| 1715 | 1715 | |
| 1716 | - private function parseTag(){ |
|
| 1717 | - return ( $tag = $this->MatchReg('/\\G[A-Za-z][A-Za-z-]*[0-9]?/') ) ? $tag : $this->MatchChar('*'); |
|
| 1716 | + private function parseTag() { |
|
| 1717 | + return ($tag = $this->MatchReg('/\\G[A-Za-z][A-Za-z-]*[0-9]?/')) ? $tag : $this->MatchChar('*'); |
|
| 1718 | 1718 | } |
| 1719 | 1719 | |
| 1720 | - private function parseAttribute(){ |
|
| 1720 | + private function parseAttribute() { |
|
| 1721 | 1721 | |
| 1722 | 1722 | $val = null; |
| 1723 | 1723 | |
| 1724 | - if( !$this->MatchChar('[') ){ |
|
| 1724 | + if (!$this->MatchChar('[')) { |
|
| 1725 | 1725 | return; |
| 1726 | 1726 | } |
| 1727 | 1727 | |
| 1728 | 1728 | $key = $this->parseEntitiesVariableCurly(); |
| 1729 | - if( !$key ){ |
|
| 1729 | + if (!$key) { |
|
| 1730 | 1730 | $key = $this->expect('/\\G(?:[_A-Za-z0-9-\*]*\|)?(?:[_A-Za-z0-9-]|\\\\.)+/'); |
| 1731 | 1731 | } |
| 1732 | 1732 | |
| 1733 | 1733 | $op = $this->MatchReg('/\\G[|~*$^]?=/'); |
| 1734 | - if( $op ){ |
|
| 1735 | - $val = $this->match( array('parseEntitiesQuoted','/\\G[0-9]+%/','/\\G[\w-]+/','parseEntitiesVariableCurly') ); |
|
| 1734 | + if ($op) { |
|
| 1735 | + $val = $this->match(array('parseEntitiesQuoted', '/\\G[0-9]+%/', '/\\G[\w-]+/', 'parseEntitiesVariableCurly')); |
|
| 1736 | 1736 | } |
| 1737 | 1737 | |
| 1738 | 1738 | $this->expectChar(']'); |
| 1739 | 1739 | |
| 1740 | - return $this->NewObj3('Less_Tree_Attribute',array( $key, $op[0], $val)); |
|
| 1740 | + return $this->NewObj3('Less_Tree_Attribute', array($key, $op[0], $val)); |
|
| 1741 | 1741 | } |
| 1742 | 1742 | |
| 1743 | 1743 | // |
| 1744 | 1744 | // The `block` rule is used by `ruleset` and `mixin.definition`. |
| 1745 | 1745 | // It's a wrapper around the `primary` rule, with added `{}`. |
| 1746 | 1746 | // |
| 1747 | - private function parseBlock(){ |
|
| 1748 | - if( $this->MatchChar('{') ){ |
|
| 1747 | + private function parseBlock() { |
|
| 1748 | + if ($this->MatchChar('{')) { |
|
| 1749 | 1749 | $content = $this->parsePrimary(); |
| 1750 | - if( $this->MatchChar('}') ){ |
|
| 1750 | + if ($this->MatchChar('}')) { |
|
| 1751 | 1751 | return $content; |
| 1752 | 1752 | } |
| 1753 | 1753 | } |
| 1754 | 1754 | } |
| 1755 | 1755 | |
| 1756 | - private function parseBlockRuleset(){ |
|
| 1756 | + private function parseBlockRuleset() { |
|
| 1757 | 1757 | $block = $this->parseBlock(); |
| 1758 | 1758 | |
| 1759 | - if( $block ){ |
|
| 1760 | - $block = $this->NewObj2('Less_Tree_Ruleset',array( null, $block)); |
|
| 1759 | + if ($block) { |
|
| 1760 | + $block = $this->NewObj2('Less_Tree_Ruleset', array(null, $block)); |
|
| 1761 | 1761 | } |
| 1762 | 1762 | |
| 1763 | 1763 | return $block; |
| 1764 | 1764 | } |
| 1765 | 1765 | |
| 1766 | - private function parseDetachedRuleset(){ |
|
| 1766 | + private function parseDetachedRuleset() { |
|
| 1767 | 1767 | $blockRuleset = $this->parseBlockRuleset(); |
| 1768 | - if( $blockRuleset ){ |
|
| 1769 | - return $this->NewObj1('Less_Tree_DetachedRuleset',$blockRuleset); |
|
| 1768 | + if ($blockRuleset) { |
|
| 1769 | + return $this->NewObj1('Less_Tree_DetachedRuleset', $blockRuleset); |
|
| 1770 | 1770 | } |
| 1771 | 1771 | } |
| 1772 | 1772 | |
| 1773 | 1773 | // |
| 1774 | 1774 | // div, .class, body > p {...} |
| 1775 | 1775 | // |
| 1776 | - private function parseRuleset(){ |
|
| 1776 | + private function parseRuleset() { |
|
| 1777 | 1777 | $selectors = array(); |
| 1778 | 1778 | |
| 1779 | 1779 | $this->save(); |
| 1780 | 1780 | |
| 1781 | - while( true ){ |
|
| 1781 | + while (true) { |
|
| 1782 | 1782 | $s = $this->parseLessSelector(); |
| 1783 | - if( !$s ){ |
|
| 1783 | + if (!$s) { |
|
| 1784 | 1784 | break; |
| 1785 | 1785 | } |
| 1786 | 1786 | $selectors[] = $s; |
| 1787 | 1787 | $this->parseComments(); |
| 1788 | 1788 | |
| 1789 | - if( $s->condition && count($selectors) > 1 ){ |
|
| 1789 | + if ($s->condition && count($selectors)>1) { |
|
| 1790 | 1790 | $this->Error('Guards are only currently allowed on a single selector.'); |
| 1791 | 1791 | } |
| 1792 | 1792 | |
| 1793 | - if( !$this->MatchChar(',') ){ |
|
| 1793 | + if (!$this->MatchChar(',')) { |
|
| 1794 | 1794 | break; |
| 1795 | 1795 | } |
| 1796 | - if( $s->condition ){ |
|
| 1796 | + if ($s->condition) { |
|
| 1797 | 1797 | $this->Error('Guards are only currently allowed on a single selector.'); |
| 1798 | 1798 | } |
| 1799 | 1799 | $this->parseComments(); |
| 1800 | 1800 | } |
| 1801 | 1801 | |
| 1802 | 1802 | |
| 1803 | - if( $selectors ){ |
|
| 1803 | + if ($selectors) { |
|
| 1804 | 1804 | $rules = $this->parseBlock(); |
| 1805 | - if( is_array($rules) ){ |
|
| 1805 | + if (is_array($rules)) { |
|
| 1806 | 1806 | $this->forget(); |
| 1807 | - return $this->NewObj2('Less_Tree_Ruleset',array( $selectors, $rules)); //Less_Environment::$strictImports |
|
| 1807 | + return $this->NewObj2('Less_Tree_Ruleset', array($selectors, $rules)); //Less_Environment::$strictImports |
|
| 1808 | 1808 | } |
| 1809 | 1809 | } |
| 1810 | 1810 | |
@@ -1818,7 +1818,7 @@ discard block |
||
| 1818 | 1818 | * ex: width:100px; |
| 1819 | 1819 | * |
| 1820 | 1820 | */ |
| 1821 | - private function parseNameValue(){ |
|
| 1821 | + private function parseNameValue() { |
|
| 1822 | 1822 | |
| 1823 | 1823 | $index = $this->pos; |
| 1824 | 1824 | $this->save(); |
@@ -1826,55 +1826,55 @@ discard block |
||
| 1826 | 1826 | |
| 1827 | 1827 | //$match = $this->MatchReg('/\\G([a-zA-Z\-]+)\s*:\s*((?:\'")?[a-zA-Z0-9\-% \.,!]+?(?:\'")?)\s*([;}])/'); |
| 1828 | 1828 | $match = $this->MatchReg('/\\G([a-zA-Z\-]+)\s*:\s*([\'"]?[#a-zA-Z0-9\-%\.,]+?[\'"]?) *(! *important)?\s*([;}])/'); |
| 1829 | - if( $match ){ |
|
| 1829 | + if ($match) { |
|
| 1830 | 1830 | |
| 1831 | - if( $match[4] == '}' ){ |
|
| 1832 | - $this->pos = $index + strlen($match[0])-1; |
|
| 1831 | + if ($match[4]=='}') { |
|
| 1832 | + $this->pos = $index+strlen($match[0])-1; |
|
| 1833 | 1833 | } |
| 1834 | 1834 | |
| 1835 | - if( $match[3] ){ |
|
| 1835 | + if ($match[3]) { |
|
| 1836 | 1836 | $match[2] .= ' !important'; |
| 1837 | 1837 | } |
| 1838 | 1838 | |
| 1839 | - return $this->NewObj4('Less_Tree_NameValue',array( $match[1], $match[2], $index, $this->env->currentFileInfo)); |
|
| 1839 | + return $this->NewObj4('Less_Tree_NameValue', array($match[1], $match[2], $index, $this->env->currentFileInfo)); |
|
| 1840 | 1840 | } |
| 1841 | 1841 | |
| 1842 | 1842 | $this->restore(); |
| 1843 | 1843 | } |
| 1844 | 1844 | |
| 1845 | 1845 | |
| 1846 | - private function parseRule( $tryAnonymous = null ){ |
|
| 1846 | + private function parseRule($tryAnonymous = null) { |
|
| 1847 | 1847 | |
| 1848 | 1848 | $merge = false; |
| 1849 | 1849 | $startOfRule = $this->pos; |
| 1850 | 1850 | |
| 1851 | 1851 | $c = $this->input[$this->pos]; |
| 1852 | - if( $c === '.' || $c === '#' || $c === '&' ){ |
|
| 1852 | + if ($c==='.' || $c==='#' || $c==='&') { |
|
| 1853 | 1853 | return; |
| 1854 | 1854 | } |
| 1855 | 1855 | |
| 1856 | 1856 | $this->save(); |
| 1857 | - $name = $this->MatchFuncs( array('parseVariable','parseRuleProperty')); |
|
| 1857 | + $name = $this->MatchFuncs(array('parseVariable', 'parseRuleProperty')); |
|
| 1858 | 1858 | |
| 1859 | - if( $name ){ |
|
| 1859 | + if ($name) { |
|
| 1860 | 1860 | |
| 1861 | 1861 | $isVariable = is_string($name); |
| 1862 | 1862 | |
| 1863 | 1863 | $value = null; |
| 1864 | - if( $isVariable ){ |
|
| 1864 | + if ($isVariable) { |
|
| 1865 | 1865 | $value = $this->parseDetachedRuleset(); |
| 1866 | 1866 | } |
| 1867 | 1867 | |
| 1868 | 1868 | $important = null; |
| 1869 | - if( !$value ){ |
|
| 1869 | + if (!$value) { |
|
| 1870 | 1870 | |
| 1871 | 1871 | // prefer to try to parse first if its a variable or we are compressing |
| 1872 | 1872 | // but always fallback on the other one |
| 1873 | 1873 | //if( !$tryAnonymous && is_string($name) && $name[0] === '@' ){ |
| 1874 | - if( !$tryAnonymous && (Less_Parser::$options['compress'] || $isVariable) ){ |
|
| 1875 | - $value = $this->MatchFuncs( array('parseValue','parseAnonymousValue')); |
|
| 1876 | - }else{ |
|
| 1877 | - $value = $this->MatchFuncs( array('parseAnonymousValue','parseValue')); |
|
| 1874 | + if (!$tryAnonymous && (Less_Parser::$options['compress'] || $isVariable)) { |
|
| 1875 | + $value = $this->MatchFuncs(array('parseValue', 'parseAnonymousValue')); |
|
| 1876 | + }else { |
|
| 1877 | + $value = $this->MatchFuncs(array('parseAnonymousValue', 'parseValue')); |
|
| 1878 | 1878 | } |
| 1879 | 1879 | |
| 1880 | 1880 | $important = $this->parseImportant(); |
@@ -1882,35 +1882,35 @@ discard block |
||
| 1882 | 1882 | // a name returned by this.ruleProperty() is always an array of the form: |
| 1883 | 1883 | // [string-1, ..., string-n, ""] or [string-1, ..., string-n, "+"] |
| 1884 | 1884 | // where each item is a tree.Keyword or tree.Variable |
| 1885 | - if( !$isVariable && is_array($name) ){ |
|
| 1885 | + if (!$isVariable && is_array($name)) { |
|
| 1886 | 1886 | $nm = array_pop($name); |
| 1887 | - if( $nm->value ){ |
|
| 1887 | + if ($nm->value) { |
|
| 1888 | 1888 | $merge = $nm->value; |
| 1889 | 1889 | } |
| 1890 | 1890 | } |
| 1891 | 1891 | } |
| 1892 | 1892 | |
| 1893 | 1893 | |
| 1894 | - if( $value && $this->parseEnd() ){ |
|
| 1894 | + if ($value && $this->parseEnd()) { |
|
| 1895 | 1895 | $this->forget(); |
| 1896 | - return $this->NewObj6('Less_Tree_Rule',array( $name, $value, $important, $merge, $startOfRule, $this->env->currentFileInfo)); |
|
| 1897 | - }else{ |
|
| 1896 | + return $this->NewObj6('Less_Tree_Rule', array($name, $value, $important, $merge, $startOfRule, $this->env->currentFileInfo)); |
|
| 1897 | + }else { |
|
| 1898 | 1898 | $this->furthest = $this->pos; |
| 1899 | 1899 | $this->restore(); |
| 1900 | - if( $value && !$tryAnonymous ){ |
|
| 1900 | + if ($value && !$tryAnonymous) { |
|
| 1901 | 1901 | return $this->parseRule(true); |
| 1902 | 1902 | } |
| 1903 | 1903 | } |
| 1904 | - }else{ |
|
| 1904 | + }else { |
|
| 1905 | 1905 | $this->forget(); |
| 1906 | 1906 | } |
| 1907 | 1907 | } |
| 1908 | 1908 | |
| 1909 | - function parseAnonymousValue(){ |
|
| 1909 | + function parseAnonymousValue() { |
|
| 1910 | 1910 | |
| 1911 | - if( preg_match('/\\G([^@+\/\'"*`(;{}-]*);/',$this->input, $match, 0, $this->pos) ){ |
|
| 1911 | + if (preg_match('/\\G([^@+\/\'"*`(;{}-]*);/', $this->input, $match, 0, $this->pos)) { |
|
| 1912 | 1912 | $this->pos += strlen($match[1]); |
| 1913 | - return $this->NewObj1('Less_Tree_Anonymous',$match[1]); |
|
| 1913 | + return $this->NewObj1('Less_Tree_Anonymous', $match[1]); |
|
| 1914 | 1914 | } |
| 1915 | 1915 | } |
| 1916 | 1916 | |
@@ -1924,25 +1924,25 @@ discard block |
||
| 1924 | 1924 | // file-system operation. The function used for importing is |
| 1925 | 1925 | // stored in `import`, which we pass to the Import constructor. |
| 1926 | 1926 | // |
| 1927 | - private function parseImport(){ |
|
| 1927 | + private function parseImport() { |
|
| 1928 | 1928 | |
| 1929 | 1929 | $this->save(); |
| 1930 | 1930 | |
| 1931 | 1931 | $dir = $this->MatchReg('/\\G@import?\s+/'); |
| 1932 | 1932 | |
| 1933 | - if( $dir ){ |
|
| 1933 | + if ($dir) { |
|
| 1934 | 1934 | $options = $this->parseImportOptions(); |
| 1935 | - $path = $this->MatchFuncs( array('parseEntitiesQuoted','parseEntitiesUrl')); |
|
| 1935 | + $path = $this->MatchFuncs(array('parseEntitiesQuoted', 'parseEntitiesUrl')); |
|
| 1936 | 1936 | |
| 1937 | - if( $path ){ |
|
| 1937 | + if ($path) { |
|
| 1938 | 1938 | $features = $this->parseMediaFeatures(); |
| 1939 | - if( $this->MatchChar(';') ){ |
|
| 1940 | - if( $features ){ |
|
| 1941 | - $features = $this->NewObj1('Less_Tree_Value',$features); |
|
| 1939 | + if ($this->MatchChar(';')) { |
|
| 1940 | + if ($features) { |
|
| 1941 | + $features = $this->NewObj1('Less_Tree_Value', $features); |
|
| 1942 | 1942 | } |
| 1943 | 1943 | |
| 1944 | 1944 | $this->forget(); |
| 1945 | - return $this->NewObj5('Less_Tree_Import',array( $path, $features, $options, $this->pos, $this->env->currentFileInfo)); |
|
| 1945 | + return $this->NewObj5('Less_Tree_Import', array($path, $features, $options, $this->pos, $this->env->currentFileInfo)); |
|
| 1946 | 1946 | } |
| 1947 | 1947 | } |
| 1948 | 1948 | } |
@@ -1950,19 +1950,19 @@ discard block |
||
| 1950 | 1950 | $this->restore(); |
| 1951 | 1951 | } |
| 1952 | 1952 | |
| 1953 | - private function parseImportOptions(){ |
|
| 1953 | + private function parseImportOptions() { |
|
| 1954 | 1954 | |
| 1955 | 1955 | $options = array(); |
| 1956 | 1956 | |
| 1957 | 1957 | // list of options, surrounded by parens |
| 1958 | - if( !$this->MatchChar('(') ){ |
|
| 1958 | + if (!$this->MatchChar('(')) { |
|
| 1959 | 1959 | return $options; |
| 1960 | 1960 | } |
| 1961 | - do{ |
|
| 1961 | + do { |
|
| 1962 | 1962 | $optionName = $this->parseImportOption(); |
| 1963 | - if( $optionName ){ |
|
| 1963 | + if ($optionName) { |
|
| 1964 | 1964 | $value = true; |
| 1965 | - switch( $optionName ){ |
|
| 1965 | + switch ($optionName) { |
|
| 1966 | 1966 | case "css": |
| 1967 | 1967 | $optionName = "less"; |
| 1968 | 1968 | $value = false; |
@@ -1973,16 +1973,16 @@ discard block |
||
| 1973 | 1973 | break; |
| 1974 | 1974 | } |
| 1975 | 1975 | $options[$optionName] = $value; |
| 1976 | - if( !$this->MatchChar(',') ){ break; } |
|
| 1976 | + if (!$this->MatchChar(',')) { break; } |
|
| 1977 | 1977 | } |
| 1978 | - }while( $optionName ); |
|
| 1978 | + } while ($optionName); |
|
| 1979 | 1979 | $this->expectChar(')'); |
| 1980 | 1980 | return $options; |
| 1981 | 1981 | } |
| 1982 | 1982 | |
| 1983 | - private function parseImportOption(){ |
|
| 1983 | + private function parseImportOption() { |
|
| 1984 | 1984 | $opt = $this->MatchReg('/\\G(less|css|multiple|once|inline|reference)/'); |
| 1985 | - if( $opt ){ |
|
| 1985 | + if ($opt) { |
|
| 1986 | 1986 | return $opt[1]; |
| 1987 | 1987 | } |
| 1988 | 1988 | } |
@@ -1990,43 +1990,43 @@ discard block |
||
| 1990 | 1990 | private function parseMediaFeature() { |
| 1991 | 1991 | $nodes = array(); |
| 1992 | 1992 | |
| 1993 | - do{ |
|
| 1994 | - $e = $this->MatchFuncs(array('parseEntitiesKeyword','parseEntitiesVariable')); |
|
| 1995 | - if( $e ){ |
|
| 1993 | + do { |
|
| 1994 | + $e = $this->MatchFuncs(array('parseEntitiesKeyword', 'parseEntitiesVariable')); |
|
| 1995 | + if ($e) { |
|
| 1996 | 1996 | $nodes[] = $e; |
| 1997 | 1997 | } elseif ($this->MatchChar('(')) { |
| 1998 | 1998 | $p = $this->parseProperty(); |
| 1999 | 1999 | $e = $this->parseValue(); |
| 2000 | 2000 | if ($this->MatchChar(')')) { |
| 2001 | 2001 | if ($p && $e) { |
| 2002 | - $r = $this->NewObj7('Less_Tree_Rule', array( $p, $e, null, null, $this->pos, $this->env->currentFileInfo, true)); |
|
| 2003 | - $nodes[] = $this->NewObj1('Less_Tree_Paren',$r); |
|
| 2002 | + $r = $this->NewObj7('Less_Tree_Rule', array($p, $e, null, null, $this->pos, $this->env->currentFileInfo, true)); |
|
| 2003 | + $nodes[] = $this->NewObj1('Less_Tree_Paren', $r); |
|
| 2004 | 2004 | } elseif ($e) { |
| 2005 | - $nodes[] = $this->NewObj1('Less_Tree_Paren',$e); |
|
| 2006 | - } else { |
|
| 2005 | + $nodes[] = $this->NewObj1('Less_Tree_Paren', $e); |
|
| 2006 | + }else { |
|
| 2007 | 2007 | return null; |
| 2008 | 2008 | } |
| 2009 | - } else |
|
| 2009 | + }else |
|
| 2010 | 2010 | return null; |
| 2011 | 2011 | } |
| 2012 | 2012 | } while ($e); |
| 2013 | 2013 | |
| 2014 | 2014 | if ($nodes) { |
| 2015 | - return $this->NewObj1('Less_Tree_Expression',$nodes); |
|
| 2015 | + return $this->NewObj1('Less_Tree_Expression', $nodes); |
|
| 2016 | 2016 | } |
| 2017 | 2017 | } |
| 2018 | 2018 | |
| 2019 | 2019 | private function parseMediaFeatures() { |
| 2020 | 2020 | $features = array(); |
| 2021 | 2021 | |
| 2022 | - do{ |
|
| 2022 | + do { |
|
| 2023 | 2023 | $e = $this->parseMediaFeature(); |
| 2024 | - if( $e ){ |
|
| 2024 | + if ($e) { |
|
| 2025 | 2025 | $features[] = $e; |
| 2026 | 2026 | if (!$this->MatchChar(',')) break; |
| 2027 | - }else{ |
|
| 2027 | + }else { |
|
| 2028 | 2028 | $e = $this->parseEntitiesVariable(); |
| 2029 | - if( $e ){ |
|
| 2029 | + if ($e) { |
|
| 2030 | 2030 | $features[] = $e; |
| 2031 | 2031 | if (!$this->MatchChar(',')) break; |
| 2032 | 2032 | } |
@@ -2037,12 +2037,12 @@ discard block |
||
| 2037 | 2037 | } |
| 2038 | 2038 | |
| 2039 | 2039 | private function parseMedia() { |
| 2040 | - if( $this->MatchReg('/\\G@media/') ){ |
|
| 2040 | + if ($this->MatchReg('/\\G@media/')) { |
|
| 2041 | 2041 | $features = $this->parseMediaFeatures(); |
| 2042 | 2042 | $rules = $this->parseBlock(); |
| 2043 | 2043 | |
| 2044 | - if( is_array($rules) ){ |
|
| 2045 | - return $this->NewObj4('Less_Tree_Media',array( $rules, $features, $this->pos, $this->env->currentFileInfo)); |
|
| 2044 | + if (is_array($rules)) { |
|
| 2045 | + return $this->NewObj4('Less_Tree_Media', array($rules, $features, $this->pos, $this->env->currentFileInfo)); |
|
| 2046 | 2046 | } |
| 2047 | 2047 | } |
| 2048 | 2048 | } |
@@ -2053,9 +2053,9 @@ discard block |
||
| 2053 | 2053 | // |
| 2054 | 2054 | // @charset "utf-8"; |
| 2055 | 2055 | // |
| 2056 | - private function parseDirective(){ |
|
| 2056 | + private function parseDirective() { |
|
| 2057 | 2057 | |
| 2058 | - if( !$this->PeekChar('@') ){ |
|
| 2058 | + if (!$this->PeekChar('@')) { |
|
| 2059 | 2059 | return; |
| 2060 | 2060 | } |
| 2061 | 2061 | |
@@ -2067,8 +2067,8 @@ discard block |
||
| 2067 | 2067 | $hasUnknown = false; |
| 2068 | 2068 | |
| 2069 | 2069 | |
| 2070 | - $value = $this->MatchFuncs(array('parseImport','parseMedia')); |
|
| 2071 | - if( $value ){ |
|
| 2070 | + $value = $this->MatchFuncs(array('parseImport', 'parseMedia')); |
|
| 2071 | + if ($value) { |
|
| 2072 | 2072 | return $value; |
| 2073 | 2073 | } |
| 2074 | 2074 | |
@@ -2076,18 +2076,18 @@ discard block |
||
| 2076 | 2076 | |
| 2077 | 2077 | $name = $this->MatchReg('/\\G@[a-z-]+/'); |
| 2078 | 2078 | |
| 2079 | - if( !$name ) return; |
|
| 2079 | + if (!$name) return; |
|
| 2080 | 2080 | $name = $name[0]; |
| 2081 | 2081 | |
| 2082 | 2082 | |
| 2083 | 2083 | $nonVendorSpecificName = $name; |
| 2084 | - $pos = strpos($name,'-', 2); |
|
| 2085 | - if( $name[1] == '-' && $pos > 0 ){ |
|
| 2086 | - $nonVendorSpecificName = "@" . substr($name, $pos + 1); |
|
| 2084 | + $pos = strpos($name, '-', 2); |
|
| 2085 | + if ($name[1]=='-' && $pos>0) { |
|
| 2086 | + $nonVendorSpecificName = "@".substr($name, $pos+1); |
|
| 2087 | 2087 | } |
| 2088 | 2088 | |
| 2089 | 2089 | |
| 2090 | - switch( $nonVendorSpecificName ){ |
|
| 2090 | + switch ($nonVendorSpecificName) { |
|
| 2091 | 2091 | /* |
| 2092 | 2092 | case "@font-face": |
| 2093 | 2093 | case "@viewport": |
@@ -2129,31 +2129,31 @@ discard block |
||
| 2129 | 2129 | break; |
| 2130 | 2130 | } |
| 2131 | 2131 | |
| 2132 | - if( $hasIdentifier ){ |
|
| 2132 | + if ($hasIdentifier) { |
|
| 2133 | 2133 | $value = $this->parseEntity(); |
| 2134 | - if( !$value ){ |
|
| 2135 | - $this->error("expected " . $name . " identifier"); |
|
| 2134 | + if (!$value) { |
|
| 2135 | + $this->error("expected ".$name." identifier"); |
|
| 2136 | 2136 | } |
| 2137 | - } else if( $hasExpression ){ |
|
| 2137 | + }else if ($hasExpression) { |
|
| 2138 | 2138 | $value = $this->parseExpression(); |
| 2139 | - if( !$value ){ |
|
| 2140 | - $this->error("expected " . $name. " expression"); |
|
| 2139 | + if (!$value) { |
|
| 2140 | + $this->error("expected ".$name." expression"); |
|
| 2141 | 2141 | } |
| 2142 | - } else if ($hasUnknown) { |
|
| 2142 | + }else if ($hasUnknown) { |
|
| 2143 | 2143 | |
| 2144 | 2144 | $value = $this->MatchReg('/\\G[^{;]+/'); |
| 2145 | - if( $value ){ |
|
| 2146 | - $value = $this->NewObj1('Less_Tree_Anonymous',trim($value[0])); |
|
| 2145 | + if ($value) { |
|
| 2146 | + $value = $this->NewObj1('Less_Tree_Anonymous', trim($value[0])); |
|
| 2147 | 2147 | } |
| 2148 | 2148 | } |
| 2149 | 2149 | |
| 2150 | - if( $hasBlock ){ |
|
| 2150 | + if ($hasBlock) { |
|
| 2151 | 2151 | $rules = $this->parseBlockRuleset(); |
| 2152 | 2152 | } |
| 2153 | 2153 | |
| 2154 | - if( $rules || (!$hasBlock && $value && $this->MatchChar(';'))) { |
|
| 2154 | + if ($rules || (!$hasBlock && $value && $this->MatchChar(';'))) { |
|
| 2155 | 2155 | $this->forget(); |
| 2156 | - return $this->NewObj5('Less_Tree_Directive',array($name, $value, $rules, $index, $this->env->currentFileInfo)); |
|
| 2156 | + return $this->NewObj5('Less_Tree_Directive', array($name, $value, $rules, $index, $this->env->currentFileInfo)); |
|
| 2157 | 2157 | } |
| 2158 | 2158 | |
| 2159 | 2159 | $this->restore(); |
@@ -2168,37 +2168,37 @@ discard block |
||
| 2168 | 2168 | // In a Rule, a Value represents everything after the `:`, |
| 2169 | 2169 | // and before the `;`. |
| 2170 | 2170 | // |
| 2171 | - private function parseValue(){ |
|
| 2171 | + private function parseValue() { |
|
| 2172 | 2172 | $expressions = array(); |
| 2173 | 2173 | |
| 2174 | - do{ |
|
| 2174 | + do { |
|
| 2175 | 2175 | $e = $this->parseExpression(); |
| 2176 | - if( $e ){ |
|
| 2176 | + if ($e) { |
|
| 2177 | 2177 | $expressions[] = $e; |
| 2178 | - if (! $this->MatchChar(',')) { |
|
| 2178 | + if (!$this->MatchChar(',')) { |
|
| 2179 | 2179 | break; |
| 2180 | 2180 | } |
| 2181 | 2181 | } |
| 2182 | - }while($e); |
|
| 2182 | + } while ($e); |
|
| 2183 | 2183 | |
| 2184 | - if( $expressions ){ |
|
| 2185 | - return $this->NewObj1('Less_Tree_Value',$expressions); |
|
| 2184 | + if ($expressions) { |
|
| 2185 | + return $this->NewObj1('Less_Tree_Value', $expressions); |
|
| 2186 | 2186 | } |
| 2187 | 2187 | } |
| 2188 | 2188 | |
| 2189 | - private function parseImportant (){ |
|
| 2190 | - if( $this->PeekChar('!') && $this->MatchReg('/\\G! *important/') ){ |
|
| 2189 | + private function parseImportant() { |
|
| 2190 | + if ($this->PeekChar('!') && $this->MatchReg('/\\G! *important/')) { |
|
| 2191 | 2191 | return ' !important'; |
| 2192 | 2192 | } |
| 2193 | 2193 | } |
| 2194 | 2194 | |
| 2195 | - private function parseSub (){ |
|
| 2195 | + private function parseSub() { |
|
| 2196 | 2196 | |
| 2197 | - if( $this->MatchChar('(') ){ |
|
| 2197 | + if ($this->MatchChar('(')) { |
|
| 2198 | 2198 | $a = $this->parseAddition(); |
| 2199 | - if( $a ){ |
|
| 2199 | + if ($a) { |
|
| 2200 | 2200 | $this->expectChar(')'); |
| 2201 | - return $this->NewObj2('Less_Tree_Expression',array( array($a), true) ); //instead of $e->parens = true so the value is cached |
|
| 2201 | + return $this->NewObj2('Less_Tree_Expression', array(array($a), true)); //instead of $e->parens = true so the value is cached |
|
| 2202 | 2202 | } |
| 2203 | 2203 | } |
| 2204 | 2204 | } |
@@ -2209,33 +2209,33 @@ discard block |
||
| 2209 | 2209 | * |
| 2210 | 2210 | * @return Less_Tree_Operation|null |
| 2211 | 2211 | */ |
| 2212 | - function parseMultiplication(){ |
|
| 2212 | + function parseMultiplication() { |
|
| 2213 | 2213 | |
| 2214 | 2214 | $return = $m = $this->parseOperand(); |
| 2215 | - if( $return ){ |
|
| 2216 | - while( true ){ |
|
| 2215 | + if ($return) { |
|
| 2216 | + while (true) { |
|
| 2217 | 2217 | |
| 2218 | 2218 | $isSpaced = $this->isWhitespace( -1 ); |
| 2219 | 2219 | |
| 2220 | - if( $this->PeekReg('/\\G\/[*\/]/') ){ |
|
| 2220 | + if ($this->PeekReg('/\\G\/[*\/]/')) { |
|
| 2221 | 2221 | break; |
| 2222 | 2222 | } |
| 2223 | 2223 | |
| 2224 | 2224 | $op = $this->MatchChar('/'); |
| 2225 | - if( !$op ){ |
|
| 2225 | + if (!$op) { |
|
| 2226 | 2226 | $op = $this->MatchChar('*'); |
| 2227 | - if( !$op ){ |
|
| 2227 | + if (!$op) { |
|
| 2228 | 2228 | break; |
| 2229 | 2229 | } |
| 2230 | 2230 | } |
| 2231 | 2231 | |
| 2232 | 2232 | $a = $this->parseOperand(); |
| 2233 | 2233 | |
| 2234 | - if(!$a) { break; } |
|
| 2234 | + if (!$a) { break; } |
|
| 2235 | 2235 | |
| 2236 | 2236 | $m->parensInOp = true; |
| 2237 | 2237 | $a->parensInOp = true; |
| 2238 | - $return = $this->NewObj3('Less_Tree_Operation',array( $op, array( $return, $a ), $isSpaced) ); |
|
| 2238 | + $return = $this->NewObj3('Less_Tree_Operation', array($op, array($return, $a), $isSpaced)); |
|
| 2239 | 2239 | } |
| 2240 | 2240 | } |
| 2241 | 2241 | return $return; |
@@ -2248,34 +2248,34 @@ discard block |
||
| 2248 | 2248 | * |
| 2249 | 2249 | * @return Less_Tree_Operation|null |
| 2250 | 2250 | */ |
| 2251 | - private function parseAddition (){ |
|
| 2251 | + private function parseAddition() { |
|
| 2252 | 2252 | |
| 2253 | 2253 | $return = $m = $this->parseMultiplication(); |
| 2254 | - if( $return ){ |
|
| 2255 | - while( true ){ |
|
| 2254 | + if ($return) { |
|
| 2255 | + while (true) { |
|
| 2256 | 2256 | |
| 2257 | 2257 | $isSpaced = $this->isWhitespace( -1 ); |
| 2258 | 2258 | |
| 2259 | 2259 | $op = $this->MatchReg('/\\G[-+]\s+/'); |
| 2260 | - if( $op ){ |
|
| 2260 | + if ($op) { |
|
| 2261 | 2261 | $op = $op[0]; |
| 2262 | - }else{ |
|
| 2263 | - if( !$isSpaced ){ |
|
| 2264 | - $op = $this->match(array('#+','#-')); |
|
| 2262 | + }else { |
|
| 2263 | + if (!$isSpaced) { |
|
| 2264 | + $op = $this->match(array('#+', '#-')); |
|
| 2265 | 2265 | } |
| 2266 | - if( !$op ){ |
|
| 2266 | + if (!$op) { |
|
| 2267 | 2267 | break; |
| 2268 | 2268 | } |
| 2269 | 2269 | } |
| 2270 | 2270 | |
| 2271 | 2271 | $a = $this->parseMultiplication(); |
| 2272 | - if( !$a ){ |
|
| 2272 | + if (!$a) { |
|
| 2273 | 2273 | break; |
| 2274 | 2274 | } |
| 2275 | 2275 | |
| 2276 | 2276 | $m->parensInOp = true; |
| 2277 | 2277 | $a->parensInOp = true; |
| 2278 | - $return = $this->NewObj3('Less_Tree_Operation',array($op, array($return, $a), $isSpaced)); |
|
| 2278 | + $return = $this->NewObj3('Less_Tree_Operation', array($op, array($return, $a), $isSpaced)); |
|
| 2279 | 2279 | } |
| 2280 | 2280 | } |
| 2281 | 2281 | |
@@ -2291,17 +2291,17 @@ discard block |
||
| 2291 | 2291 | private function parseConditions() { |
| 2292 | 2292 | $index = $this->pos; |
| 2293 | 2293 | $return = $a = $this->parseCondition(); |
| 2294 | - if( $a ){ |
|
| 2295 | - while( true ){ |
|
| 2296 | - if( !$this->PeekReg('/\\G,\s*(not\s*)?\(/') || !$this->MatchChar(',') ){ |
|
| 2294 | + if ($a) { |
|
| 2295 | + while (true) { |
|
| 2296 | + if (!$this->PeekReg('/\\G,\s*(not\s*)?\(/') || !$this->MatchChar(',')) { |
|
| 2297 | 2297 | break; |
| 2298 | 2298 | } |
| 2299 | 2299 | $b = $this->parseCondition(); |
| 2300 | - if( !$b ){ |
|
| 2300 | + if (!$b) { |
|
| 2301 | 2301 | break; |
| 2302 | 2302 | } |
| 2303 | 2303 | |
| 2304 | - $return = $this->NewObj4('Less_Tree_Condition',array('or', $return, $b, $index)); |
|
| 2304 | + $return = $this->NewObj4('Less_Tree_Condition', array('or', $return, $b, $index)); |
|
| 2305 | 2305 | } |
| 2306 | 2306 | return $return; |
| 2307 | 2307 | } |
@@ -2314,23 +2314,23 @@ discard block |
||
| 2314 | 2314 | |
| 2315 | 2315 | if ($this->MatchReg('/\\Gnot/')) $negate = true; |
| 2316 | 2316 | $this->expectChar('('); |
| 2317 | - $a = $this->MatchFuncs(array('parseAddition','parseEntitiesKeyword','parseEntitiesQuoted')); |
|
| 2317 | + $a = $this->MatchFuncs(array('parseAddition', 'parseEntitiesKeyword', 'parseEntitiesQuoted')); |
|
| 2318 | 2318 | |
| 2319 | - if( $a ){ |
|
| 2319 | + if ($a) { |
|
| 2320 | 2320 | $op = $this->MatchReg('/\\G(?:>=|<=|=<|[<=>])/'); |
| 2321 | - if( $op ){ |
|
| 2322 | - $b = $this->MatchFuncs(array('parseAddition','parseEntitiesKeyword','parseEntitiesQuoted')); |
|
| 2323 | - if( $b ){ |
|
| 2324 | - $c = $this->NewObj5('Less_Tree_Condition',array($op[0], $a, $b, $index, $negate)); |
|
| 2325 | - } else { |
|
| 2321 | + if ($op) { |
|
| 2322 | + $b = $this->MatchFuncs(array('parseAddition', 'parseEntitiesKeyword', 'parseEntitiesQuoted')); |
|
| 2323 | + if ($b) { |
|
| 2324 | + $c = $this->NewObj5('Less_Tree_Condition', array($op[0], $a, $b, $index, $negate)); |
|
| 2325 | + }else { |
|
| 2326 | 2326 | $this->Error('Unexpected expression'); |
| 2327 | 2327 | } |
| 2328 | - } else { |
|
| 2329 | - $k = $this->NewObj1('Less_Tree_Keyword','true'); |
|
| 2330 | - $c = $this->NewObj5('Less_Tree_Condition',array('=', $a, $k, $index, $negate)); |
|
| 2328 | + }else { |
|
| 2329 | + $k = $this->NewObj1('Less_Tree_Keyword', 'true'); |
|
| 2330 | + $c = $this->NewObj5('Less_Tree_Condition', array('=', $a, $k, $index, $negate)); |
|
| 2331 | 2331 | } |
| 2332 | 2332 | $this->expectChar(')'); |
| 2333 | - return $this->MatchReg('/\\Gand/') ? $this->NewObj3('Less_Tree_Condition',array('and', $c, $this->parseCondition())) : $c; |
|
| 2333 | + return $this->MatchReg('/\\Gand/') ? $this->NewObj3('Less_Tree_Condition', array('and', $c, $this->parseCondition())) : $c; |
|
| 2334 | 2334 | } |
| 2335 | 2335 | } |
| 2336 | 2336 | |
@@ -2339,23 +2339,23 @@ discard block |
||
| 2339 | 2339 | * such as a Color, or a Variable |
| 2340 | 2340 | * |
| 2341 | 2341 | */ |
| 2342 | - private function parseOperand (){ |
|
| 2342 | + private function parseOperand() { |
|
| 2343 | 2343 | |
| 2344 | 2344 | $negate = false; |
| 2345 | 2345 | $offset = $this->pos+1; |
| 2346 | - if( $offset >= $this->input_len ){ |
|
| 2346 | + if ($offset>=$this->input_len) { |
|
| 2347 | 2347 | return; |
| 2348 | 2348 | } |
| 2349 | 2349 | $char = $this->input[$offset]; |
| 2350 | - if( $char === '@' || $char === '(' ){ |
|
| 2350 | + if ($char==='@' || $char==='(') { |
|
| 2351 | 2351 | $negate = $this->MatchChar('-'); |
| 2352 | 2352 | } |
| 2353 | 2353 | |
| 2354 | - $o = $this->MatchFuncs(array('parseSub','parseEntitiesDimension','parseEntitiesColor','parseEntitiesVariable','parseEntitiesCall')); |
|
| 2354 | + $o = $this->MatchFuncs(array('parseSub', 'parseEntitiesDimension', 'parseEntitiesColor', 'parseEntitiesVariable', 'parseEntitiesCall')); |
|
| 2355 | 2355 | |
| 2356 | - if( $negate ){ |
|
| 2356 | + if ($negate) { |
|
| 2357 | 2357 | $o->parensInOp = true; |
| 2358 | - $o = $this->NewObj1('Less_Tree_Negative',$o); |
|
| 2358 | + $o = $this->NewObj1('Less_Tree_Negative', $o); |
|
| 2359 | 2359 | } |
| 2360 | 2360 | |
| 2361 | 2361 | return $o; |
@@ -2371,25 +2371,25 @@ discard block |
||
| 2371 | 2371 | * |
| 2372 | 2372 | * @return Less_Tree_Expression|null |
| 2373 | 2373 | */ |
| 2374 | - private function parseExpression (){ |
|
| 2374 | + private function parseExpression() { |
|
| 2375 | 2375 | $entities = array(); |
| 2376 | 2376 | |
| 2377 | - do{ |
|
| 2378 | - $e = $this->MatchFuncs(array('parseAddition','parseEntity')); |
|
| 2379 | - if( $e ){ |
|
| 2377 | + do { |
|
| 2378 | + $e = $this->MatchFuncs(array('parseAddition', 'parseEntity')); |
|
| 2379 | + if ($e) { |
|
| 2380 | 2380 | $entities[] = $e; |
| 2381 | 2381 | // operations do not allow keyword "/" dimension (e.g. small/20px) so we support that here |
| 2382 | - if( !$this->PeekReg('/\\G\/[\/*]/') ){ |
|
| 2382 | + if (!$this->PeekReg('/\\G\/[\/*]/')) { |
|
| 2383 | 2383 | $delim = $this->MatchChar('/'); |
| 2384 | - if( $delim ){ |
|
| 2385 | - $entities[] = $this->NewObj1('Less_Tree_Anonymous',$delim); |
|
| 2384 | + if ($delim) { |
|
| 2385 | + $entities[] = $this->NewObj1('Less_Tree_Anonymous', $delim); |
|
| 2386 | 2386 | } |
| 2387 | 2387 | } |
| 2388 | 2388 | } |
| 2389 | - }while($e); |
|
| 2389 | + } while ($e); |
|
| 2390 | 2390 | |
| 2391 | - if( $entities ){ |
|
| 2392 | - return $this->NewObj1('Less_Tree_Expression',$entities); |
|
| 2391 | + if ($entities) { |
|
| 2392 | + return $this->NewObj1('Less_Tree_Expression', $entities); |
|
| 2393 | 2393 | } |
| 2394 | 2394 | } |
| 2395 | 2395 | |
@@ -2400,9 +2400,9 @@ discard block |
||
| 2400 | 2400 | * |
| 2401 | 2401 | * @return string |
| 2402 | 2402 | */ |
| 2403 | - private function parseProperty (){ |
|
| 2403 | + private function parseProperty() { |
|
| 2404 | 2404 | $name = $this->MatchReg('/\\G(\*?-?[_a-zA-Z0-9-]+)\s*:/'); |
| 2405 | - if( $name ){ |
|
| 2405 | + if ($name) { |
|
| 2406 | 2406 | return $name[1]; |
| 2407 | 2407 | } |
| 2408 | 2408 | } |
@@ -2414,30 +2414,30 @@ discard block |
||
| 2414 | 2414 | * |
| 2415 | 2415 | * @return string |
| 2416 | 2416 | */ |
| 2417 | - private function parseRuleProperty(){ |
|
| 2417 | + private function parseRuleProperty() { |
|
| 2418 | 2418 | $offset = $this->pos; |
| 2419 | 2419 | $name = array(); |
| 2420 | 2420 | $index = array(); |
| 2421 | 2421 | $length = 0; |
| 2422 | 2422 | |
| 2423 | 2423 | |
| 2424 | - $this->rulePropertyMatch('/\\G(\*?)/', $offset, $length, $index, $name ); |
|
| 2425 | - while( $this->rulePropertyMatch('/\\G((?:[\w-]+)|(?:@\{[\w-]+\}))/', $offset, $length, $index, $name )); // ! |
|
| 2424 | + $this->rulePropertyMatch('/\\G(\*?)/', $offset, $length, $index, $name); |
|
| 2425 | + while ($this->rulePropertyMatch('/\\G((?:[\w-]+)|(?:@\{[\w-]+\}))/', $offset, $length, $index, $name)); // ! |
|
| 2426 | 2426 | |
| 2427 | - if( (count($name) > 1) && $this->rulePropertyMatch('/\\G\s*((?:\+_|\+)?)\s*:/', $offset, $length, $index, $name) ){ |
|
| 2427 | + if ((count($name)>1) && $this->rulePropertyMatch('/\\G\s*((?:\+_|\+)?)\s*:/', $offset, $length, $index, $name)) { |
|
| 2428 | 2428 | // at last, we have the complete match now. move forward, |
| 2429 | 2429 | // convert name particles to tree objects and return: |
| 2430 | 2430 | $this->skipWhitespace($length); |
| 2431 | 2431 | |
| 2432 | - if( $name[0] === '' ){ |
|
| 2432 | + if ($name[0]==='') { |
|
| 2433 | 2433 | array_shift($name); |
| 2434 | 2434 | array_shift($index); |
| 2435 | 2435 | } |
| 2436 | - foreach($name as $k => $s ){ |
|
| 2437 | - if( !$s || $s[0] !== '@' ){ |
|
| 2438 | - $name[$k] = $this->NewObj1('Less_Tree_Keyword',$s); |
|
| 2439 | - }else{ |
|
| 2440 | - $name[$k] = $this->NewObj3('Less_Tree_Variable',array('@' . substr($s,2,-1), $index[$k], $this->env->currentFileInfo)); |
|
| 2436 | + foreach ($name as $k => $s) { |
|
| 2437 | + if (!$s || $s[0]!=='@') { |
|
| 2438 | + $name[$k] = $this->NewObj1('Less_Tree_Keyword', $s); |
|
| 2439 | + }else { |
|
| 2440 | + $name[$k] = $this->NewObj3('Less_Tree_Variable', array('@'.substr($s, 2, -1), $index[$k], $this->env->currentFileInfo)); |
|
| 2441 | 2441 | } |
| 2442 | 2442 | } |
| 2443 | 2443 | return $name; |
@@ -2446,10 +2446,10 @@ discard block |
||
| 2446 | 2446 | |
| 2447 | 2447 | } |
| 2448 | 2448 | |
| 2449 | - private function rulePropertyMatch( $re, &$offset, &$length, &$index, &$name ){ |
|
| 2449 | + private function rulePropertyMatch($re, &$offset, &$length, &$index, &$name) { |
|
| 2450 | 2450 | preg_match($re, $this->input, $a, 0, $offset); |
| 2451 | - if( $a ){ |
|
| 2452 | - $index[] = $this->pos + $length; |
|
| 2451 | + if ($a) { |
|
| 2452 | + $index[] = $this->pos+$length; |
|
| 2453 | 2453 | $length += strlen($a[0]); |
| 2454 | 2454 | $offset += strlen($a[0]); |
| 2455 | 2455 | $name[] = $a[1]; |
@@ -2457,11 +2457,11 @@ discard block |
||
| 2457 | 2457 | } |
| 2458 | 2458 | } |
| 2459 | 2459 | |
| 2460 | - public static function serializeVars( $vars ){ |
|
| 2460 | + public static function serializeVars($vars) { |
|
| 2461 | 2461 | $s = ''; |
| 2462 | 2462 | |
| 2463 | - foreach($vars as $name => $value){ |
|
| 2464 | - $s .= (($name[0] === '@') ? '' : '@') . $name .': '. $value . ((substr($value,-1) === ';') ? '' : ';'); |
|
| 2463 | + foreach ($vars as $name => $value) { |
|
| 2464 | + $s .= (($name[0]==='@') ? '' : '@').$name.': '.$value.((substr($value, -1)===';') ? '' : ';'); |
|
| 2465 | 2465 | } |
| 2466 | 2466 | |
| 2467 | 2467 | return $s; |
@@ -2473,8 +2473,8 @@ discard block |
||
| 2473 | 2473 | * |
| 2474 | 2474 | * @param string $b |
| 2475 | 2475 | */ |
| 2476 | - public static function is_method($a,$b){ |
|
| 2477 | - return is_object($a) && method_exists($a,$b); |
|
| 2476 | + public static function is_method($a, $b) { |
|
| 2477 | + return is_object($a) && method_exists($a, $b); |
|
| 2478 | 2478 | } |
| 2479 | 2479 | |
| 2480 | 2480 | |
@@ -2483,17 +2483,17 @@ discard block |
||
| 2483 | 2483 | * eg: 1.499999 to 1 instead of 2 |
| 2484 | 2484 | * |
| 2485 | 2485 | */ |
| 2486 | - public static function round($i, $precision = 0){ |
|
| 2486 | + public static function round($i, $precision = 0) { |
|
| 2487 | 2487 | |
| 2488 | - $precision = pow(10,$precision); |
|
| 2489 | - $i = $i*$precision; |
|
| 2488 | + $precision = pow(10, $precision); |
|
| 2489 | + $i = $i * $precision; |
|
| 2490 | 2490 | |
| 2491 | 2491 | $ceil = ceil($i); |
| 2492 | 2492 | $floor = floor($i); |
| 2493 | - if( ($ceil - $i) <= ($i - $floor) ){ |
|
| 2494 | - return $ceil/$precision; |
|
| 2495 | - }else{ |
|
| 2496 | - return $floor/$precision; |
|
| 2493 | + if (($ceil-$i)<=($i-$floor)) { |
|
| 2494 | + return $ceil / $precision; |
|
| 2495 | + }else { |
|
| 2496 | + return $floor / $precision; |
|
| 2497 | 2497 | } |
| 2498 | 2498 | } |
| 2499 | 2499 | |
@@ -2503,77 +2503,77 @@ discard block |
||
| 2503 | 2503 | * |
| 2504 | 2504 | * @return mixed |
| 2505 | 2505 | */ |
| 2506 | - public function NewObj0($class){ |
|
| 2506 | + public function NewObj0($class) { |
|
| 2507 | 2507 | $obj = new $class(); |
| 2508 | - if( $this->CacheEnabled() ){ |
|
| 2508 | + if ($this->CacheEnabled()) { |
|
| 2509 | 2509 | $obj->cache_string = ' new '.$class.'()'; |
| 2510 | 2510 | } |
| 2511 | 2511 | return $obj; |
| 2512 | 2512 | } |
| 2513 | 2513 | |
| 2514 | - public function NewObj1($class, $arg){ |
|
| 2515 | - $obj = new $class( $arg ); |
|
| 2516 | - if( $this->CacheEnabled() ){ |
|
| 2514 | + public function NewObj1($class, $arg) { |
|
| 2515 | + $obj = new $class($arg); |
|
| 2516 | + if ($this->CacheEnabled()) { |
|
| 2517 | 2517 | $obj->cache_string = ' new '.$class.'('.Less_Parser::ArgString($arg).')'; |
| 2518 | 2518 | } |
| 2519 | 2519 | return $obj; |
| 2520 | 2520 | } |
| 2521 | 2521 | |
| 2522 | - public function NewObj2($class, $args){ |
|
| 2523 | - $obj = new $class( $args[0], $args[1] ); |
|
| 2524 | - if( $this->CacheEnabled() ){ |
|
| 2525 | - $this->ObjCache( $obj, $class, $args); |
|
| 2522 | + public function NewObj2($class, $args) { |
|
| 2523 | + $obj = new $class($args[0], $args[1]); |
|
| 2524 | + if ($this->CacheEnabled()) { |
|
| 2525 | + $this->ObjCache($obj, $class, $args); |
|
| 2526 | 2526 | } |
| 2527 | 2527 | return $obj; |
| 2528 | 2528 | } |
| 2529 | 2529 | |
| 2530 | - public function NewObj3($class, $args){ |
|
| 2531 | - $obj = new $class( $args[0], $args[1], $args[2] ); |
|
| 2532 | - if( $this->CacheEnabled() ){ |
|
| 2533 | - $this->ObjCache( $obj, $class, $args); |
|
| 2530 | + public function NewObj3($class, $args) { |
|
| 2531 | + $obj = new $class($args[0], $args[1], $args[2]); |
|
| 2532 | + if ($this->CacheEnabled()) { |
|
| 2533 | + $this->ObjCache($obj, $class, $args); |
|
| 2534 | 2534 | } |
| 2535 | 2535 | return $obj; |
| 2536 | 2536 | } |
| 2537 | 2537 | |
| 2538 | - public function NewObj4($class, $args){ |
|
| 2539 | - $obj = new $class( $args[0], $args[1], $args[2], $args[3] ); |
|
| 2540 | - if( $this->CacheEnabled() ){ |
|
| 2541 | - $this->ObjCache( $obj, $class, $args); |
|
| 2538 | + public function NewObj4($class, $args) { |
|
| 2539 | + $obj = new $class($args[0], $args[1], $args[2], $args[3]); |
|
| 2540 | + if ($this->CacheEnabled()) { |
|
| 2541 | + $this->ObjCache($obj, $class, $args); |
|
| 2542 | 2542 | } |
| 2543 | 2543 | return $obj; |
| 2544 | 2544 | } |
| 2545 | 2545 | |
| 2546 | - public function NewObj5($class, $args){ |
|
| 2547 | - $obj = new $class( $args[0], $args[1], $args[2], $args[3], $args[4] ); |
|
| 2548 | - if( $this->CacheEnabled() ){ |
|
| 2549 | - $this->ObjCache( $obj, $class, $args); |
|
| 2546 | + public function NewObj5($class, $args) { |
|
| 2547 | + $obj = new $class($args[0], $args[1], $args[2], $args[3], $args[4]); |
|
| 2548 | + if ($this->CacheEnabled()) { |
|
| 2549 | + $this->ObjCache($obj, $class, $args); |
|
| 2550 | 2550 | } |
| 2551 | 2551 | return $obj; |
| 2552 | 2552 | } |
| 2553 | 2553 | |
| 2554 | - public function NewObj6($class, $args){ |
|
| 2555 | - $obj = new $class( $args[0], $args[1], $args[2], $args[3], $args[4], $args[5] ); |
|
| 2556 | - if( $this->CacheEnabled() ){ |
|
| 2557 | - $this->ObjCache( $obj, $class, $args); |
|
| 2554 | + public function NewObj6($class, $args) { |
|
| 2555 | + $obj = new $class($args[0], $args[1], $args[2], $args[3], $args[4], $args[5]); |
|
| 2556 | + if ($this->CacheEnabled()) { |
|
| 2557 | + $this->ObjCache($obj, $class, $args); |
|
| 2558 | 2558 | } |
| 2559 | 2559 | return $obj; |
| 2560 | 2560 | } |
| 2561 | 2561 | |
| 2562 | - public function NewObj7($class, $args){ |
|
| 2563 | - $obj = new $class( $args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6] ); |
|
| 2564 | - if( $this->CacheEnabled() ){ |
|
| 2565 | - $this->ObjCache( $obj, $class, $args); |
|
| 2562 | + public function NewObj7($class, $args) { |
|
| 2563 | + $obj = new $class($args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6]); |
|
| 2564 | + if ($this->CacheEnabled()) { |
|
| 2565 | + $this->ObjCache($obj, $class, $args); |
|
| 2566 | 2566 | } |
| 2567 | 2567 | return $obj; |
| 2568 | 2568 | } |
| 2569 | 2569 | |
| 2570 | 2570 | //caching |
| 2571 | - public function ObjCache($obj, $class, $args=array()){ |
|
| 2572 | - $obj->cache_string = ' new '.$class.'('. self::ArgCache($args).')'; |
|
| 2571 | + public function ObjCache($obj, $class, $args = array()) { |
|
| 2572 | + $obj->cache_string = ' new '.$class.'('.self::ArgCache($args).')'; |
|
| 2573 | 2573 | } |
| 2574 | 2574 | |
| 2575 | - public function ArgCache($args){ |
|
| 2576 | - return implode(',',array_map( array('Less_Parser','ArgString'),$args)); |
|
| 2575 | + public function ArgCache($args) { |
|
| 2576 | + return implode(',', array_map(array('Less_Parser', 'ArgString'), $args)); |
|
| 2577 | 2577 | } |
| 2578 | 2578 | |
| 2579 | 2579 | |
@@ -2582,36 +2582,36 @@ discard block |
||
| 2582 | 2582 | * |
| 2583 | 2583 | * @return string |
| 2584 | 2584 | */ |
| 2585 | - public static function ArgString($arg){ |
|
| 2585 | + public static function ArgString($arg) { |
|
| 2586 | 2586 | |
| 2587 | 2587 | $type = gettype($arg); |
| 2588 | 2588 | |
| 2589 | - if( $type === 'object'){ |
|
| 2589 | + if ($type==='object') { |
|
| 2590 | 2590 | $string = $arg->cache_string; |
| 2591 | 2591 | unset($arg->cache_string); |
| 2592 | 2592 | return $string; |
| 2593 | 2593 | |
| 2594 | - }elseif( $type === 'array' ){ |
|
| 2594 | + }elseif ($type==='array') { |
|
| 2595 | 2595 | $string = ' Array('; |
| 2596 | - foreach($arg as $k => $a){ |
|
| 2597 | - $string .= var_export($k,true).' => '.self::ArgString($a).','; |
|
| 2596 | + foreach ($arg as $k => $a) { |
|
| 2597 | + $string .= var_export($k, true).' => '.self::ArgString($a).','; |
|
| 2598 | 2598 | } |
| 2599 | - return $string . ')'; |
|
| 2599 | + return $string.')'; |
|
| 2600 | 2600 | } |
| 2601 | 2601 | |
| 2602 | - return var_export($arg,true); |
|
| 2602 | + return var_export($arg, true); |
|
| 2603 | 2603 | } |
| 2604 | 2604 | |
| 2605 | - public function Error($msg){ |
|
| 2605 | + public function Error($msg) { |
|
| 2606 | 2606 | throw new Less_Exception_Parser($msg, null, $this->furthest, $this->env->currentFileInfo); |
| 2607 | 2607 | } |
| 2608 | 2608 | |
| 2609 | - public static function WinPath($path){ |
|
| 2609 | + public static function WinPath($path) { |
|
| 2610 | 2610 | return str_replace('\\', '/', $path); |
| 2611 | 2611 | } |
| 2612 | 2612 | |
| 2613 | - public function CacheEnabled(){ |
|
| 2614 | - return (Less_Parser::$options['cache_method'] && (Less_Cache::$cache_dir || (Less_Parser::$options['cache_method'] == 'callback'))); |
|
| 2613 | + public function CacheEnabled() { |
|
| 2614 | + return (Less_Parser::$options['cache_method'] && (Less_Cache::$cache_dir || (Less_Parser::$options['cache_method']=='callback'))); |
|
| 2615 | 2615 | } |
| 2616 | 2616 | |
| 2617 | 2617 | } |
@@ -2796,7 +2796,7 @@ discard block |
||
| 2796 | 2796 | * @package Less |
| 2797 | 2797 | * @subpackage environment |
| 2798 | 2798 | */ |
| 2799 | -class Less_Environment{ |
|
| 2799 | +class Less_Environment { |
|
| 2800 | 2800 | |
| 2801 | 2801 | //public $paths = array(); // option - unmodified - paths to search for imports on |
| 2802 | 2802 | //public static $files = array(); // list of files that have been imported, used for import-once |
@@ -2806,9 +2806,9 @@ discard block |
||
| 2806 | 2806 | //public $processImports; // option - whether to process imports. if false then imports will not be imported |
| 2807 | 2807 | //public $javascriptEnabled; // option - whether JavaScript is enabled. if undefined, defaults to true |
| 2808 | 2808 | //public $useFileCache; // browser only - whether to use the per file session cache |
| 2809 | - public $currentFileInfo; // information about the current file - for error reporting and importing and making urls relative etc. |
|
| 2809 | + public $currentFileInfo; // information about the current file - for error reporting and importing and making urls relative etc. |
|
| 2810 | 2810 | |
| 2811 | - public $importMultiple = false; // whether we are currently importing multiple copies |
|
| 2811 | + public $importMultiple = false; // whether we are currently importing multiple copies |
|
| 2812 | 2812 | |
| 2813 | 2813 | |
| 2814 | 2814 | /** |
@@ -2842,14 +2842,14 @@ discard block |
||
| 2842 | 2842 | public $functions = array(); |
| 2843 | 2843 | |
| 2844 | 2844 | |
| 2845 | - public function Init(){ |
|
| 2845 | + public function Init() { |
|
| 2846 | 2846 | |
| 2847 | 2847 | self::$parensStack = 0; |
| 2848 | 2848 | self::$tabLevel = 0; |
| 2849 | 2849 | self::$lastRule = false; |
| 2850 | 2850 | self::$mixin_stack = 0; |
| 2851 | 2851 | |
| 2852 | - if( Less_Parser::$options['compress'] ){ |
|
| 2852 | + if (Less_Parser::$options['compress']) { |
|
| 2853 | 2853 | |
| 2854 | 2854 | Less_Environment::$_outputMap = array( |
| 2855 | 2855 | ',' => ',', |
@@ -2865,7 +2865,7 @@ discard block |
||
| 2865 | 2865 | '^^' => '^^' |
| 2866 | 2866 | ); |
| 2867 | 2867 | |
| 2868 | - }else{ |
|
| 2868 | + }else { |
|
| 2869 | 2869 | |
| 2870 | 2870 | Less_Environment::$_outputMap = array( |
| 2871 | 2871 | ',' => ', ', |
@@ -2885,19 +2885,19 @@ discard block |
||
| 2885 | 2885 | } |
| 2886 | 2886 | |
| 2887 | 2887 | |
| 2888 | - public function copyEvalEnv($frames = array() ){ |
|
| 2888 | + public function copyEvalEnv($frames = array()) { |
|
| 2889 | 2889 | $new_env = new Less_Environment(); |
| 2890 | 2890 | $new_env->frames = $frames; |
| 2891 | 2891 | return $new_env; |
| 2892 | 2892 | } |
| 2893 | 2893 | |
| 2894 | 2894 | |
| 2895 | - public static function isMathOn(){ |
|
| 2895 | + public static function isMathOn() { |
|
| 2896 | 2896 | return !Less_Parser::$options['strictMath'] || Less_Environment::$parensStack; |
| 2897 | 2897 | } |
| 2898 | 2898 | |
| 2899 | - public static function isPathRelative($path){ |
|
| 2900 | - return !preg_match('/^(?:[a-z-]+:|\/)/',$path); |
|
| 2899 | + public static function isPathRelative($path) { |
|
| 2900 | + return !preg_match('/^(?:[a-z-]+:|\/)/', $path); |
|
| 2901 | 2901 | } |
| 2902 | 2902 | |
| 2903 | 2903 | |
@@ -2908,26 +2908,26 @@ discard block |
||
| 2908 | 2908 | * @return string Canonicalized path |
| 2909 | 2909 | * |
| 2910 | 2910 | */ |
| 2911 | - public static function normalizePath($path){ |
|
| 2911 | + public static function normalizePath($path) { |
|
| 2912 | 2912 | |
| 2913 | - $segments = explode('/',$path); |
|
| 2913 | + $segments = explode('/', $path); |
|
| 2914 | 2914 | $segments = array_reverse($segments); |
| 2915 | 2915 | |
| 2916 | 2916 | $path = array(); |
| 2917 | 2917 | $path_len = 0; |
| 2918 | 2918 | |
| 2919 | - while( $segments ){ |
|
| 2919 | + while ($segments) { |
|
| 2920 | 2920 | $segment = array_pop($segments); |
| 2921 | - switch( $segment ) { |
|
| 2921 | + switch ($segment) { |
|
| 2922 | 2922 | |
| 2923 | 2923 | case '.': |
| 2924 | 2924 | break; |
| 2925 | 2925 | |
| 2926 | 2926 | case '..': |
| 2927 | - if( !$path_len || ( $path[$path_len-1] === '..') ){ |
|
| 2927 | + if (!$path_len || ($path[$path_len-1]==='..')) { |
|
| 2928 | 2928 | $path[] = $segment; |
| 2929 | 2929 | $path_len++; |
| 2930 | - }else{ |
|
| 2930 | + }else { |
|
| 2931 | 2931 | array_pop($path); |
| 2932 | 2932 | $path_len--; |
| 2933 | 2933 | } |
@@ -2940,15 +2940,15 @@ discard block |
||
| 2940 | 2940 | } |
| 2941 | 2941 | } |
| 2942 | 2942 | |
| 2943 | - return implode('/',$path); |
|
| 2943 | + return implode('/', $path); |
|
| 2944 | 2944 | } |
| 2945 | 2945 | |
| 2946 | 2946 | |
| 2947 | - public function unshiftFrame($frame){ |
|
| 2947 | + public function unshiftFrame($frame) { |
|
| 2948 | 2948 | array_unshift($this->frames, $frame); |
| 2949 | 2949 | } |
| 2950 | 2950 | |
| 2951 | - public function shiftFrame(){ |
|
| 2951 | + public function shiftFrame() { |
|
| 2952 | 2952 | return array_shift($this->frames); |
| 2953 | 2953 | } |
| 2954 | 2954 | |
@@ -2962,12 +2962,12 @@ discard block |
||
| 2962 | 2962 | * @subpackage function |
| 2963 | 2963 | * @see http://lesscss.org/functions/ |
| 2964 | 2964 | */ |
| 2965 | -class Less_Functions{ |
|
| 2965 | +class Less_Functions { |
|
| 2966 | 2966 | |
| 2967 | 2967 | public $env; |
| 2968 | 2968 | public $currentFileInfo; |
| 2969 | 2969 | |
| 2970 | - function __construct($env, $currentFileInfo = null ){ |
|
| 2970 | + function __construct($env, $currentFileInfo = null) { |
|
| 2971 | 2971 | $this->env = $env; |
| 2972 | 2972 | $this->currentFileInfo = $currentFileInfo; |
| 2973 | 2973 | } |
@@ -2975,95 +2975,95 @@ discard block |
||
| 2975 | 2975 | /** |
| 2976 | 2976 | * @param string $op |
| 2977 | 2977 | */ |
| 2978 | - public static function operate( $op, $a, $b ){ |
|
| 2978 | + public static function operate($op, $a, $b) { |
|
| 2979 | 2979 | switch ($op) { |
| 2980 | - case '+': return $a + $b; |
|
| 2981 | - case '-': return $a - $b; |
|
| 2980 | + case '+': return $a+$b; |
|
| 2981 | + case '-': return $a-$b; |
|
| 2982 | 2982 | case '*': return $a * $b; |
| 2983 | 2983 | case '/': return $a / $b; |
| 2984 | 2984 | } |
| 2985 | 2985 | } |
| 2986 | 2986 | |
| 2987 | - public static function clamp($val, $max = 1){ |
|
| 2988 | - return min( max($val, 0), $max); |
|
| 2987 | + public static function clamp($val, $max = 1) { |
|
| 2988 | + return min(max($val, 0), $max); |
|
| 2989 | 2989 | } |
| 2990 | 2990 | |
| 2991 | - public static function fround( $value ){ |
|
| 2991 | + public static function fround($value) { |
|
| 2992 | 2992 | |
| 2993 | - if( $value === 0 ){ |
|
| 2993 | + if ($value===0) { |
|
| 2994 | 2994 | return $value; |
| 2995 | 2995 | } |
| 2996 | 2996 | |
| 2997 | - if( Less_Parser::$options['numPrecision'] ){ |
|
| 2997 | + if (Less_Parser::$options['numPrecision']) { |
|
| 2998 | 2998 | $p = pow(10, Less_Parser::$options['numPrecision']); |
| 2999 | - return round( $value * $p) / $p; |
|
| 2999 | + return round($value * $p) / $p; |
|
| 3000 | 3000 | } |
| 3001 | 3001 | return $value; |
| 3002 | 3002 | } |
| 3003 | 3003 | |
| 3004 | - public static function number($n){ |
|
| 3004 | + public static function number($n) { |
|
| 3005 | 3005 | |
| 3006 | 3006 | if ($n instanceof Less_Tree_Dimension) { |
| 3007 | - return floatval( $n->unit->is('%') ? $n->value / 100 : $n->value); |
|
| 3008 | - } else if (is_numeric($n)) { |
|
| 3007 | + return floatval($n->unit->is('%') ? $n->value / 100 : $n->value); |
|
| 3008 | + }else if (is_numeric($n)) { |
|
| 3009 | 3009 | return $n; |
| 3010 | - } else { |
|
| 3010 | + }else { |
|
| 3011 | 3011 | throw new Less_Exception_Compiler("color functions take numbers as parameters"); |
| 3012 | 3012 | } |
| 3013 | 3013 | } |
| 3014 | 3014 | |
| 3015 | - public static function scaled($n, $size = 255 ){ |
|
| 3016 | - if( $n instanceof Less_Tree_Dimension && $n->unit->is('%') ){ |
|
| 3015 | + public static function scaled($n, $size = 255) { |
|
| 3016 | + if ($n instanceof Less_Tree_Dimension && $n->unit->is('%')) { |
|
| 3017 | 3017 | return (float)$n->value * $size / 100; |
| 3018 | - } else { |
|
| 3018 | + }else { |
|
| 3019 | 3019 | return Less_Functions::number($n); |
| 3020 | 3020 | } |
| 3021 | 3021 | } |
| 3022 | 3022 | |
| 3023 | - public function rgb ($r = null, $g = null, $b = null){ |
|
| 3023 | + public function rgb($r = null, $g = null, $b = null) { |
|
| 3024 | 3024 | if (is_null($r) || is_null($g) || is_null($b)) { |
| 3025 | 3025 | throw new Less_Exception_Compiler("rgb expects three parameters"); |
| 3026 | 3026 | } |
| 3027 | 3027 | return $this->rgba($r, $g, $b, 1.0); |
| 3028 | 3028 | } |
| 3029 | 3029 | |
| 3030 | - public function rgba($r = null, $g = null, $b = null, $a = null){ |
|
| 3030 | + public function rgba($r = null, $g = null, $b = null, $a = null) { |
|
| 3031 | 3031 | $rgb = array($r, $g, $b); |
| 3032 | - $rgb = array_map(array('Less_Functions','scaled'),$rgb); |
|
| 3032 | + $rgb = array_map(array('Less_Functions', 'scaled'), $rgb); |
|
| 3033 | 3033 | |
| 3034 | 3034 | $a = self::number($a); |
| 3035 | 3035 | return new Less_Tree_Color($rgb, $a); |
| 3036 | 3036 | } |
| 3037 | 3037 | |
| 3038 | - public function hsl($h, $s, $l){ |
|
| 3038 | + public function hsl($h, $s, $l) { |
|
| 3039 | 3039 | return $this->hsla($h, $s, $l, 1.0); |
| 3040 | 3040 | } |
| 3041 | 3041 | |
| 3042 | - public function hsla($h, $s, $l, $a){ |
|
| 3042 | + public function hsla($h, $s, $l, $a) { |
|
| 3043 | 3043 | |
| 3044 | 3044 | $h = fmod(self::number($h), 360) / 360; // Classic % operator will change float to int |
| 3045 | 3045 | $s = self::clamp(self::number($s)); |
| 3046 | 3046 | $l = self::clamp(self::number($l)); |
| 3047 | 3047 | $a = self::clamp(self::number($a)); |
| 3048 | 3048 | |
| 3049 | - $m2 = $l <= 0.5 ? $l * ($s + 1) : $l + $s - $l * $s; |
|
| 3049 | + $m2 = $l<=0.5 ? $l * ($s+1) : $l+$s-$l * $s; |
|
| 3050 | 3050 | |
| 3051 | - $m1 = $l * 2 - $m2; |
|
| 3051 | + $m1 = $l * 2-$m2; |
|
| 3052 | 3052 | |
| 3053 | - return $this->rgba( self::hsla_hue($h + 1/3, $m1, $m2) * 255, |
|
| 3053 | + return $this->rgba(self::hsla_hue($h+1 / 3, $m1, $m2) * 255, |
|
| 3054 | 3054 | self::hsla_hue($h, $m1, $m2) * 255, |
| 3055 | - self::hsla_hue($h - 1/3, $m1, $m2) * 255, |
|
| 3055 | + self::hsla_hue($h-1 / 3, $m1, $m2) * 255, |
|
| 3056 | 3056 | $a); |
| 3057 | 3057 | } |
| 3058 | 3058 | |
| 3059 | 3059 | /** |
| 3060 | 3060 | * @param double $h |
| 3061 | 3061 | */ |
| 3062 | - public function hsla_hue($h, $m1, $m2){ |
|
| 3063 | - $h = $h < 0 ? $h + 1 : ($h > 1 ? $h - 1 : $h); |
|
| 3064 | - if ($h * 6 < 1) return $m1 + ($m2 - $m1) * $h * 6; |
|
| 3065 | - else if ($h * 2 < 1) return $m2; |
|
| 3066 | - else if ($h * 3 < 2) return $m1 + ($m2 - $m1) * (2/3 - $h) * 6; |
|
| 3062 | + public function hsla_hue($h, $m1, $m2) { |
|
| 3063 | + $h = $h<0 ? $h+1 : ($h>1 ? $h-1 : $h); |
|
| 3064 | + if ($h * 6<1) return $m1+($m2-$m1) * $h * 6; |
|
| 3065 | + else if ($h * 2<1) return $m2; |
|
| 3066 | + else if ($h * 3<2) return $m1+($m2-$m1) * (2 / 3-$h) * 6; |
|
| 3067 | 3067 | else return $m1; |
| 3068 | 3068 | } |
| 3069 | 3069 | |
@@ -3075,18 +3075,18 @@ discard block |
||
| 3075 | 3075 | * @param double $a |
| 3076 | 3076 | */ |
| 3077 | 3077 | public function hsva($h, $s, $v, $a) { |
| 3078 | - $h = ((Less_Functions::number($h) % 360) / 360 ) * 360; |
|
| 3078 | + $h = ((Less_Functions::number($h) % 360) / 360) * 360; |
|
| 3079 | 3079 | $s = Less_Functions::number($s); |
| 3080 | 3080 | $v = Less_Functions::number($v); |
| 3081 | 3081 | $a = Less_Functions::number($a); |
| 3082 | 3082 | |
| 3083 | 3083 | $i = floor(($h / 60) % 6); |
| 3084 | - $f = ($h / 60) - $i; |
|
| 3084 | + $f = ($h / 60)-$i; |
|
| 3085 | 3085 | |
| 3086 | - $vs = array( $v, |
|
| 3087 | - $v * (1 - $s), |
|
| 3088 | - $v * (1 - $f * $s), |
|
| 3089 | - $v * (1 - (1 - $f) * $s)); |
|
| 3086 | + $vs = array($v, |
|
| 3087 | + $v * (1-$s), |
|
| 3088 | + $v * (1-$f * $s), |
|
| 3089 | + $v * (1-(1-$f) * $s)); |
|
| 3090 | 3090 | |
| 3091 | 3091 | $perm = array(array(0, 3, 1), |
| 3092 | 3092 | array(2, 0, 1), |
@@ -3101,105 +3101,105 @@ discard block |
||
| 3101 | 3101 | $a); |
| 3102 | 3102 | } |
| 3103 | 3103 | |
| 3104 | - public function hue($color = null){ |
|
| 3104 | + public function hue($color = null) { |
|
| 3105 | 3105 | if (!$color instanceof Less_Tree_Color) { |
| 3106 | - throw new Less_Exception_Compiler('The first argument to hue must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3106 | + throw new Less_Exception_Compiler('The first argument to hue must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3107 | 3107 | } |
| 3108 | 3108 | |
| 3109 | 3109 | $c = $color->toHSL(); |
| 3110 | 3110 | return new Less_Tree_Dimension(Less_Parser::round($c['h'])); |
| 3111 | 3111 | } |
| 3112 | 3112 | |
| 3113 | - public function saturation($color = null){ |
|
| 3113 | + public function saturation($color = null) { |
|
| 3114 | 3114 | if (!$color instanceof Less_Tree_Color) { |
| 3115 | - throw new Less_Exception_Compiler('The first argument to saturation must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3115 | + throw new Less_Exception_Compiler('The first argument to saturation must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3116 | 3116 | } |
| 3117 | 3117 | |
| 3118 | 3118 | $c = $color->toHSL(); |
| 3119 | 3119 | return new Less_Tree_Dimension(Less_Parser::round($c['s'] * 100), '%'); |
| 3120 | 3120 | } |
| 3121 | 3121 | |
| 3122 | - public function lightness($color = null){ |
|
| 3122 | + public function lightness($color = null) { |
|
| 3123 | 3123 | if (!$color instanceof Less_Tree_Color) { |
| 3124 | - throw new Less_Exception_Compiler('The first argument to lightness must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3124 | + throw new Less_Exception_Compiler('The first argument to lightness must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3125 | 3125 | } |
| 3126 | 3126 | |
| 3127 | 3127 | $c = $color->toHSL(); |
| 3128 | 3128 | return new Less_Tree_Dimension(Less_Parser::round($c['l'] * 100), '%'); |
| 3129 | 3129 | } |
| 3130 | 3130 | |
| 3131 | - public function hsvhue( $color = null ){ |
|
| 3131 | + public function hsvhue($color = null) { |
|
| 3132 | 3132 | if (!$color instanceof Less_Tree_Color) { |
| 3133 | - throw new Less_Exception_Compiler('The first argument to hsvhue must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3133 | + throw new Less_Exception_Compiler('The first argument to hsvhue must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3134 | 3134 | } |
| 3135 | 3135 | |
| 3136 | 3136 | $hsv = $color->toHSV(); |
| 3137 | - return new Less_Tree_Dimension( Less_Parser::round($hsv['h']) ); |
|
| 3137 | + return new Less_Tree_Dimension(Less_Parser::round($hsv['h'])); |
|
| 3138 | 3138 | } |
| 3139 | 3139 | |
| 3140 | 3140 | |
| 3141 | - public function hsvsaturation( $color = null ){ |
|
| 3141 | + public function hsvsaturation($color = null) { |
|
| 3142 | 3142 | if (!$color instanceof Less_Tree_Color) { |
| 3143 | - throw new Less_Exception_Compiler('The first argument to hsvsaturation must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3143 | + throw new Less_Exception_Compiler('The first argument to hsvsaturation must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3144 | 3144 | } |
| 3145 | 3145 | |
| 3146 | 3146 | $hsv = $color->toHSV(); |
| 3147 | - return new Less_Tree_Dimension( Less_Parser::round($hsv['s'] * 100), '%' ); |
|
| 3147 | + return new Less_Tree_Dimension(Less_Parser::round($hsv['s'] * 100), '%'); |
|
| 3148 | 3148 | } |
| 3149 | 3149 | |
| 3150 | - public function hsvvalue( $color = null ){ |
|
| 3150 | + public function hsvvalue($color = null) { |
|
| 3151 | 3151 | if (!$color instanceof Less_Tree_Color) { |
| 3152 | - throw new Less_Exception_Compiler('The first argument to hsvvalue must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3152 | + throw new Less_Exception_Compiler('The first argument to hsvvalue must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3153 | 3153 | } |
| 3154 | 3154 | |
| 3155 | 3155 | $hsv = $color->toHSV(); |
| 3156 | - return new Less_Tree_Dimension( Less_Parser::round($hsv['v'] * 100), '%' ); |
|
| 3156 | + return new Less_Tree_Dimension(Less_Parser::round($hsv['v'] * 100), '%'); |
|
| 3157 | 3157 | } |
| 3158 | 3158 | |
| 3159 | 3159 | public function red($color = null) { |
| 3160 | 3160 | if (!$color instanceof Less_Tree_Color) { |
| 3161 | - throw new Less_Exception_Compiler('The first argument to red must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3161 | + throw new Less_Exception_Compiler('The first argument to red must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3162 | 3162 | } |
| 3163 | 3163 | |
| 3164 | - return new Less_Tree_Dimension( $color->rgb[0] ); |
|
| 3164 | + return new Less_Tree_Dimension($color->rgb[0]); |
|
| 3165 | 3165 | } |
| 3166 | 3166 | |
| 3167 | 3167 | public function green($color = null) { |
| 3168 | 3168 | if (!$color instanceof Less_Tree_Color) { |
| 3169 | - throw new Less_Exception_Compiler('The first argument to green must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3169 | + throw new Less_Exception_Compiler('The first argument to green must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3170 | 3170 | } |
| 3171 | 3171 | |
| 3172 | - return new Less_Tree_Dimension( $color->rgb[1] ); |
|
| 3172 | + return new Less_Tree_Dimension($color->rgb[1]); |
|
| 3173 | 3173 | } |
| 3174 | 3174 | |
| 3175 | 3175 | public function blue($color = null) { |
| 3176 | 3176 | if (!$color instanceof Less_Tree_Color) { |
| 3177 | - throw new Less_Exception_Compiler('The first argument to blue must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3177 | + throw new Less_Exception_Compiler('The first argument to blue must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3178 | 3178 | } |
| 3179 | 3179 | |
| 3180 | - return new Less_Tree_Dimension( $color->rgb[2] ); |
|
| 3180 | + return new Less_Tree_Dimension($color->rgb[2]); |
|
| 3181 | 3181 | } |
| 3182 | 3182 | |
| 3183 | - public function alpha($color = null){ |
|
| 3183 | + public function alpha($color = null) { |
|
| 3184 | 3184 | if (!$color instanceof Less_Tree_Color) { |
| 3185 | - throw new Less_Exception_Compiler('The first argument to alpha must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3185 | + throw new Less_Exception_Compiler('The first argument to alpha must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3186 | 3186 | } |
| 3187 | 3187 | |
| 3188 | 3188 | $c = $color->toHSL(); |
| 3189 | 3189 | return new Less_Tree_Dimension($c['a']); |
| 3190 | 3190 | } |
| 3191 | 3191 | |
| 3192 | - public function luma ($color = null) { |
|
| 3192 | + public function luma($color = null) { |
|
| 3193 | 3193 | if (!$color instanceof Less_Tree_Color) { |
| 3194 | - throw new Less_Exception_Compiler('The first argument to luma must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3194 | + throw new Less_Exception_Compiler('The first argument to luma must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3195 | 3195 | } |
| 3196 | 3196 | |
| 3197 | - return new Less_Tree_Dimension(Less_Parser::round( $color->luma() * $color->alpha * 100), '%'); |
|
| 3197 | + return new Less_Tree_Dimension(Less_Parser::round($color->luma() * $color->alpha * 100), '%'); |
|
| 3198 | 3198 | } |
| 3199 | 3199 | |
| 3200 | - public function luminance( $color = null ){ |
|
| 3200 | + public function luminance($color = null) { |
|
| 3201 | 3201 | if (!$color instanceof Less_Tree_Color) { |
| 3202 | - throw new Less_Exception_Compiler('The first argument to luminance must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3202 | + throw new Less_Exception_Compiler('The first argument to luminance must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3203 | 3203 | } |
| 3204 | 3204 | |
| 3205 | 3205 | $luminance = |
@@ -3207,10 +3207,10 @@ discard block |
||
| 3207 | 3207 | + (0.7152 * $color->rgb[1] / 255) |
| 3208 | 3208 | + (0.0722 * $color->rgb[2] / 255); |
| 3209 | 3209 | |
| 3210 | - return new Less_Tree_Dimension(Less_Parser::round( $luminance * $color->alpha * 100), '%'); |
|
| 3210 | + return new Less_Tree_Dimension(Less_Parser::round($luminance * $color->alpha * 100), '%'); |
|
| 3211 | 3211 | } |
| 3212 | 3212 | |
| 3213 | - public function saturate($color = null, $amount = null){ |
|
| 3213 | + public function saturate($color = null, $amount = null) { |
|
| 3214 | 3214 | // filter: saturate(3.2); |
| 3215 | 3215 | // should be kept as is, so check for color |
| 3216 | 3216 | if ($color instanceof Less_Tree_Dimension) { |
@@ -3218,10 +3218,10 @@ discard block |
||
| 3218 | 3218 | } |
| 3219 | 3219 | |
| 3220 | 3220 | if (!$color instanceof Less_Tree_Color) { |
| 3221 | - throw new Less_Exception_Compiler('The first argument to saturate must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3221 | + throw new Less_Exception_Compiler('The first argument to saturate must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3222 | 3222 | } |
| 3223 | 3223 | if (!$amount instanceof Less_Tree_Dimension) { |
| 3224 | - throw new Less_Exception_Compiler('The second argument to saturate must be a percentage' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3224 | + throw new Less_Exception_Compiler('The second argument to saturate must be a percentage'.($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3225 | 3225 | } |
| 3226 | 3226 | |
| 3227 | 3227 | $hsl = $color->toHSL(); |
@@ -3235,12 +3235,12 @@ discard block |
||
| 3235 | 3235 | /** |
| 3236 | 3236 | * @param Less_Tree_Dimension $amount |
| 3237 | 3237 | */ |
| 3238 | - public function desaturate($color = null, $amount = null){ |
|
| 3238 | + public function desaturate($color = null, $amount = null) { |
|
| 3239 | 3239 | if (!$color instanceof Less_Tree_Color) { |
| 3240 | - throw new Less_Exception_Compiler('The first argument to desaturate must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3240 | + throw new Less_Exception_Compiler('The first argument to desaturate must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3241 | 3241 | } |
| 3242 | 3242 | if (!$amount instanceof Less_Tree_Dimension) { |
| 3243 | - throw new Less_Exception_Compiler('The second argument to desaturate must be a percentage' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3243 | + throw new Less_Exception_Compiler('The second argument to desaturate must be a percentage'.($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3244 | 3244 | } |
| 3245 | 3245 | |
| 3246 | 3246 | $hsl = $color->toHSL(); |
@@ -3253,12 +3253,12 @@ discard block |
||
| 3253 | 3253 | |
| 3254 | 3254 | |
| 3255 | 3255 | |
| 3256 | - public function lighten($color = null, $amount=null){ |
|
| 3256 | + public function lighten($color = null, $amount = null) { |
|
| 3257 | 3257 | if (!$color instanceof Less_Tree_Color) { |
| 3258 | - throw new Less_Exception_Compiler('The first argument to lighten must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3258 | + throw new Less_Exception_Compiler('The first argument to lighten must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3259 | 3259 | } |
| 3260 | 3260 | if (!$amount instanceof Less_Tree_Dimension) { |
| 3261 | - throw new Less_Exception_Compiler('The second argument to lighten must be a percentage' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3261 | + throw new Less_Exception_Compiler('The second argument to lighten must be a percentage'.($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3262 | 3262 | } |
| 3263 | 3263 | |
| 3264 | 3264 | $hsl = $color->toHSL(); |
@@ -3269,12 +3269,12 @@ discard block |
||
| 3269 | 3269 | return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']); |
| 3270 | 3270 | } |
| 3271 | 3271 | |
| 3272 | - public function darken($color = null, $amount = null){ |
|
| 3272 | + public function darken($color = null, $amount = null) { |
|
| 3273 | 3273 | if (!$color instanceof Less_Tree_Color) { |
| 3274 | - throw new Less_Exception_Compiler('The first argument to darken must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3274 | + throw new Less_Exception_Compiler('The first argument to darken must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3275 | 3275 | } |
| 3276 | 3276 | if (!$amount instanceof Less_Tree_Dimension) { |
| 3277 | - throw new Less_Exception_Compiler('The second argument to darken must be a percentage' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3277 | + throw new Less_Exception_Compiler('The second argument to darken must be a percentage'.($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3278 | 3278 | } |
| 3279 | 3279 | |
| 3280 | 3280 | $hsl = $color->toHSL(); |
@@ -3284,12 +3284,12 @@ discard block |
||
| 3284 | 3284 | return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']); |
| 3285 | 3285 | } |
| 3286 | 3286 | |
| 3287 | - public function fadein($color = null, $amount = null){ |
|
| 3287 | + public function fadein($color = null, $amount = null) { |
|
| 3288 | 3288 | if (!$color instanceof Less_Tree_Color) { |
| 3289 | - throw new Less_Exception_Compiler('The first argument to fadein must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3289 | + throw new Less_Exception_Compiler('The first argument to fadein must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3290 | 3290 | } |
| 3291 | 3291 | if (!$amount instanceof Less_Tree_Dimension) { |
| 3292 | - throw new Less_Exception_Compiler('The second argument to fadein must be a percentage' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3292 | + throw new Less_Exception_Compiler('The second argument to fadein must be a percentage'.($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3293 | 3293 | } |
| 3294 | 3294 | |
| 3295 | 3295 | $hsl = $color->toHSL(); |
@@ -3298,12 +3298,12 @@ discard block |
||
| 3298 | 3298 | return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']); |
| 3299 | 3299 | } |
| 3300 | 3300 | |
| 3301 | - public function fadeout($color = null, $amount = null){ |
|
| 3301 | + public function fadeout($color = null, $amount = null) { |
|
| 3302 | 3302 | if (!$color instanceof Less_Tree_Color) { |
| 3303 | - throw new Less_Exception_Compiler('The first argument to fadeout must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3303 | + throw new Less_Exception_Compiler('The first argument to fadeout must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3304 | 3304 | } |
| 3305 | 3305 | if (!$amount instanceof Less_Tree_Dimension) { |
| 3306 | - throw new Less_Exception_Compiler('The second argument to fadeout must be a percentage' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3306 | + throw new Less_Exception_Compiler('The second argument to fadeout must be a percentage'.($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3307 | 3307 | } |
| 3308 | 3308 | |
| 3309 | 3309 | $hsl = $color->toHSL(); |
@@ -3312,12 +3312,12 @@ discard block |
||
| 3312 | 3312 | return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']); |
| 3313 | 3313 | } |
| 3314 | 3314 | |
| 3315 | - public function fade($color = null, $amount = null){ |
|
| 3315 | + public function fade($color = null, $amount = null) { |
|
| 3316 | 3316 | if (!$color instanceof Less_Tree_Color) { |
| 3317 | - throw new Less_Exception_Compiler('The first argument to fade must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3317 | + throw new Less_Exception_Compiler('The first argument to fade must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3318 | 3318 | } |
| 3319 | 3319 | if (!$amount instanceof Less_Tree_Dimension) { |
| 3320 | - throw new Less_Exception_Compiler('The second argument to fade must be a percentage' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3320 | + throw new Less_Exception_Compiler('The second argument to fade must be a percentage'.($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3321 | 3321 | } |
| 3322 | 3322 | |
| 3323 | 3323 | $hsl = $color->toHSL(); |
@@ -3329,18 +3329,18 @@ discard block |
||
| 3329 | 3329 | |
| 3330 | 3330 | |
| 3331 | 3331 | |
| 3332 | - public function spin($color = null, $amount = null){ |
|
| 3332 | + public function spin($color = null, $amount = null) { |
|
| 3333 | 3333 | if (!$color instanceof Less_Tree_Color) { |
| 3334 | - throw new Less_Exception_Compiler('The first argument to spin must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3334 | + throw new Less_Exception_Compiler('The first argument to spin must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3335 | 3335 | } |
| 3336 | 3336 | if (!$amount instanceof Less_Tree_Dimension) { |
| 3337 | - throw new Less_Exception_Compiler('The second argument to spin must be a number' . ($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3337 | + throw new Less_Exception_Compiler('The second argument to spin must be a number'.($amount instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3338 | 3338 | } |
| 3339 | 3339 | |
| 3340 | 3340 | $hsl = $color->toHSL(); |
| 3341 | - $hue = fmod($hsl['h'] + $amount->value, 360); |
|
| 3341 | + $hue = fmod($hsl['h']+$amount->value, 360); |
|
| 3342 | 3342 | |
| 3343 | - $hsl['h'] = $hue < 0 ? 360 + $hue : $hue; |
|
| 3343 | + $hsl['h'] = $hue<0 ? 360+$hue : $hue; |
|
| 3344 | 3344 | |
| 3345 | 3345 | return $this->hsla($hsl['h'], $hsl['s'], $hsl['l'], $hsl['a']); |
| 3346 | 3346 | } |
@@ -3353,92 +3353,92 @@ discard block |
||
| 3353 | 3353 | /** |
| 3354 | 3354 | * @param Less_Tree_Color $color1 |
| 3355 | 3355 | */ |
| 3356 | - public function mix($color1 = null, $color2 = null, $weight = null){ |
|
| 3356 | + public function mix($color1 = null, $color2 = null, $weight = null) { |
|
| 3357 | 3357 | if (!$color1 instanceof Less_Tree_Color) { |
| 3358 | - throw new Less_Exception_Compiler('The first argument to mix must be a color' . ($color1 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3358 | + throw new Less_Exception_Compiler('The first argument to mix must be a color'.($color1 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3359 | 3359 | } |
| 3360 | 3360 | if (!$color2 instanceof Less_Tree_Color) { |
| 3361 | - throw new Less_Exception_Compiler('The second argument to mix must be a color' . ($color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3361 | + throw new Less_Exception_Compiler('The second argument to mix must be a color'.($color2 instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3362 | 3362 | } |
| 3363 | 3363 | if (!$weight) { |
| 3364 | 3364 | $weight = new Less_Tree_Dimension('50', '%'); |
| 3365 | 3365 | } |
| 3366 | 3366 | if (!$weight instanceof Less_Tree_Dimension) { |
| 3367 | - throw new Less_Exception_Compiler('The third argument to contrast must be a percentage' . ($weight instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3367 | + throw new Less_Exception_Compiler('The third argument to contrast must be a percentage'.($weight instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3368 | 3368 | } |
| 3369 | 3369 | |
| 3370 | 3370 | $p = $weight->value / 100.0; |
| 3371 | - $w = $p * 2 - 1; |
|
| 3371 | + $w = $p * 2-1; |
|
| 3372 | 3372 | $hsl1 = $color1->toHSL(); |
| 3373 | 3373 | $hsl2 = $color2->toHSL(); |
| 3374 | - $a = $hsl1['a'] - $hsl2['a']; |
|
| 3374 | + $a = $hsl1['a']-$hsl2['a']; |
|
| 3375 | 3375 | |
| 3376 | - $w1 = (((($w * $a) == -1) ? $w : ($w + $a) / (1 + $w * $a)) + 1) / 2; |
|
| 3377 | - $w2 = 1 - $w1; |
|
| 3376 | + $w1 = (((($w * $a)==-1) ? $w : ($w+$a) / (1+$w * $a))+1) / 2; |
|
| 3377 | + $w2 = 1-$w1; |
|
| 3378 | 3378 | |
| 3379 | - $rgb = array($color1->rgb[0] * $w1 + $color2->rgb[0] * $w2, |
|
| 3380 | - $color1->rgb[1] * $w1 + $color2->rgb[1] * $w2, |
|
| 3381 | - $color1->rgb[2] * $w1 + $color2->rgb[2] * $w2); |
|
| 3379 | + $rgb = array($color1->rgb[0] * $w1+$color2->rgb[0] * $w2, |
|
| 3380 | + $color1->rgb[1] * $w1+$color2->rgb[1] * $w2, |
|
| 3381 | + $color1->rgb[2] * $w1+$color2->rgb[2] * $w2); |
|
| 3382 | 3382 | |
| 3383 | - $alpha = $color1->alpha * $p + $color2->alpha * (1 - $p); |
|
| 3383 | + $alpha = $color1->alpha * $p+$color2->alpha * (1-$p); |
|
| 3384 | 3384 | |
| 3385 | 3385 | return new Less_Tree_Color($rgb, $alpha); |
| 3386 | 3386 | } |
| 3387 | 3387 | |
| 3388 | - public function greyscale($color){ |
|
| 3389 | - return $this->desaturate($color, new Less_Tree_Dimension(100,'%')); |
|
| 3388 | + public function greyscale($color) { |
|
| 3389 | + return $this->desaturate($color, new Less_Tree_Dimension(100, '%')); |
|
| 3390 | 3390 | } |
| 3391 | 3391 | |
| 3392 | 3392 | |
| 3393 | - public function contrast( $color, $dark = null, $light = null, $threshold = null){ |
|
| 3393 | + public function contrast($color, $dark = null, $light = null, $threshold = null) { |
|
| 3394 | 3394 | // filter: contrast(3.2); |
| 3395 | 3395 | // should be kept as is, so check for color |
| 3396 | 3396 | if (!$color instanceof Less_Tree_Color) { |
| 3397 | 3397 | return null; |
| 3398 | 3398 | } |
| 3399 | - if( !$light ){ |
|
| 3399 | + if (!$light) { |
|
| 3400 | 3400 | $light = $this->rgba(255, 255, 255, 1.0); |
| 3401 | 3401 | } |
| 3402 | - if( !$dark ){ |
|
| 3402 | + if (!$dark) { |
|
| 3403 | 3403 | $dark = $this->rgba(0, 0, 0, 1.0); |
| 3404 | 3404 | } |
| 3405 | 3405 | |
| 3406 | 3406 | if (!$dark instanceof Less_Tree_Color) { |
| 3407 | - throw new Less_Exception_Compiler('The second argument to contrast must be a color' . ($dark instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3407 | + throw new Less_Exception_Compiler('The second argument to contrast must be a color'.($dark instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3408 | 3408 | } |
| 3409 | 3409 | if (!$light instanceof Less_Tree_Color) { |
| 3410 | - throw new Less_Exception_Compiler('The third argument to contrast must be a color' . ($light instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3410 | + throw new Less_Exception_Compiler('The third argument to contrast must be a color'.($light instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3411 | 3411 | } |
| 3412 | 3412 | |
| 3413 | 3413 | //Figure out which is actually light and dark! |
| 3414 | - if( $dark->luma() > $light->luma() ){ |
|
| 3414 | + if ($dark->luma()>$light->luma()) { |
|
| 3415 | 3415 | $t = $light; |
| 3416 | 3416 | $light = $dark; |
| 3417 | 3417 | $dark = $t; |
| 3418 | 3418 | } |
| 3419 | - if( !$threshold ){ |
|
| 3419 | + if (!$threshold) { |
|
| 3420 | 3420 | $threshold = 0.43; |
| 3421 | - } else { |
|
| 3421 | + }else { |
|
| 3422 | 3422 | $threshold = Less_Functions::number($threshold); |
| 3423 | 3423 | } |
| 3424 | 3424 | |
| 3425 | - if( $color->luma() < $threshold ){ |
|
| 3425 | + if ($color->luma()<$threshold) { |
|
| 3426 | 3426 | return $light; |
| 3427 | - } else { |
|
| 3427 | + }else { |
|
| 3428 | 3428 | return $dark; |
| 3429 | 3429 | } |
| 3430 | 3430 | } |
| 3431 | 3431 | |
| 3432 | - public function e ($str){ |
|
| 3433 | - if( is_string($str) ){ |
|
| 3432 | + public function e($str) { |
|
| 3433 | + if (is_string($str)) { |
|
| 3434 | 3434 | return new Less_Tree_Anonymous($str); |
| 3435 | 3435 | } |
| 3436 | 3436 | return new Less_Tree_Anonymous($str instanceof Less_Tree_JavaScript ? $str->expression : $str->value); |
| 3437 | 3437 | } |
| 3438 | 3438 | |
| 3439 | - public function escape ($str){ |
|
| 3439 | + public function escape($str) { |
|
| 3440 | 3440 | |
| 3441 | - $revert = array('%21'=>'!', '%2A'=>'*', '%27'=>"'",'%3F'=>'?','%26'=>'&','%2C'=>',','%2F'=>'/','%40'=>'@','%2B'=>'+','%24'=>'$'); |
|
| 3441 | + $revert = array('%21'=>'!', '%2A'=>'*', '%27'=>"'", '%3F'=>'?', '%26'=>'&', '%2C'=>',', '%2F'=>'/', '%40'=>'@', '%2B'=>'+', '%24'=>'$'); |
|
| 3442 | 3442 | |
| 3443 | 3443 | return new Less_Tree_Anonymous(strtr(rawurlencode($str->value), $revert)); |
| 3444 | 3444 | } |
@@ -3448,29 +3448,29 @@ discard block |
||
| 3448 | 3448 | * todo: This function will need some additional work to make it work the same as less.js |
| 3449 | 3449 | * |
| 3450 | 3450 | */ |
| 3451 | - public function replace( $string, $pattern, $replacement, $flags = null ){ |
|
| 3451 | + public function replace($string, $pattern, $replacement, $flags = null) { |
|
| 3452 | 3452 | $result = $string->value; |
| 3453 | 3453 | |
| 3454 | - $expr = '/'.str_replace('/','\\/',$pattern->value).'/'; |
|
| 3455 | - if( $flags && $flags->value){ |
|
| 3454 | + $expr = '/'.str_replace('/', '\\/', $pattern->value).'/'; |
|
| 3455 | + if ($flags && $flags->value) { |
|
| 3456 | 3456 | $expr .= self::replace_flags($flags->value); |
| 3457 | 3457 | } |
| 3458 | 3458 | |
| 3459 | - $result = preg_replace($expr,$replacement->value,$result); |
|
| 3459 | + $result = preg_replace($expr, $replacement->value, $result); |
|
| 3460 | 3460 | |
| 3461 | 3461 | |
| 3462 | - if( property_exists($string,'quote') ){ |
|
| 3463 | - return new Less_Tree_Quoted( $string->quote, $result, $string->escaped); |
|
| 3462 | + if (property_exists($string, 'quote')) { |
|
| 3463 | + return new Less_Tree_Quoted($string->quote, $result, $string->escaped); |
|
| 3464 | 3464 | } |
| 3465 | - return new Less_Tree_Quoted( '', $result ); |
|
| 3465 | + return new Less_Tree_Quoted('', $result); |
|
| 3466 | 3466 | } |
| 3467 | 3467 | |
| 3468 | - public static function replace_flags($flags){ |
|
| 3469 | - $flags = str_split($flags,1); |
|
| 3468 | + public static function replace_flags($flags) { |
|
| 3469 | + $flags = str_split($flags, 1); |
|
| 3470 | 3470 | $new_flags = ''; |
| 3471 | 3471 | |
| 3472 | - foreach($flags as $flag){ |
|
| 3473 | - switch($flag){ |
|
| 3472 | + foreach ($flags as $flag) { |
|
| 3473 | + switch ($flag) { |
|
| 3474 | 3474 | case 'e': |
| 3475 | 3475 | case 'g': |
| 3476 | 3476 | break; |
@@ -3484,91 +3484,91 @@ discard block |
||
| 3484 | 3484 | return $new_flags; |
| 3485 | 3485 | } |
| 3486 | 3486 | |
| 3487 | - public function _percent(){ |
|
| 3487 | + public function _percent() { |
|
| 3488 | 3488 | $string = func_get_arg(0); |
| 3489 | 3489 | |
| 3490 | 3490 | $args = func_get_args(); |
| 3491 | 3491 | array_shift($args); |
| 3492 | 3492 | $result = $string->value; |
| 3493 | 3493 | |
| 3494 | - foreach($args as $arg){ |
|
| 3495 | - if( preg_match('/%[sda]/i',$result, $token) ){ |
|
| 3494 | + foreach ($args as $arg) { |
|
| 3495 | + if (preg_match('/%[sda]/i', $result, $token)) { |
|
| 3496 | 3496 | $token = $token[0]; |
| 3497 | 3497 | $value = stristr($token, 's') ? $arg->value : $arg->toCSS(); |
| 3498 | 3498 | $value = preg_match('/[A-Z]$/', $token) ? urlencode($value) : $value; |
| 3499 | - $result = preg_replace('/%[sda]/i',$value, $result, 1); |
|
| 3499 | + $result = preg_replace('/%[sda]/i', $value, $result, 1); |
|
| 3500 | 3500 | } |
| 3501 | 3501 | } |
| 3502 | 3502 | $result = str_replace('%%', '%', $result); |
| 3503 | 3503 | |
| 3504 | - return new Less_Tree_Quoted( $string->quote , $result, $string->escaped); |
|
| 3504 | + return new Less_Tree_Quoted($string->quote, $result, $string->escaped); |
|
| 3505 | 3505 | } |
| 3506 | 3506 | |
| 3507 | - public function unit( $val, $unit = null) { |
|
| 3508 | - if( !($val instanceof Less_Tree_Dimension) ){ |
|
| 3509 | - throw new Less_Exception_Compiler('The first argument to unit must be a number' . ($val instanceof Less_Tree_Operation ? '. Have you forgotten parenthesis?' : '.') ); |
|
| 3507 | + public function unit($val, $unit = null) { |
|
| 3508 | + if (!($val instanceof Less_Tree_Dimension)) { |
|
| 3509 | + throw new Less_Exception_Compiler('The first argument to unit must be a number'.($val instanceof Less_Tree_Operation ? '. Have you forgotten parenthesis?' : '.')); |
|
| 3510 | 3510 | } |
| 3511 | 3511 | |
| 3512 | - if( $unit ){ |
|
| 3513 | - if( $unit instanceof Less_Tree_Keyword ){ |
|
| 3512 | + if ($unit) { |
|
| 3513 | + if ($unit instanceof Less_Tree_Keyword) { |
|
| 3514 | 3514 | $unit = $unit->value; |
| 3515 | - } else { |
|
| 3515 | + }else { |
|
| 3516 | 3516 | $unit = $unit->toCSS(); |
| 3517 | 3517 | } |
| 3518 | - } else { |
|
| 3518 | + }else { |
|
| 3519 | 3519 | $unit = ""; |
| 3520 | 3520 | } |
| 3521 | - return new Less_Tree_Dimension($val->value, $unit ); |
|
| 3521 | + return new Less_Tree_Dimension($val->value, $unit); |
|
| 3522 | 3522 | } |
| 3523 | 3523 | |
| 3524 | - public function convert($val, $unit){ |
|
| 3524 | + public function convert($val, $unit) { |
|
| 3525 | 3525 | return $val->convertTo($unit->value); |
| 3526 | 3526 | } |
| 3527 | 3527 | |
| 3528 | 3528 | public function round($n, $f = false) { |
| 3529 | 3529 | |
| 3530 | 3530 | $fraction = 0; |
| 3531 | - if( $f !== false ){ |
|
| 3531 | + if ($f!==false) { |
|
| 3532 | 3532 | $fraction = $f->value; |
| 3533 | 3533 | } |
| 3534 | 3534 | |
| 3535 | - return $this->_math('Less_Parser::round',null, $n, $fraction); |
|
| 3535 | + return $this->_math('Less_Parser::round', null, $n, $fraction); |
|
| 3536 | 3536 | } |
| 3537 | 3537 | |
| 3538 | - public function pi(){ |
|
| 3538 | + public function pi() { |
|
| 3539 | 3539 | return new Less_Tree_Dimension(M_PI); |
| 3540 | 3540 | } |
| 3541 | 3541 | |
| 3542 | 3542 | public function mod($a, $b) { |
| 3543 | - return new Less_Tree_Dimension( $a->value % $b->value, $a->unit); |
|
| 3543 | + return new Less_Tree_Dimension($a->value % $b->value, $a->unit); |
|
| 3544 | 3544 | } |
| 3545 | 3545 | |
| 3546 | 3546 | |
| 3547 | 3547 | |
| 3548 | 3548 | public function pow($x, $y) { |
| 3549 | - if( is_numeric($x) && is_numeric($y) ){ |
|
| 3549 | + if (is_numeric($x) && is_numeric($y)) { |
|
| 3550 | 3550 | $x = new Less_Tree_Dimension($x); |
| 3551 | 3551 | $y = new Less_Tree_Dimension($y); |
| 3552 | - }elseif( !($x instanceof Less_Tree_Dimension) || !($y instanceof Less_Tree_Dimension) ){ |
|
| 3552 | + }elseif (!($x instanceof Less_Tree_Dimension) || !($y instanceof Less_Tree_Dimension)) { |
|
| 3553 | 3553 | throw new Less_Exception_Compiler('Arguments must be numbers'); |
| 3554 | 3554 | } |
| 3555 | 3555 | |
| 3556 | - return new Less_Tree_Dimension( pow($x->value, $y->value), $x->unit ); |
|
| 3556 | + return new Less_Tree_Dimension(pow($x->value, $y->value), $x->unit); |
|
| 3557 | 3557 | } |
| 3558 | 3558 | |
| 3559 | 3559 | // var mathFunctions = [{name:"ce ... |
| 3560 | - public function ceil( $n ){ return $this->_math('ceil', null, $n); } |
|
| 3561 | - public function floor( $n ){ return $this->_math('floor', null, $n); } |
|
| 3562 | - public function sqrt( $n ){ return $this->_math('sqrt', null, $n); } |
|
| 3563 | - public function abs( $n ){ return $this->_math('abs', null, $n); } |
|
| 3560 | + public function ceil($n) { return $this->_math('ceil', null, $n); } |
|
| 3561 | + public function floor($n) { return $this->_math('floor', null, $n); } |
|
| 3562 | + public function sqrt($n) { return $this->_math('sqrt', null, $n); } |
|
| 3563 | + public function abs($n) { return $this->_math('abs', null, $n); } |
|
| 3564 | 3564 | |
| 3565 | - public function tan( $n ){ return $this->_math('tan', '', $n); } |
|
| 3566 | - public function sin( $n ){ return $this->_math('sin', '', $n); } |
|
| 3567 | - public function cos( $n ){ return $this->_math('cos', '', $n); } |
|
| 3565 | + public function tan($n) { return $this->_math('tan', '', $n); } |
|
| 3566 | + public function sin($n) { return $this->_math('sin', '', $n); } |
|
| 3567 | + public function cos($n) { return $this->_math('cos', '', $n); } |
|
| 3568 | 3568 | |
| 3569 | - public function atan( $n ){ return $this->_math('atan', 'rad', $n); } |
|
| 3570 | - public function asin( $n ){ return $this->_math('asin', 'rad', $n); } |
|
| 3571 | - public function acos( $n ){ return $this->_math('acos', 'rad', $n); } |
|
| 3569 | + public function atan($n) { return $this->_math('atan', 'rad', $n); } |
|
| 3570 | + public function asin($n) { return $this->_math('asin', 'rad', $n); } |
|
| 3571 | + public function acos($n) { return $this->_math('acos', 'rad', $n); } |
|
| 3572 | 3572 | |
| 3573 | 3573 | private function _math() { |
| 3574 | 3574 | $args = func_get_args(); |
@@ -3577,16 +3577,16 @@ discard block |
||
| 3577 | 3577 | |
| 3578 | 3578 | if ($args[0] instanceof Less_Tree_Dimension) { |
| 3579 | 3579 | |
| 3580 | - if( $unit === null ){ |
|
| 3580 | + if ($unit===null) { |
|
| 3581 | 3581 | $unit = $args[0]->unit; |
| 3582 | - }else{ |
|
| 3582 | + }else { |
|
| 3583 | 3583 | $args[0] = $args[0]->unify(); |
| 3584 | 3584 | } |
| 3585 | 3585 | $args[0] = (float)$args[0]->value; |
| 3586 | - return new Less_Tree_Dimension( call_user_func_array($fn, $args), $unit); |
|
| 3587 | - } else if (is_numeric($args[0])) { |
|
| 3588 | - return call_user_func_array($fn,$args); |
|
| 3589 | - } else { |
|
| 3586 | + return new Less_Tree_Dimension(call_user_func_array($fn, $args), $unit); |
|
| 3587 | + }else if (is_numeric($args[0])) { |
|
| 3588 | + return call_user_func_array($fn, $args); |
|
| 3589 | + }else { |
|
| 3590 | 3590 | throw new Less_Exception_Compiler("math functions take numbers as parameters"); |
| 3591 | 3591 | } |
| 3592 | 3592 | } |
@@ -3594,12 +3594,12 @@ discard block |
||
| 3594 | 3594 | /** |
| 3595 | 3595 | * @param boolean $isMin |
| 3596 | 3596 | */ |
| 3597 | - private function _minmax( $isMin, $args ){ |
|
| 3597 | + private function _minmax($isMin, $args) { |
|
| 3598 | 3598 | |
| 3599 | 3599 | $arg_count = count($args); |
| 3600 | 3600 | |
| 3601 | - if( $arg_count < 1 ){ |
|
| 3602 | - throw new Less_Exception_Compiler( 'one or more arguments required'); |
|
| 3601 | + if ($arg_count<1) { |
|
| 3602 | + throw new Less_Exception_Compiler('one or more arguments required'); |
|
| 3603 | 3603 | } |
| 3604 | 3604 | |
| 3605 | 3605 | $j = null; |
@@ -3607,49 +3607,49 @@ discard block |
||
| 3607 | 3607 | $unitStatic = null; |
| 3608 | 3608 | |
| 3609 | 3609 | |
| 3610 | - $order = array(); // elems only contains original argument values. |
|
| 3611 | - $values = array(); // key is the unit.toString() for unified tree.Dimension values, |
|
| 3610 | + $order = array(); // elems only contains original argument values. |
|
| 3611 | + $values = array(); // key is the unit.toString() for unified tree.Dimension values, |
|
| 3612 | 3612 | // value is the index into the order array. |
| 3613 | 3613 | |
| 3614 | 3614 | |
| 3615 | - for( $i = 0; $i < $arg_count; $i++ ){ |
|
| 3615 | + for ($i = 0; $i<$arg_count; $i++) { |
|
| 3616 | 3616 | $current = $args[$i]; |
| 3617 | - if( !($current instanceof Less_Tree_Dimension) ){ |
|
| 3618 | - if( is_array($args[$i]->value) ){ |
|
| 3617 | + if (!($current instanceof Less_Tree_Dimension)) { |
|
| 3618 | + if (is_array($args[$i]->value)) { |
|
| 3619 | 3619 | $args[] = $args[$i]->value; |
| 3620 | 3620 | } |
| 3621 | 3621 | continue; |
| 3622 | 3622 | } |
| 3623 | 3623 | |
| 3624 | - if( $current->unit->toString() === '' && !$unitClone ){ |
|
| 3624 | + if ($current->unit->toString()==='' && !$unitClone) { |
|
| 3625 | 3625 | $temp = new Less_Tree_Dimension($current->value, $unitClone); |
| 3626 | 3626 | $currentUnified = $temp->unify(); |
| 3627 | - }else{ |
|
| 3627 | + }else { |
|
| 3628 | 3628 | $currentUnified = $current->unify(); |
| 3629 | 3629 | } |
| 3630 | 3630 | |
| 3631 | - if( $currentUnified->unit->toString() === "" && !$unitStatic ){ |
|
| 3631 | + if ($currentUnified->unit->toString()==="" && !$unitStatic) { |
|
| 3632 | 3632 | $unit = $unitStatic; |
| 3633 | - }else{ |
|
| 3633 | + }else { |
|
| 3634 | 3634 | $unit = $currentUnified->unit->toString(); |
| 3635 | 3635 | } |
| 3636 | 3636 | |
| 3637 | - if( $unit !== '' && !$unitStatic || $unit !== '' && $order[0]->unify()->unit->toString() === "" ){ |
|
| 3637 | + if ($unit!=='' && !$unitStatic || $unit!=='' && $order[0]->unify()->unit->toString()==="") { |
|
| 3638 | 3638 | $unitStatic = $unit; |
| 3639 | 3639 | } |
| 3640 | 3640 | |
| 3641 | - if( $unit != '' && !$unitClone ){ |
|
| 3641 | + if ($unit!='' && !$unitClone) { |
|
| 3642 | 3642 | $unitClone = $current->unit->toString(); |
| 3643 | 3643 | } |
| 3644 | 3644 | |
| 3645 | - if( isset($values['']) && $unit !== '' && $unit === $unitStatic ){ |
|
| 3645 | + if (isset($values['']) && $unit!=='' && $unit===$unitStatic) { |
|
| 3646 | 3646 | $j = $values['']; |
| 3647 | - }elseif( isset($values[$unit]) ){ |
|
| 3647 | + }elseif (isset($values[$unit])) { |
|
| 3648 | 3648 | $j = $values[$unit]; |
| 3649 | - }else{ |
|
| 3649 | + }else { |
|
| 3650 | 3650 | |
| 3651 | - if( $unitStatic && $unit !== $unitStatic ){ |
|
| 3652 | - throw new Less_Exception_Compiler( 'incompatible types'); |
|
| 3651 | + if ($unitStatic && $unit!==$unitStatic) { |
|
| 3652 | + throw new Less_Exception_Compiler('incompatible types'); |
|
| 3653 | 3653 | } |
| 3654 | 3654 | $values[$unit] = count($order); |
| 3655 | 3655 | $order[] = $current; |
@@ -3657,44 +3657,44 @@ discard block |
||
| 3657 | 3657 | } |
| 3658 | 3658 | |
| 3659 | 3659 | |
| 3660 | - if( $order[$j]->unit->toString() === "" && $unitClone ){ |
|
| 3661 | - $temp = new Less_Tree_Dimension( $order[$j]->value, $unitClone); |
|
| 3660 | + if ($order[$j]->unit->toString()==="" && $unitClone) { |
|
| 3661 | + $temp = new Less_Tree_Dimension($order[$j]->value, $unitClone); |
|
| 3662 | 3662 | $referenceUnified = $temp->unify(); |
| 3663 | - }else{ |
|
| 3663 | + }else { |
|
| 3664 | 3664 | $referenceUnified = $order[$j]->unify(); |
| 3665 | 3665 | } |
| 3666 | - if( ($isMin && $currentUnified->value < $referenceUnified->value) || (!$isMin && $currentUnified->value > $referenceUnified->value) ){ |
|
| 3666 | + if (($isMin && $currentUnified->value<$referenceUnified->value) || (!$isMin && $currentUnified->value>$referenceUnified->value)) { |
|
| 3667 | 3667 | $order[$j] = $current; |
| 3668 | 3668 | } |
| 3669 | 3669 | } |
| 3670 | 3670 | |
| 3671 | - if( count($order) == 1 ){ |
|
| 3671 | + if (count($order)==1) { |
|
| 3672 | 3672 | return $order[0]; |
| 3673 | 3673 | } |
| 3674 | 3674 | $args = array(); |
| 3675 | - foreach($order as $a){ |
|
| 3675 | + foreach ($order as $a) { |
|
| 3676 | 3676 | $args[] = $a->toCSS($this->env); |
| 3677 | 3677 | } |
| 3678 | - return new Less_Tree_Anonymous( ($isMin?'min(':'max(') . implode(Less_Environment::$_outputMap[','],$args).')'); |
|
| 3678 | + return new Less_Tree_Anonymous(($isMin ? 'min(' : 'max(').implode(Less_Environment::$_outputMap[','], $args).')'); |
|
| 3679 | 3679 | } |
| 3680 | 3680 | |
| 3681 | - public function min(){ |
|
| 3681 | + public function min() { |
|
| 3682 | 3682 | $args = func_get_args(); |
| 3683 | - return $this->_minmax( true, $args ); |
|
| 3683 | + return $this->_minmax(true, $args); |
|
| 3684 | 3684 | } |
| 3685 | 3685 | |
| 3686 | - public function max(){ |
|
| 3686 | + public function max() { |
|
| 3687 | 3687 | $args = func_get_args(); |
| 3688 | - return $this->_minmax( false, $args ); |
|
| 3688 | + return $this->_minmax(false, $args); |
|
| 3689 | 3689 | } |
| 3690 | 3690 | |
| 3691 | - public function getunit($n){ |
|
| 3691 | + public function getunit($n) { |
|
| 3692 | 3692 | return new Less_Tree_Anonymous($n->unit); |
| 3693 | 3693 | } |
| 3694 | 3694 | |
| 3695 | 3695 | public function argb($color) { |
| 3696 | 3696 | if (!$color instanceof Less_Tree_Color) { |
| 3697 | - throw new Less_Exception_Compiler('The first argument to argb must be a color' . ($dark instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3697 | + throw new Less_Exception_Compiler('The first argument to argb must be a color'.($dark instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3698 | 3698 | } |
| 3699 | 3699 | |
| 3700 | 3700 | return new Less_Tree_Anonymous($color->toARGB()); |
@@ -3706,17 +3706,17 @@ discard block |
||
| 3706 | 3706 | |
| 3707 | 3707 | public function color($n) { |
| 3708 | 3708 | |
| 3709 | - if( $n instanceof Less_Tree_Quoted ){ |
|
| 3709 | + if ($n instanceof Less_Tree_Quoted) { |
|
| 3710 | 3710 | $colorCandidate = $n->value; |
| 3711 | 3711 | $returnColor = Less_Tree_Color::fromKeyword($colorCandidate); |
| 3712 | - if( $returnColor ){ |
|
| 3712 | + if ($returnColor) { |
|
| 3713 | 3713 | return $returnColor; |
| 3714 | 3714 | } |
| 3715 | - if( preg_match('/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})/',$colorCandidate) ){ |
|
| 3715 | + if (preg_match('/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})/', $colorCandidate)) { |
|
| 3716 | 3716 | return new Less_Tree_Color(substr($colorCandidate, 1)); |
| 3717 | 3717 | } |
| 3718 | 3718 | throw new Less_Exception_Compiler("argument must be a color keyword or 3/6 digit hex e.g. #FFF"); |
| 3719 | - } else { |
|
| 3719 | + }else { |
|
| 3720 | 3720 | throw new Less_Exception_Compiler("argument must be a string"); |
| 3721 | 3721 | } |
| 3722 | 3722 | } |
@@ -3757,8 +3757,8 @@ discard block |
||
| 3757 | 3757 | /** |
| 3758 | 3758 | * @param string $unit |
| 3759 | 3759 | */ |
| 3760 | - public function isunit( $n, $unit ){ |
|
| 3761 | - 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'); |
|
| 3760 | + public function isunit($n, $unit) { |
|
| 3761 | + 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'); |
|
| 3762 | 3762 | } |
| 3763 | 3763 | |
| 3764 | 3764 | /** |
@@ -3769,64 +3769,64 @@ discard block |
||
| 3769 | 3769 | } |
| 3770 | 3770 | |
| 3771 | 3771 | public function tint($color, $amount) { |
| 3772 | - return $this->mix( $this->rgb(255,255,255), $color, $amount); |
|
| 3772 | + return $this->mix($this->rgb(255, 255, 255), $color, $amount); |
|
| 3773 | 3773 | } |
| 3774 | 3774 | |
| 3775 | 3775 | public function shade($color, $amount) { |
| 3776 | 3776 | return $this->mix($this->rgb(0, 0, 0), $color, $amount); |
| 3777 | 3777 | } |
| 3778 | 3778 | |
| 3779 | - public function extract($values, $index ){ |
|
| 3780 | - $index = (int)$index->value - 1; // (1-based index) |
|
| 3779 | + public function extract($values, $index) { |
|
| 3780 | + $index = (int)$index->value-1; // (1-based index) |
|
| 3781 | 3781 | // handle non-array values as an array of length 1 |
| 3782 | 3782 | // return 'undefined' if index is invalid |
| 3783 | - if( property_exists($values,'value') && is_array($values->value) ){ |
|
| 3784 | - if( isset($values->value[$index]) ){ |
|
| 3783 | + if (property_exists($values, 'value') && is_array($values->value)) { |
|
| 3784 | + if (isset($values->value[$index])) { |
|
| 3785 | 3785 | return $values->value[$index]; |
| 3786 | 3786 | } |
| 3787 | 3787 | return null; |
| 3788 | 3788 | |
| 3789 | - }elseif( (int)$index === 0 ){ |
|
| 3789 | + }elseif ((int)$index===0) { |
|
| 3790 | 3790 | return $values; |
| 3791 | 3791 | } |
| 3792 | 3792 | |
| 3793 | 3793 | return null; |
| 3794 | 3794 | } |
| 3795 | 3795 | |
| 3796 | - public function length($values){ |
|
| 3797 | - $n = (property_exists($values,'value') && is_array($values->value)) ? count($values->value) : 1; |
|
| 3796 | + public function length($values) { |
|
| 3797 | + $n = (property_exists($values, 'value') && is_array($values->value)) ? count($values->value) : 1; |
|
| 3798 | 3798 | return new Less_Tree_Dimension($n); |
| 3799 | 3799 | } |
| 3800 | 3800 | |
| 3801 | - public function datauri($mimetypeNode, $filePathNode = null ) { |
|
| 3801 | + public function datauri($mimetypeNode, $filePathNode = null) { |
|
| 3802 | 3802 | |
| 3803 | - $filePath = ( $filePathNode ? $filePathNode->value : null ); |
|
| 3803 | + $filePath = ($filePathNode ? $filePathNode->value : null); |
|
| 3804 | 3804 | $mimetype = $mimetypeNode->value; |
| 3805 | 3805 | |
| 3806 | 3806 | $args = 2; |
| 3807 | - if( !$filePath ){ |
|
| 3807 | + if (!$filePath) { |
|
| 3808 | 3808 | $filePath = $mimetype; |
| 3809 | 3809 | $args = 1; |
| 3810 | 3810 | } |
| 3811 | 3811 | |
| 3812 | - $filePath = str_replace('\\','/',$filePath); |
|
| 3813 | - if( Less_Environment::isPathRelative($filePath) ){ |
|
| 3812 | + $filePath = str_replace('\\', '/', $filePath); |
|
| 3813 | + if (Less_Environment::isPathRelative($filePath)) { |
|
| 3814 | 3814 | |
| 3815 | - if( Less_Parser::$options['relativeUrls'] ){ |
|
| 3815 | + if (Less_Parser::$options['relativeUrls']) { |
|
| 3816 | 3816 | $temp = $this->currentFileInfo['currentDirectory']; |
| 3817 | - } else { |
|
| 3817 | + }else { |
|
| 3818 | 3818 | $temp = $this->currentFileInfo['entryPath']; |
| 3819 | 3819 | } |
| 3820 | 3820 | |
| 3821 | - if( !empty($temp) ){ |
|
| 3822 | - $filePath = Less_Environment::normalizePath(rtrim($temp,'/').'/'.$filePath); |
|
| 3821 | + if (!empty($temp)) { |
|
| 3822 | + $filePath = Less_Environment::normalizePath(rtrim($temp, '/').'/'.$filePath); |
|
| 3823 | 3823 | } |
| 3824 | 3824 | |
| 3825 | 3825 | } |
| 3826 | 3826 | |
| 3827 | 3827 | |
| 3828 | 3828 | // detect the mimetype if not given |
| 3829 | - if( $args < 2 ){ |
|
| 3829 | + if ($args<2) { |
|
| 3830 | 3830 | |
| 3831 | 3831 | /* incomplete |
| 3832 | 3832 | $mime = require('mime'); |
@@ -3841,17 +3841,17 @@ discard block |
||
| 3841 | 3841 | $mimetype = Less_Mime::lookup($filePath); |
| 3842 | 3842 | |
| 3843 | 3843 | $charset = Less_Mime::charsets_lookup($mimetype); |
| 3844 | - $useBase64 = !in_array($charset,array('US-ASCII', 'UTF-8')); |
|
| 3845 | - if( $useBase64 ){ $mimetype .= ';base64'; } |
|
| 3844 | + $useBase64 = !in_array($charset, array('US-ASCII', 'UTF-8')); |
|
| 3845 | + if ($useBase64) { $mimetype .= ';base64'; } |
|
| 3846 | 3846 | |
| 3847 | - }else{ |
|
| 3848 | - $useBase64 = preg_match('/;base64$/',$mimetype); |
|
| 3847 | + }else { |
|
| 3848 | + $useBase64 = preg_match('/;base64$/', $mimetype); |
|
| 3849 | 3849 | } |
| 3850 | 3850 | |
| 3851 | 3851 | |
| 3852 | - if( file_exists($filePath) ){ |
|
| 3852 | + if (file_exists($filePath)) { |
|
| 3853 | 3853 | $buf = @file_get_contents($filePath); |
| 3854 | - }else{ |
|
| 3854 | + }else { |
|
| 3855 | 3855 | $buf = false; |
| 3856 | 3856 | } |
| 3857 | 3857 | |
@@ -3859,38 +3859,38 @@ discard block |
||
| 3859 | 3859 | // IE8 cannot handle a data-uri larger than 32KB. If this is exceeded |
| 3860 | 3860 | // and the --ieCompat flag is enabled, return a normal url() instead. |
| 3861 | 3861 | $DATA_URI_MAX_KB = 32; |
| 3862 | - $fileSizeInKB = round( strlen($buf) / 1024 ); |
|
| 3863 | - if( $fileSizeInKB >= $DATA_URI_MAX_KB ){ |
|
| 3864 | - $url = new Less_Tree_Url( ($filePathNode ? $filePathNode : $mimetypeNode), $this->currentFileInfo); |
|
| 3862 | + $fileSizeInKB = round(strlen($buf) / 1024); |
|
| 3863 | + if ($fileSizeInKB>=$DATA_URI_MAX_KB) { |
|
| 3864 | + $url = new Less_Tree_Url(($filePathNode ? $filePathNode : $mimetypeNode), $this->currentFileInfo); |
|
| 3865 | 3865 | return $url->compile($this); |
| 3866 | 3866 | } |
| 3867 | 3867 | |
| 3868 | - if( $buf ){ |
|
| 3868 | + if ($buf) { |
|
| 3869 | 3869 | $buf = $useBase64 ? base64_encode($buf) : rawurlencode($buf); |
| 3870 | - $filePath = '"data:' . $mimetype . ',' . $buf . '"'; |
|
| 3870 | + $filePath = '"data:'.$mimetype.','.$buf.'"'; |
|
| 3871 | 3871 | } |
| 3872 | 3872 | |
| 3873 | - return new Less_Tree_Url( new Less_Tree_Anonymous($filePath) ); |
|
| 3873 | + return new Less_Tree_Url(new Less_Tree_Anonymous($filePath)); |
|
| 3874 | 3874 | } |
| 3875 | 3875 | |
| 3876 | 3876 | //svg-gradient |
| 3877 | - public function svggradient( $direction ){ |
|
| 3877 | + public function svggradient($direction) { |
|
| 3878 | 3878 | |
| 3879 | 3879 | $throw_message = 'svg-gradient expects direction, start_color [start_position], [color position,]..., end_color [end_position]'; |
| 3880 | 3880 | $arguments = func_get_args(); |
| 3881 | 3881 | |
| 3882 | - if( count($arguments) < 3 ){ |
|
| 3883 | - throw new Less_Exception_Compiler( $throw_message ); |
|
| 3882 | + if (count($arguments)<3) { |
|
| 3883 | + throw new Less_Exception_Compiler($throw_message); |
|
| 3884 | 3884 | } |
| 3885 | 3885 | |
| 3886 | - $stops = array_slice($arguments,1); |
|
| 3886 | + $stops = array_slice($arguments, 1); |
|
| 3887 | 3887 | $gradientType = 'linear'; |
| 3888 | 3888 | $rectangleDimension = 'x="0" y="0" width="1" height="1"'; |
| 3889 | 3889 | $useBase64 = true; |
| 3890 | 3890 | $directionValue = $direction->toCSS(); |
| 3891 | 3891 | |
| 3892 | 3892 | |
| 3893 | - switch( $directionValue ){ |
|
| 3893 | + switch ($directionValue) { |
|
| 3894 | 3894 | case "to bottom": |
| 3895 | 3895 | $gradientDirectionSvg = 'x1="0%" y1="0%" x2="0%" y2="100%"'; |
| 3896 | 3896 | break; |
@@ -3910,46 +3910,46 @@ discard block |
||
| 3910 | 3910 | $rectangleDimension = 'x="-50" y="-50" width="101" height="101"'; |
| 3911 | 3911 | break; |
| 3912 | 3912 | default: |
| 3913 | - throw new Less_Exception_Compiler( "svg-gradient direction must be 'to bottom', 'to right', 'to bottom right', 'to top right' or 'ellipse at center'" ); |
|
| 3913 | + throw new Less_Exception_Compiler("svg-gradient direction must be 'to bottom', 'to right', 'to bottom right', 'to top right' or 'ellipse at center'"); |
|
| 3914 | 3914 | } |
| 3915 | 3915 | |
| 3916 | - $returner = '<?xml version="1.0" ?>' . |
|
| 3917 | - '<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="100%" height="100%" viewBox="0 0 1 1" preserveAspectRatio="none">' . |
|
| 3918 | - '<' . $gradientType . 'Gradient id="gradient" gradientUnits="userSpaceOnUse" ' . $gradientDirectionSvg . '>'; |
|
| 3916 | + $returner = '<?xml version="1.0" ?>'. |
|
| 3917 | + '<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="100%" height="100%" viewBox="0 0 1 1" preserveAspectRatio="none">'. |
|
| 3918 | + '<'.$gradientType.'Gradient id="gradient" gradientUnits="userSpaceOnUse" '.$gradientDirectionSvg.'>'; |
|
| 3919 | 3919 | |
| 3920 | - for( $i = 0; $i < count($stops); $i++ ){ |
|
| 3921 | - if( is_object($stops[$i]) && property_exists($stops[$i],'value') ){ |
|
| 3920 | + for ($i = 0; $i<count($stops); $i++) { |
|
| 3921 | + if (is_object($stops[$i]) && property_exists($stops[$i], 'value')) { |
|
| 3922 | 3922 | $color = $stops[$i]->value[0]; |
| 3923 | 3923 | $position = $stops[$i]->value[1]; |
| 3924 | - }else{ |
|
| 3924 | + }else { |
|
| 3925 | 3925 | $color = $stops[$i]; |
| 3926 | 3926 | $position = null; |
| 3927 | 3927 | } |
| 3928 | 3928 | |
| 3929 | - if( !($color instanceof Less_Tree_Color) || (!(($i === 0 || $i+1 === count($stops)) && $position === null) && !($position instanceof Less_Tree_Dimension)) ){ |
|
| 3930 | - throw new Less_Exception_Compiler( $throw_message ); |
|
| 3929 | + if (!($color instanceof Less_Tree_Color) || (!(($i===0 || $i+1===count($stops)) && $position===null) && !($position instanceof Less_Tree_Dimension))) { |
|
| 3930 | + throw new Less_Exception_Compiler($throw_message); |
|
| 3931 | 3931 | } |
| 3932 | - if( $position ){ |
|
| 3932 | + if ($position) { |
|
| 3933 | 3933 | $positionValue = $position->toCSS(); |
| 3934 | - }elseif( $i === 0 ){ |
|
| 3934 | + }elseif ($i===0) { |
|
| 3935 | 3935 | $positionValue = '0%'; |
| 3936 | - }else{ |
|
| 3936 | + }else { |
|
| 3937 | 3937 | $positionValue = '100%'; |
| 3938 | 3938 | } |
| 3939 | 3939 | $alpha = $color->alpha; |
| 3940 | - $returner .= '<stop offset="' . $positionValue . '" stop-color="' . $color->toRGB() . '"' . ($alpha < 1 ? ' stop-opacity="' . $alpha . '"' : '') . '/>'; |
|
| 3940 | + $returner .= '<stop offset="'.$positionValue.'" stop-color="'.$color->toRGB().'"'.($alpha<1 ? ' stop-opacity="'.$alpha.'"' : '').'/>'; |
|
| 3941 | 3941 | } |
| 3942 | 3942 | |
| 3943 | - $returner .= '</' . $gradientType . 'Gradient><rect ' . $rectangleDimension . ' fill="url(#gradient)" /></svg>'; |
|
| 3943 | + $returner .= '</'.$gradientType.'Gradient><rect '.$rectangleDimension.' fill="url(#gradient)" /></svg>'; |
|
| 3944 | 3944 | |
| 3945 | 3945 | |
| 3946 | - if( $useBase64 ){ |
|
| 3946 | + if ($useBase64) { |
|
| 3947 | 3947 | $returner = "'data:image/svg+xml;base64,".base64_encode($returner)."'"; |
| 3948 | - }else{ |
|
| 3948 | + }else { |
|
| 3949 | 3949 | $returner = "'data:image/svg+xml,".$returner."'"; |
| 3950 | 3950 | } |
| 3951 | 3951 | |
| 3952 | - return new Less_Tree_URL( new Less_Tree_Anonymous( $returner ) ); |
|
| 3952 | + return new Less_Tree_URL(new Less_Tree_Anonymous($returner)); |
|
| 3953 | 3953 | } |
| 3954 | 3954 | |
| 3955 | 3955 | |
@@ -3959,7 +3959,7 @@ discard block |
||
| 3959 | 3959 | * @param string $string The string to encode |
| 3960 | 3960 | * @return string The encoded string |
| 3961 | 3961 | */ |
| 3962 | - public static function encodeURIComponent($string){ |
|
| 3962 | + public static function encodeURIComponent($string) { |
|
| 3963 | 3963 | $revert = array('%21' => '!', '%2A' => '*', '%27' => "'", '%28' => '(', '%29' => ')'); |
| 3964 | 3964 | return strtr(rawurlencode($string), $revert); |
| 3965 | 3965 | } |
@@ -3968,18 +3968,18 @@ discard block |
||
| 3968 | 3968 | // Color Blending |
| 3969 | 3969 | // ref: http://www.w3.org/TR/compositing-1 |
| 3970 | 3970 | |
| 3971 | - public function colorBlend( $mode, $color1, $color2 ){ |
|
| 3972 | - $ab = $color1->alpha; // backdrop |
|
| 3973 | - $as = $color2->alpha; // source |
|
| 3974 | - $r = array(); // result |
|
| 3971 | + public function colorBlend($mode, $color1, $color2) { |
|
| 3972 | + $ab = $color1->alpha; // backdrop |
|
| 3973 | + $as = $color2->alpha; // source |
|
| 3974 | + $r = array(); // result |
|
| 3975 | 3975 | |
| 3976 | - $ar = $as + $ab * (1 - $as); |
|
| 3977 | - for( $i = 0; $i < 3; $i++ ){ |
|
| 3976 | + $ar = $as+$ab * (1-$as); |
|
| 3977 | + for ($i = 0; $i<3; $i++) { |
|
| 3978 | 3978 | $cb = $color1->rgb[$i] / 255; |
| 3979 | 3979 | $cs = $color2->rgb[$i] / 255; |
| 3980 | - $cr = call_user_func( $mode, $cb, $cs ); |
|
| 3981 | - if( $ar ){ |
|
| 3982 | - $cr = ($as * $cs + $ab * ($cb - $as * ($cb + $cs - $cr))) / $ar; |
|
| 3980 | + $cr = call_user_func($mode, $cb, $cs); |
|
| 3981 | + if ($ar) { |
|
| 3982 | + $cr = ($as * $cs+$ab * ($cb-$as * ($cb+$cs-$cr))) / $ar; |
|
| 3983 | 3983 | } |
| 3984 | 3984 | $r[$i] = $cr * 255; |
| 3985 | 3985 | } |
@@ -3987,150 +3987,150 @@ discard block |
||
| 3987 | 3987 | return new Less_Tree_Color($r, $ar); |
| 3988 | 3988 | } |
| 3989 | 3989 | |
| 3990 | - public function multiply($color1 = null, $color2 = null ){ |
|
| 3990 | + public function multiply($color1 = null, $color2 = null) { |
|
| 3991 | 3991 | if (!$color1 instanceof Less_Tree_Color) { |
| 3992 | - throw new Less_Exception_Compiler('The first argument to multiply must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3992 | + throw new Less_Exception_Compiler('The first argument to multiply must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3993 | 3993 | } |
| 3994 | 3994 | if (!$color2 instanceof Less_Tree_Color) { |
| 3995 | - throw new Less_Exception_Compiler('The second argument to multiply must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 3995 | + throw new Less_Exception_Compiler('The second argument to multiply must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 3996 | 3996 | } |
| 3997 | 3997 | |
| 3998 | - return $this->colorBlend( array($this,'colorBlendMultiply'), $color1, $color2 ); |
|
| 3998 | + return $this->colorBlend(array($this, 'colorBlendMultiply'), $color1, $color2); |
|
| 3999 | 3999 | } |
| 4000 | 4000 | |
| 4001 | - private function colorBlendMultiply($cb, $cs){ |
|
| 4001 | + private function colorBlendMultiply($cb, $cs) { |
|
| 4002 | 4002 | return $cb * $cs; |
| 4003 | 4003 | } |
| 4004 | 4004 | |
| 4005 | - public function screen($color1 = null, $color2 = null ){ |
|
| 4005 | + public function screen($color1 = null, $color2 = null) { |
|
| 4006 | 4006 | if (!$color1 instanceof Less_Tree_Color) { |
| 4007 | - throw new Less_Exception_Compiler('The first argument to screen must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 4007 | + throw new Less_Exception_Compiler('The first argument to screen must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 4008 | 4008 | } |
| 4009 | 4009 | if (!$color2 instanceof Less_Tree_Color) { |
| 4010 | - throw new Less_Exception_Compiler('The second argument to screen must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 4010 | + throw new Less_Exception_Compiler('The second argument to screen must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 4011 | 4011 | } |
| 4012 | 4012 | |
| 4013 | - return $this->colorBlend( array($this,'colorBlendScreen'), $color1, $color2 ); |
|
| 4013 | + return $this->colorBlend(array($this, 'colorBlendScreen'), $color1, $color2); |
|
| 4014 | 4014 | } |
| 4015 | 4015 | |
| 4016 | - private function colorBlendScreen( $cb, $cs){ |
|
| 4017 | - return $cb + $cs - $cb * $cs; |
|
| 4016 | + private function colorBlendScreen($cb, $cs) { |
|
| 4017 | + return $cb+$cs-$cb * $cs; |
|
| 4018 | 4018 | } |
| 4019 | 4019 | |
| 4020 | - public function overlay($color1 = null, $color2 = null){ |
|
| 4020 | + public function overlay($color1 = null, $color2 = null) { |
|
| 4021 | 4021 | if (!$color1 instanceof Less_Tree_Color) { |
| 4022 | - throw new Less_Exception_Compiler('The first argument to overlay must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 4022 | + throw new Less_Exception_Compiler('The first argument to overlay must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 4023 | 4023 | } |
| 4024 | 4024 | if (!$color2 instanceof Less_Tree_Color) { |
| 4025 | - throw new Less_Exception_Compiler('The second argument to overlay must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 4025 | + throw new Less_Exception_Compiler('The second argument to overlay must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 4026 | 4026 | } |
| 4027 | 4027 | |
| 4028 | - return $this->colorBlend( array($this,'colorBlendOverlay'), $color1, $color2 ); |
|
| 4028 | + return $this->colorBlend(array($this, 'colorBlendOverlay'), $color1, $color2); |
|
| 4029 | 4029 | } |
| 4030 | 4030 | |
| 4031 | - private function colorBlendOverlay($cb, $cs ){ |
|
| 4031 | + private function colorBlendOverlay($cb, $cs) { |
|
| 4032 | 4032 | $cb *= 2; |
| 4033 | - return ($cb <= 1) |
|
| 4033 | + return ($cb<=1) |
|
| 4034 | 4034 | ? $this->colorBlendMultiply($cb, $cs) |
| 4035 | - : $this->colorBlendScreen($cb - 1, $cs); |
|
| 4035 | + : $this->colorBlendScreen($cb-1, $cs); |
|
| 4036 | 4036 | } |
| 4037 | 4037 | |
| 4038 | - public function softlight($color1 = null, $color2 = null){ |
|
| 4038 | + public function softlight($color1 = null, $color2 = null) { |
|
| 4039 | 4039 | if (!$color1 instanceof Less_Tree_Color) { |
| 4040 | - throw new Less_Exception_Compiler('The first argument to softlight must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 4040 | + throw new Less_Exception_Compiler('The first argument to softlight must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 4041 | 4041 | } |
| 4042 | 4042 | if (!$color2 instanceof Less_Tree_Color) { |
| 4043 | - throw new Less_Exception_Compiler('The second argument to softlight must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 4043 | + throw new Less_Exception_Compiler('The second argument to softlight must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 4044 | 4044 | } |
| 4045 | 4045 | |
| 4046 | - return $this->colorBlend( array($this,'colorBlendSoftlight'), $color1, $color2 ); |
|
| 4046 | + return $this->colorBlend(array($this, 'colorBlendSoftlight'), $color1, $color2); |
|
| 4047 | 4047 | } |
| 4048 | 4048 | |
| 4049 | - private function colorBlendSoftlight($cb, $cs ){ |
|
| 4049 | + private function colorBlendSoftlight($cb, $cs) { |
|
| 4050 | 4050 | $d = 1; |
| 4051 | 4051 | $e = $cb; |
| 4052 | - if( $cs > 0.5 ){ |
|
| 4052 | + if ($cs>0.5) { |
|
| 4053 | 4053 | $e = 1; |
| 4054 | - $d = ($cb > 0.25) ? sqrt($cb) |
|
| 4055 | - : ((16 * $cb - 12) * $cb + 4) * $cb; |
|
| 4054 | + $d = ($cb>0.25) ? sqrt($cb) |
|
| 4055 | + : ((16 * $cb-12) * $cb+4) * $cb; |
|
| 4056 | 4056 | } |
| 4057 | - return $cb - (1 - 2 * $cs) * $e * ($d - $cb); |
|
| 4057 | + return $cb-(1-2 * $cs) * $e * ($d-$cb); |
|
| 4058 | 4058 | } |
| 4059 | 4059 | |
| 4060 | - public function hardlight($color1 = null, $color2 = null){ |
|
| 4060 | + public function hardlight($color1 = null, $color2 = null) { |
|
| 4061 | 4061 | if (!$color1 instanceof Less_Tree_Color) { |
| 4062 | - throw new Less_Exception_Compiler('The first argument to hardlight must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 4062 | + throw new Less_Exception_Compiler('The first argument to hardlight must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 4063 | 4063 | } |
| 4064 | 4064 | if (!$color2 instanceof Less_Tree_Color) { |
| 4065 | - throw new Less_Exception_Compiler('The second argument to hardlight must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 4065 | + throw new Less_Exception_Compiler('The second argument to hardlight must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 4066 | 4066 | } |
| 4067 | 4067 | |
| 4068 | - return $this->colorBlend( array($this,'colorBlendHardlight'), $color1, $color2 ); |
|
| 4068 | + return $this->colorBlend(array($this, 'colorBlendHardlight'), $color1, $color2); |
|
| 4069 | 4069 | } |
| 4070 | 4070 | |
| 4071 | - private function colorBlendHardlight( $cb, $cs ){ |
|
| 4071 | + private function colorBlendHardlight($cb, $cs) { |
|
| 4072 | 4072 | return $this->colorBlendOverlay($cs, $cb); |
| 4073 | 4073 | } |
| 4074 | 4074 | |
| 4075 | 4075 | public function difference($color1 = null, $color2 = null) { |
| 4076 | 4076 | if (!$color1 instanceof Less_Tree_Color) { |
| 4077 | - throw new Less_Exception_Compiler('The first argument to difference must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 4077 | + throw new Less_Exception_Compiler('The first argument to difference must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 4078 | 4078 | } |
| 4079 | 4079 | if (!$color2 instanceof Less_Tree_Color) { |
| 4080 | - throw new Less_Exception_Compiler('The second argument to difference must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 4080 | + throw new Less_Exception_Compiler('The second argument to difference must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 4081 | 4081 | } |
| 4082 | 4082 | |
| 4083 | - return $this->colorBlend( array($this,'colorBlendDifference'), $color1, $color2 ); |
|
| 4083 | + return $this->colorBlend(array($this, 'colorBlendDifference'), $color1, $color2); |
|
| 4084 | 4084 | } |
| 4085 | 4085 | |
| 4086 | - private function colorBlendDifference( $cb, $cs ){ |
|
| 4087 | - return abs($cb - $cs); |
|
| 4086 | + private function colorBlendDifference($cb, $cs) { |
|
| 4087 | + return abs($cb-$cs); |
|
| 4088 | 4088 | } |
| 4089 | 4089 | |
| 4090 | - public function exclusion( $color1 = null, $color2 = null ){ |
|
| 4090 | + public function exclusion($color1 = null, $color2 = null) { |
|
| 4091 | 4091 | if (!$color1 instanceof Less_Tree_Color) { |
| 4092 | - throw new Less_Exception_Compiler('The first argument to exclusion must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 4092 | + throw new Less_Exception_Compiler('The first argument to exclusion must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 4093 | 4093 | } |
| 4094 | 4094 | if (!$color2 instanceof Less_Tree_Color) { |
| 4095 | - throw new Less_Exception_Compiler('The second argument to exclusion must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 4095 | + throw new Less_Exception_Compiler('The second argument to exclusion must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 4096 | 4096 | } |
| 4097 | 4097 | |
| 4098 | - return $this->colorBlend( array($this,'colorBlendExclusion'), $color1, $color2 ); |
|
| 4098 | + return $this->colorBlend(array($this, 'colorBlendExclusion'), $color1, $color2); |
|
| 4099 | 4099 | } |
| 4100 | 4100 | |
| 4101 | - private function colorBlendExclusion( $cb, $cs ){ |
|
| 4102 | - return $cb + $cs - 2 * $cb * $cs; |
|
| 4101 | + private function colorBlendExclusion($cb, $cs) { |
|
| 4102 | + return $cb+$cs-2 * $cb * $cs; |
|
| 4103 | 4103 | } |
| 4104 | 4104 | |
| 4105 | - public function average($color1 = null, $color2 = null){ |
|
| 4105 | + public function average($color1 = null, $color2 = null) { |
|
| 4106 | 4106 | if (!$color1 instanceof Less_Tree_Color) { |
| 4107 | - throw new Less_Exception_Compiler('The first argument to average must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 4107 | + throw new Less_Exception_Compiler('The first argument to average must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 4108 | 4108 | } |
| 4109 | 4109 | if (!$color2 instanceof Less_Tree_Color) { |
| 4110 | - throw new Less_Exception_Compiler('The second argument to average must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 4110 | + throw new Less_Exception_Compiler('The second argument to average must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 4111 | 4111 | } |
| 4112 | 4112 | |
| 4113 | - return $this->colorBlend( array($this,'colorBlendAverage'), $color1, $color2 ); |
|
| 4113 | + return $this->colorBlend(array($this, 'colorBlendAverage'), $color1, $color2); |
|
| 4114 | 4114 | } |
| 4115 | 4115 | |
| 4116 | 4116 | // non-w3c functions: |
| 4117 | - public function colorBlendAverage($cb, $cs ){ |
|
| 4118 | - return ($cb + $cs) / 2; |
|
| 4117 | + public function colorBlendAverage($cb, $cs) { |
|
| 4118 | + return ($cb+$cs) / 2; |
|
| 4119 | 4119 | } |
| 4120 | 4120 | |
| 4121 | - public function negation($color1 = null, $color2 = null ){ |
|
| 4121 | + public function negation($color1 = null, $color2 = null) { |
|
| 4122 | 4122 | if (!$color1 instanceof Less_Tree_Color) { |
| 4123 | - throw new Less_Exception_Compiler('The first argument to negation must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 4123 | + throw new Less_Exception_Compiler('The first argument to negation must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 4124 | 4124 | } |
| 4125 | 4125 | if (!$color2 instanceof Less_Tree_Color) { |
| 4126 | - throw new Less_Exception_Compiler('The second argument to negation must be a color' . ($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '') ); |
|
| 4126 | + throw new Less_Exception_Compiler('The second argument to negation must be a color'.($color instanceof Less_Tree_Expression ? ' (did you forgot commas?)' : '')); |
|
| 4127 | 4127 | } |
| 4128 | 4128 | |
| 4129 | - return $this->colorBlend( array($this,'colorBlendNegation'), $color1, $color2 ); |
|
| 4129 | + return $this->colorBlend(array($this, 'colorBlendNegation'), $color1, $color2); |
|
| 4130 | 4130 | } |
| 4131 | 4131 | |
| 4132 | - public function colorBlendNegation($cb, $cs){ |
|
| 4133 | - return 1 - abs($cb + $cs - 1); |
|
| 4132 | + public function colorBlendNegation($cb, $cs) { |
|
| 4133 | + return 1-abs($cb+$cs-1); |
|
| 4134 | 4134 | } |
| 4135 | 4135 | |
| 4136 | 4136 | // ~ End of Color Blending |
@@ -4144,7 +4144,7 @@ discard block |
||
| 4144 | 4144 | * @package Less |
| 4145 | 4145 | * @subpackage node |
| 4146 | 4146 | */ |
| 4147 | -class Less_Mime{ |
|
| 4147 | +class Less_Mime { |
|
| 4148 | 4148 | |
| 4149 | 4149 | // this map is intentionally incomplete |
| 4150 | 4150 | // if you want more, install 'mime' dep |
@@ -4162,19 +4162,19 @@ discard block |
||
| 4162 | 4162 | '.svg' => 'image/svg+xml', |
| 4163 | 4163 | ); |
| 4164 | 4164 | |
| 4165 | - public static function lookup( $filepath ){ |
|
| 4166 | - $parts = explode('.',$filepath); |
|
| 4165 | + public static function lookup($filepath) { |
|
| 4166 | + $parts = explode('.', $filepath); |
|
| 4167 | 4167 | $ext = '.'.strtolower(array_pop($parts)); |
| 4168 | 4168 | |
| 4169 | - if( !isset(self::$_types[$ext]) ){ |
|
| 4169 | + if (!isset(self::$_types[$ext])) { |
|
| 4170 | 4170 | return null; |
| 4171 | 4171 | } |
| 4172 | 4172 | return self::$_types[$ext]; |
| 4173 | 4173 | } |
| 4174 | 4174 | |
| 4175 | - public static function charsets_lookup( $type = null ){ |
|
| 4175 | + public static function charsets_lookup($type = null) { |
|
| 4176 | 4176 | // assumes all text types are UTF-8 |
| 4177 | - return $type && preg_match('/^text\//',$type) ? 'UTF-8' : ''; |
|
| 4177 | + return $type && preg_match('/^text\//', $type) ? 'UTF-8' : ''; |
|
| 4178 | 4178 | } |
| 4179 | 4179 | } |
| 4180 | 4180 | |
@@ -4185,11 +4185,11 @@ discard block |
||
| 4185 | 4185 | * @package Less |
| 4186 | 4186 | * @subpackage tree |
| 4187 | 4187 | */ |
| 4188 | -class Less_Tree{ |
|
| 4188 | +class Less_Tree { |
|
| 4189 | 4189 | |
| 4190 | 4190 | public $cache_string; |
| 4191 | 4191 | |
| 4192 | - public function toCSS(){ |
|
| 4192 | + public function toCSS() { |
|
| 4193 | 4193 | $output = new Less_Output(); |
| 4194 | 4194 | $this->genCSS($output); |
| 4195 | 4195 | return $output->toString(); |
@@ -4202,51 +4202,51 @@ discard block |
||
| 4202 | 4202 | * @param Less_Output $output The output |
| 4203 | 4203 | * @return void |
| 4204 | 4204 | */ |
| 4205 | - public function genCSS($output){} |
|
| 4205 | + public function genCSS($output) {} |
|
| 4206 | 4206 | |
| 4207 | 4207 | |
| 4208 | 4208 | /** |
| 4209 | 4209 | * @param Less_Tree_Ruleset[] $rules |
| 4210 | 4210 | */ |
| 4211 | - public static function outputRuleset( $output, $rules ){ |
|
| 4211 | + public static function outputRuleset($output, $rules) { |
|
| 4212 | 4212 | |
| 4213 | 4213 | $ruleCnt = count($rules); |
| 4214 | 4214 | Less_Environment::$tabLevel++; |
| 4215 | 4215 | |
| 4216 | 4216 | |
| 4217 | 4217 | // Compressed |
| 4218 | - if( Less_Parser::$options['compress'] ){ |
|
| 4218 | + if (Less_Parser::$options['compress']) { |
|
| 4219 | 4219 | $output->add('{'); |
| 4220 | - for( $i = 0; $i < $ruleCnt; $i++ ){ |
|
| 4221 | - $rules[$i]->genCSS( $output ); |
|
| 4220 | + for ($i = 0; $i<$ruleCnt; $i++) { |
|
| 4221 | + $rules[$i]->genCSS($output); |
|
| 4222 | 4222 | } |
| 4223 | 4223 | |
| 4224 | - $output->add( '}' ); |
|
| 4224 | + $output->add('}'); |
|
| 4225 | 4225 | Less_Environment::$tabLevel--; |
| 4226 | 4226 | return; |
| 4227 | 4227 | } |
| 4228 | 4228 | |
| 4229 | 4229 | |
| 4230 | 4230 | // Non-compressed |
| 4231 | - $tabSetStr = "\n".str_repeat( ' ' , Less_Environment::$tabLevel-1 ); |
|
| 4231 | + $tabSetStr = "\n".str_repeat(' ', Less_Environment::$tabLevel-1); |
|
| 4232 | 4232 | $tabRuleStr = $tabSetStr.' '; |
| 4233 | 4233 | |
| 4234 | - $output->add( " {" ); |
|
| 4235 | - for($i = 0; $i < $ruleCnt; $i++ ){ |
|
| 4236 | - $output->add( $tabRuleStr ); |
|
| 4237 | - $rules[$i]->genCSS( $output ); |
|
| 4234 | + $output->add(" {"); |
|
| 4235 | + for ($i = 0; $i<$ruleCnt; $i++) { |
|
| 4236 | + $output->add($tabRuleStr); |
|
| 4237 | + $rules[$i]->genCSS($output); |
|
| 4238 | 4238 | } |
| 4239 | 4239 | Less_Environment::$tabLevel--; |
| 4240 | - $output->add( $tabSetStr.'}' ); |
|
| 4240 | + $output->add($tabSetStr.'}'); |
|
| 4241 | 4241 | |
| 4242 | 4242 | } |
| 4243 | 4243 | |
| 4244 | - public function accept($visitor){} |
|
| 4244 | + public function accept($visitor) {} |
|
| 4245 | 4245 | |
| 4246 | 4246 | |
| 4247 | - public static function ReferencedArray($rules){ |
|
| 4248 | - foreach($rules as $rule){ |
|
| 4249 | - if( method_exists($rule, 'markReferenced') ){ |
|
| 4247 | + public static function ReferencedArray($rules) { |
|
| 4248 | + foreach ($rules as $rule) { |
|
| 4249 | + if (method_exists($rule, 'markReferenced')) { |
|
| 4250 | 4250 | $rule->markReferenced(); |
| 4251 | 4251 | } |
| 4252 | 4252 | } |
@@ -4256,11 +4256,11 @@ discard block |
||
| 4256 | 4256 | /** |
| 4257 | 4257 | * Requires php 5.3+ |
| 4258 | 4258 | */ |
| 4259 | - public static function __set_state($args){ |
|
| 4259 | + public static function __set_state($args) { |
|
| 4260 | 4260 | |
| 4261 | 4261 | $class = get_called_class(); |
| 4262 | - $obj = new $class(null,null,null,null); |
|
| 4263 | - foreach($args as $key => $val){ |
|
| 4262 | + $obj = new $class(null, null, null, null); |
|
| 4263 | + foreach ($args as $key => $val) { |
|
| 4264 | 4264 | $obj->$key = $val; |
| 4265 | 4265 | } |
| 4266 | 4266 | return $obj; |
@@ -4274,7 +4274,7 @@ discard block |
||
| 4274 | 4274 | * @package Less |
| 4275 | 4275 | * @subpackage output |
| 4276 | 4276 | */ |
| 4277 | -class Less_Output{ |
|
| 4277 | +class Less_Output { |
|
| 4278 | 4278 | |
| 4279 | 4279 | /** |
| 4280 | 4280 | * Output holder |
@@ -4291,7 +4291,7 @@ discard block |
||
| 4291 | 4291 | * @param integer $index The index |
| 4292 | 4292 | * @param mixed $mapLines |
| 4293 | 4293 | */ |
| 4294 | - public function add($chunk, $fileInfo = null, $index = 0, $mapLines = null){ |
|
| 4294 | + public function add($chunk, $fileInfo = null, $index = 0, $mapLines = null) { |
|
| 4295 | 4295 | $this->strs[] = $chunk; |
| 4296 | 4296 | } |
| 4297 | 4297 | |
@@ -4300,8 +4300,8 @@ discard block |
||
| 4300 | 4300 | * |
| 4301 | 4301 | * @return boolean |
| 4302 | 4302 | */ |
| 4303 | - public function isEmpty(){ |
|
| 4304 | - return count($this->strs) === 0; |
|
| 4303 | + public function isEmpty() { |
|
| 4304 | + return count($this->strs)===0; |
|
| 4305 | 4305 | } |
| 4306 | 4306 | |
| 4307 | 4307 | |
@@ -4310,8 +4310,8 @@ discard block |
||
| 4310 | 4310 | * |
| 4311 | 4311 | * @return string |
| 4312 | 4312 | */ |
| 4313 | - public function toString(){ |
|
| 4314 | - return implode('',$this->strs); |
|
| 4313 | + public function toString() { |
|
| 4314 | + return implode('', $this->strs); |
|
| 4315 | 4315 | } |
| 4316 | 4316 | |
| 4317 | 4317 | } |
@@ -4322,43 +4322,43 @@ discard block |
||
| 4322 | 4322 | * @package Less |
| 4323 | 4323 | * @subpackage visitor |
| 4324 | 4324 | */ |
| 4325 | -class Less_Visitor{ |
|
| 4325 | +class Less_Visitor { |
|
| 4326 | 4326 | |
| 4327 | 4327 | protected $methods = array(); |
| 4328 | 4328 | protected $_visitFnCache = array(); |
| 4329 | 4329 | |
| 4330 | - public function __construct(){ |
|
| 4330 | + public function __construct() { |
|
| 4331 | 4331 | $this->_visitFnCache = get_class_methods(get_class($this)); |
| 4332 | 4332 | $this->_visitFnCache = array_flip($this->_visitFnCache); |
| 4333 | 4333 | } |
| 4334 | 4334 | |
| 4335 | - public function visitObj( $node ){ |
|
| 4335 | + public function visitObj($node) { |
|
| 4336 | 4336 | |
| 4337 | 4337 | $funcName = 'visit'.$node->type; |
| 4338 | - if( isset($this->_visitFnCache[$funcName]) ){ |
|
| 4338 | + if (isset($this->_visitFnCache[$funcName])) { |
|
| 4339 | 4339 | |
| 4340 | 4340 | $visitDeeper = true; |
| 4341 | - $this->$funcName( $node, $visitDeeper ); |
|
| 4341 | + $this->$funcName($node, $visitDeeper); |
|
| 4342 | 4342 | |
| 4343 | - if( $visitDeeper ){ |
|
| 4343 | + if ($visitDeeper) { |
|
| 4344 | 4344 | $node->accept($this); |
| 4345 | 4345 | } |
| 4346 | 4346 | |
| 4347 | - $funcName = $funcName . "Out"; |
|
| 4348 | - if( isset($this->_visitFnCache[$funcName]) ){ |
|
| 4349 | - $this->$funcName( $node ); |
|
| 4347 | + $funcName = $funcName."Out"; |
|
| 4348 | + if (isset($this->_visitFnCache[$funcName])) { |
|
| 4349 | + $this->$funcName($node); |
|
| 4350 | 4350 | } |
| 4351 | 4351 | |
| 4352 | - }else{ |
|
| 4352 | + }else { |
|
| 4353 | 4353 | $node->accept($this); |
| 4354 | 4354 | } |
| 4355 | 4355 | |
| 4356 | 4356 | return $node; |
| 4357 | 4357 | } |
| 4358 | 4358 | |
| 4359 | - public function visitArray( $nodes ){ |
|
| 4359 | + public function visitArray($nodes) { |
|
| 4360 | 4360 | |
| 4361 | - array_map( array($this,'visitObj'), $nodes); |
|
| 4361 | + array_map(array($this, 'visitObj'), $nodes); |
|
| 4362 | 4362 | return $nodes; |
| 4363 | 4363 | } |
| 4364 | 4364 | } |
@@ -4371,43 +4371,43 @@ discard block |
||
| 4371 | 4371 | * @package Less |
| 4372 | 4372 | * @subpackage visitor |
| 4373 | 4373 | */ |
| 4374 | -class Less_VisitorReplacing extends Less_Visitor{ |
|
| 4374 | +class Less_VisitorReplacing extends Less_Visitor { |
|
| 4375 | 4375 | |
| 4376 | - public function visitObj( $node ){ |
|
| 4376 | + public function visitObj($node) { |
|
| 4377 | 4377 | |
| 4378 | 4378 | $funcName = 'visit'.$node->type; |
| 4379 | - if( isset($this->_visitFnCache[$funcName]) ){ |
|
| 4379 | + if (isset($this->_visitFnCache[$funcName])) { |
|
| 4380 | 4380 | |
| 4381 | 4381 | $visitDeeper = true; |
| 4382 | - $node = $this->$funcName( $node, $visitDeeper ); |
|
| 4382 | + $node = $this->$funcName($node, $visitDeeper); |
|
| 4383 | 4383 | |
| 4384 | - if( $node ){ |
|
| 4385 | - if( $visitDeeper && is_object($node) ){ |
|
| 4384 | + if ($node) { |
|
| 4385 | + if ($visitDeeper && is_object($node)) { |
|
| 4386 | 4386 | $node->accept($this); |
| 4387 | 4387 | } |
| 4388 | 4388 | |
| 4389 | - $funcName = $funcName . "Out"; |
|
| 4390 | - if( isset($this->_visitFnCache[$funcName]) ){ |
|
| 4391 | - $this->$funcName( $node ); |
|
| 4389 | + $funcName = $funcName."Out"; |
|
| 4390 | + if (isset($this->_visitFnCache[$funcName])) { |
|
| 4391 | + $this->$funcName($node); |
|
| 4392 | 4392 | } |
| 4393 | 4393 | } |
| 4394 | 4394 | |
| 4395 | - }else{ |
|
| 4395 | + }else { |
|
| 4396 | 4396 | $node->accept($this); |
| 4397 | 4397 | } |
| 4398 | 4398 | |
| 4399 | 4399 | return $node; |
| 4400 | 4400 | } |
| 4401 | 4401 | |
| 4402 | - public function visitArray( $nodes ){ |
|
| 4402 | + public function visitArray($nodes) { |
|
| 4403 | 4403 | |
| 4404 | 4404 | $newNodes = array(); |
| 4405 | - foreach($nodes as $node){ |
|
| 4405 | + foreach ($nodes as $node) { |
|
| 4406 | 4406 | $evald = $this->visitObj($node); |
| 4407 | - if( $evald ){ |
|
| 4408 | - if( is_array($evald) ){ |
|
| 4409 | - self::flatten($evald,$newNodes); |
|
| 4410 | - }else{ |
|
| 4407 | + if ($evald) { |
|
| 4408 | + if (is_array($evald)) { |
|
| 4409 | + self::flatten($evald, $newNodes); |
|
| 4410 | + }else { |
|
| 4411 | 4411 | $newNodes[] = $evald; |
| 4412 | 4412 | } |
| 4413 | 4413 | } |
@@ -4415,18 +4415,18 @@ discard block |
||
| 4415 | 4415 | return $newNodes; |
| 4416 | 4416 | } |
| 4417 | 4417 | |
| 4418 | - public function flatten( $arr, &$out ){ |
|
| 4418 | + public function flatten($arr, &$out) { |
|
| 4419 | 4419 | |
| 4420 | - foreach($arr as $item){ |
|
| 4421 | - if( !is_array($item) ){ |
|
| 4420 | + foreach ($arr as $item) { |
|
| 4421 | + if (!is_array($item)) { |
|
| 4422 | 4422 | $out[] = $item; |
| 4423 | 4423 | continue; |
| 4424 | 4424 | } |
| 4425 | 4425 | |
| 4426 | - foreach($item as $nestedItem){ |
|
| 4427 | - if( is_array($nestedItem) ){ |
|
| 4428 | - self::flatten( $nestedItem, $out); |
|
| 4429 | - }else{ |
|
| 4426 | + foreach ($item as $nestedItem) { |
|
| 4427 | + if (is_array($nestedItem)) { |
|
| 4428 | + self::flatten($nestedItem, $out); |
|
| 4429 | + }else { |
|
| 4430 | 4430 | $out[] = $nestedItem; |
| 4431 | 4431 | } |
| 4432 | 4432 | } |
@@ -4473,8 +4473,8 @@ discard block |
||
| 4473 | 4473 | * @param array|object $options |
| 4474 | 4474 | * |
| 4475 | 4475 | */ |
| 4476 | - public function setOptions($options){ |
|
| 4477 | - $options = array_intersect_key($options,$this->defaultOptions); |
|
| 4476 | + public function setOptions($options) { |
|
| 4477 | + $options = array_intersect_key($options, $this->defaultOptions); |
|
| 4478 | 4478 | $this->options = array_merge($this->defaultOptions, $this->options, $options); |
| 4479 | 4479 | } |
| 4480 | 4480 | |
@@ -4488,8 +4488,8 @@ discard block |
||
| 4488 | 4488 | * @param mixed $default Default value if confiuration of $name is not present |
| 4489 | 4489 | * @return mixed |
| 4490 | 4490 | */ |
| 4491 | - public function getOption($name, $default = null){ |
|
| 4492 | - if(isset($this->options[$name])){ |
|
| 4491 | + public function getOption($name, $default = null) { |
|
| 4492 | + if (isset($this->options[$name])) { |
|
| 4493 | 4493 | return $this->options[$name]; |
| 4494 | 4494 | } |
| 4495 | 4495 | return $default; |
@@ -4502,7 +4502,7 @@ discard block |
||
| 4502 | 4502 | * @param string $name |
| 4503 | 4503 | * @param mixed $value |
| 4504 | 4504 | */ |
| 4505 | - public function setOption($name, $value){ |
|
| 4505 | + public function setOption($name, $value) { |
|
| 4506 | 4506 | $this->options[$name] = $value; |
| 4507 | 4507 | } |
| 4508 | 4508 | |
@@ -4514,11 +4514,11 @@ discard block |
||
| 4514 | 4514 | * @package Less |
| 4515 | 4515 | * @subpackage tree |
| 4516 | 4516 | */ |
| 4517 | -class Less_Tree_Alpha extends Less_Tree{ |
|
| 4517 | +class Less_Tree_Alpha extends Less_Tree { |
|
| 4518 | 4518 | public $value; |
| 4519 | 4519 | public $type = 'Alpha'; |
| 4520 | 4520 | |
| 4521 | - public function __construct($val){ |
|
| 4521 | + public function __construct($val) { |
|
| 4522 | 4522 | $this->value = $val; |
| 4523 | 4523 | } |
| 4524 | 4524 | |
@@ -4526,9 +4526,9 @@ discard block |
||
| 4526 | 4526 | // $this->value = $visitor->visit( $this->value ); |
| 4527 | 4527 | //} |
| 4528 | 4528 | |
| 4529 | - public function compile($env){ |
|
| 4529 | + public function compile($env) { |
|
| 4530 | 4530 | |
| 4531 | - if( is_object($this->value) ){ |
|
| 4531 | + if (is_object($this->value)) { |
|
| 4532 | 4532 | $this->value = $this->value->compile($env); |
| 4533 | 4533 | } |
| 4534 | 4534 | |
@@ -4538,21 +4538,21 @@ discard block |
||
| 4538 | 4538 | /** |
| 4539 | 4539 | * @see Less_Tree::genCSS |
| 4540 | 4540 | */ |
| 4541 | - public function genCSS( $output ){ |
|
| 4541 | + public function genCSS($output) { |
|
| 4542 | 4542 | |
| 4543 | - $output->add( "alpha(opacity=" ); |
|
| 4543 | + $output->add("alpha(opacity="); |
|
| 4544 | 4544 | |
| 4545 | - if( is_string($this->value) ){ |
|
| 4546 | - $output->add( $this->value ); |
|
| 4547 | - }else{ |
|
| 4548 | - $this->value->genCSS( $output); |
|
| 4545 | + if (is_string($this->value)) { |
|
| 4546 | + $output->add($this->value); |
|
| 4547 | + }else { |
|
| 4548 | + $this->value->genCSS($output); |
|
| 4549 | 4549 | } |
| 4550 | 4550 | |
| 4551 | - $output->add( ')' ); |
|
| 4551 | + $output->add(')'); |
|
| 4552 | 4552 | } |
| 4553 | 4553 | |
| 4554 | - public function toCSS(){ |
|
| 4555 | - return "alpha(opacity=" . (is_string($this->value) ? $this->value : $this->value->toCSS()) . ")"; |
|
| 4554 | + public function toCSS() { |
|
| 4555 | + return "alpha(opacity=".(is_string($this->value) ? $this->value : $this->value->toCSS()).")"; |
|
| 4556 | 4556 | } |
| 4557 | 4557 | |
| 4558 | 4558 | |
@@ -4564,7 +4564,7 @@ discard block |
||
| 4564 | 4564 | * @package Less |
| 4565 | 4565 | * @subpackage tree |
| 4566 | 4566 | */ |
| 4567 | -class Less_Tree_Anonymous extends Less_Tree{ |
|
| 4567 | +class Less_Tree_Anonymous extends Less_Tree { |
|
| 4568 | 4568 | public $value; |
| 4569 | 4569 | public $quote; |
| 4570 | 4570 | public $index; |
@@ -4576,40 +4576,40 @@ discard block |
||
| 4576 | 4576 | * @param integer $index |
| 4577 | 4577 | * @param boolean $mapLines |
| 4578 | 4578 | */ |
| 4579 | - public function __construct($value, $index = null, $currentFileInfo = null, $mapLines = null ){ |
|
| 4579 | + public function __construct($value, $index = null, $currentFileInfo = null, $mapLines = null) { |
|
| 4580 | 4580 | $this->value = $value; |
| 4581 | 4581 | $this->index = $index; |
| 4582 | 4582 | $this->mapLines = $mapLines; |
| 4583 | 4583 | $this->currentFileInfo = $currentFileInfo; |
| 4584 | 4584 | } |
| 4585 | 4585 | |
| 4586 | - public function compile(){ |
|
| 4586 | + public function compile() { |
|
| 4587 | 4587 | return new Less_Tree_Anonymous($this->value, $this->index, $this->currentFileInfo, $this->mapLines); |
| 4588 | 4588 | } |
| 4589 | 4589 | |
| 4590 | - public function compare($x){ |
|
| 4591 | - if( !is_object($x) ){ |
|
| 4590 | + public function compare($x) { |
|
| 4591 | + if (!is_object($x)) { |
|
| 4592 | 4592 | return -1; |
| 4593 | 4593 | } |
| 4594 | 4594 | |
| 4595 | 4595 | $left = $this->toCSS(); |
| 4596 | 4596 | $right = $x->toCSS(); |
| 4597 | 4597 | |
| 4598 | - if( $left === $right ){ |
|
| 4598 | + if ($left===$right) { |
|
| 4599 | 4599 | return 0; |
| 4600 | 4600 | } |
| 4601 | 4601 | |
| 4602 | - return $left < $right ? -1 : 1; |
|
| 4602 | + return $left<$right ? -1 : 1; |
|
| 4603 | 4603 | } |
| 4604 | 4604 | |
| 4605 | 4605 | /** |
| 4606 | 4606 | * @see Less_Tree::genCSS |
| 4607 | 4607 | */ |
| 4608 | - public function genCSS( $output ){ |
|
| 4609 | - $output->add( $this->value, $this->currentFileInfo, $this->index, $this->mapLines ); |
|
| 4608 | + public function genCSS($output) { |
|
| 4609 | + $output->add($this->value, $this->currentFileInfo, $this->index, $this->mapLines); |
|
| 4610 | 4610 | } |
| 4611 | 4611 | |
| 4612 | - public function toCSS(){ |
|
| 4612 | + public function toCSS() { |
|
| 4613 | 4613 | return $this->value; |
| 4614 | 4614 | } |
| 4615 | 4615 | |
@@ -4622,7 +4622,7 @@ discard block |
||
| 4622 | 4622 | * @package Less |
| 4623 | 4623 | * @subpackage tree |
| 4624 | 4624 | */ |
| 4625 | -class Less_Tree_Assignment extends Less_Tree{ |
|
| 4625 | +class Less_Tree_Assignment extends Less_Tree { |
|
| 4626 | 4626 | |
| 4627 | 4627 | public $key; |
| 4628 | 4628 | public $value; |
@@ -4633,24 +4633,24 @@ discard block |
||
| 4633 | 4633 | $this->value = $val; |
| 4634 | 4634 | } |
| 4635 | 4635 | |
| 4636 | - public function accept( $visitor ){ |
|
| 4637 | - $this->value = $visitor->visitObj( $this->value ); |
|
| 4636 | + public function accept($visitor) { |
|
| 4637 | + $this->value = $visitor->visitObj($this->value); |
|
| 4638 | 4638 | } |
| 4639 | 4639 | |
| 4640 | 4640 | public function compile($env) { |
| 4641 | - return new Less_Tree_Assignment( $this->key, $this->value->compile($env)); |
|
| 4641 | + return new Less_Tree_Assignment($this->key, $this->value->compile($env)); |
|
| 4642 | 4642 | } |
| 4643 | 4643 | |
| 4644 | 4644 | /** |
| 4645 | 4645 | * @see Less_Tree::genCSS |
| 4646 | 4646 | */ |
| 4647 | - public function genCSS( $output ){ |
|
| 4648 | - $output->add( $this->key . '=' ); |
|
| 4649 | - $this->value->genCSS( $output ); |
|
| 4647 | + public function genCSS($output) { |
|
| 4648 | + $output->add($this->key.'='); |
|
| 4649 | + $this->value->genCSS($output); |
|
| 4650 | 4650 | } |
| 4651 | 4651 | |
| 4652 | - public function toCss(){ |
|
| 4653 | - return $this->key . '=' . $this->value->toCSS(); |
|
| 4652 | + public function toCss() { |
|
| 4653 | + return $this->key.'='.$this->value->toCSS(); |
|
| 4654 | 4654 | } |
| 4655 | 4655 | } |
| 4656 | 4656 | |
@@ -4661,30 +4661,30 @@ discard block |
||
| 4661 | 4661 | * @package Less |
| 4662 | 4662 | * @subpackage tree |
| 4663 | 4663 | */ |
| 4664 | -class Less_Tree_Attribute extends Less_Tree{ |
|
| 4664 | +class Less_Tree_Attribute extends Less_Tree { |
|
| 4665 | 4665 | |
| 4666 | 4666 | public $key; |
| 4667 | 4667 | public $op; |
| 4668 | 4668 | public $value; |
| 4669 | 4669 | public $type = 'Attribute'; |
| 4670 | 4670 | |
| 4671 | - public function __construct($key, $op, $value){ |
|
| 4671 | + public function __construct($key, $op, $value) { |
|
| 4672 | 4672 | $this->key = $key; |
| 4673 | 4673 | $this->op = $op; |
| 4674 | 4674 | $this->value = $value; |
| 4675 | 4675 | } |
| 4676 | 4676 | |
| 4677 | - public function compile($env){ |
|
| 4677 | + public function compile($env) { |
|
| 4678 | 4678 | |
| 4679 | 4679 | $key_obj = is_object($this->key); |
| 4680 | 4680 | $val_obj = is_object($this->value); |
| 4681 | 4681 | |
| 4682 | - if( !$key_obj && !$val_obj ){ |
|
| 4682 | + if (!$key_obj && !$val_obj) { |
|
| 4683 | 4683 | return $this; |
| 4684 | 4684 | } |
| 4685 | 4685 | |
| 4686 | 4686 | return new Less_Tree_Attribute( |
| 4687 | - $key_obj ? $this->key->compile($env) : $this->key , |
|
| 4687 | + $key_obj ? $this->key->compile($env) : $this->key, |
|
| 4688 | 4688 | $this->op, |
| 4689 | 4689 | $val_obj ? $this->value->compile($env) : $this->value); |
| 4690 | 4690 | } |
@@ -4692,19 +4692,19 @@ discard block |
||
| 4692 | 4692 | /** |
| 4693 | 4693 | * @see Less_Tree::genCSS |
| 4694 | 4694 | */ |
| 4695 | - public function genCSS( $output ){ |
|
| 4696 | - $output->add( $this->toCSS() ); |
|
| 4695 | + public function genCSS($output) { |
|
| 4696 | + $output->add($this->toCSS()); |
|
| 4697 | 4697 | } |
| 4698 | 4698 | |
| 4699 | - public function toCSS(){ |
|
| 4699 | + public function toCSS() { |
|
| 4700 | 4700 | $value = $this->key; |
| 4701 | 4701 | |
| 4702 | - if( $this->op ){ |
|
| 4702 | + if ($this->op) { |
|
| 4703 | 4703 | $value .= $this->op; |
| 4704 | 4704 | $value .= (is_object($this->value) ? $this->value->toCSS() : $this->value); |
| 4705 | 4705 | } |
| 4706 | 4706 | |
| 4707 | - return '[' . $value . ']'; |
|
| 4707 | + return '['.$value.']'; |
|
| 4708 | 4708 | } |
| 4709 | 4709 | } |
| 4710 | 4710 | |
@@ -4715,7 +4715,7 @@ discard block |
||
| 4715 | 4715 | * @package Less |
| 4716 | 4716 | * @subpackage tree |
| 4717 | 4717 | */ |
| 4718 | -class Less_Tree_Call extends Less_Tree{ |
|
| 4718 | +class Less_Tree_Call extends Less_Tree { |
|
| 4719 | 4719 | public $value; |
| 4720 | 4720 | |
| 4721 | 4721 | protected $name; |
@@ -4724,15 +4724,15 @@ discard block |
||
| 4724 | 4724 | protected $currentFileInfo; |
| 4725 | 4725 | public $type = 'Call'; |
| 4726 | 4726 | |
| 4727 | - public function __construct($name, $args, $index, $currentFileInfo = null ){ |
|
| 4727 | + public function __construct($name, $args, $index, $currentFileInfo = null) { |
|
| 4728 | 4728 | $this->name = $name; |
| 4729 | 4729 | $this->args = $args; |
| 4730 | 4730 | $this->index = $index; |
| 4731 | 4731 | $this->currentFileInfo = $currentFileInfo; |
| 4732 | 4732 | } |
| 4733 | 4733 | |
| 4734 | - public function accept( $visitor ){ |
|
| 4735 | - $this->args = $visitor->visitArray( $this->args ); |
|
| 4734 | + public function accept($visitor) { |
|
| 4735 | + $this->args = $visitor->visitArray($this->args); |
|
| 4736 | 4736 | } |
| 4737 | 4737 | |
| 4738 | 4738 | // |
@@ -4747,14 +4747,14 @@ discard block |
||
| 4747 | 4747 | // we try to pass a variable to a function, like: `saturate(@color)`. |
| 4748 | 4748 | // The function should receive the value, not the variable. |
| 4749 | 4749 | // |
| 4750 | - public function compile($env=null){ |
|
| 4750 | + public function compile($env = null) { |
|
| 4751 | 4751 | $args = array(); |
| 4752 | - foreach($this->args as $a){ |
|
| 4752 | + foreach ($this->args as $a) { |
|
| 4753 | 4753 | $args[] = $a->compile($env); |
| 4754 | 4754 | } |
| 4755 | 4755 | |
| 4756 | 4756 | $nameLC = strtolower($this->name); |
| 4757 | - switch($nameLC){ |
|
| 4757 | + switch ($nameLC) { |
|
| 4758 | 4758 | case '%': |
| 4759 | 4759 | $nameLC = '_percent'; |
| 4760 | 4760 | break; |
@@ -4773,52 +4773,52 @@ discard block |
||
| 4773 | 4773 | } |
| 4774 | 4774 | |
| 4775 | 4775 | $result = null; |
| 4776 | - if( $nameLC === 'default' ){ |
|
| 4776 | + if ($nameLC==='default') { |
|
| 4777 | 4777 | $result = Less_Tree_DefaultFunc::compile(); |
| 4778 | 4778 | |
| 4779 | - }else{ |
|
| 4779 | + }else { |
|
| 4780 | 4780 | |
| 4781 | - if( method_exists('Less_Functions',$nameLC) ){ // 1. |
|
| 4781 | + if (method_exists('Less_Functions', $nameLC)) { // 1. |
|
| 4782 | 4782 | try { |
| 4783 | 4783 | |
| 4784 | 4784 | $func = new Less_Functions($env, $this->currentFileInfo); |
| 4785 | - $result = call_user_func_array( array($func,$nameLC),$args); |
|
| 4785 | + $result = call_user_func_array(array($func, $nameLC), $args); |
|
| 4786 | 4786 | |
| 4787 | 4787 | } catch (Exception $e) { |
| 4788 | - throw new Less_Exception_Compiler('error evaluating function `' . $this->name . '` '.$e->getMessage().' index: '. $this->index); |
|
| 4788 | + throw new Less_Exception_Compiler('error evaluating function `'.$this->name.'` '.$e->getMessage().' index: '.$this->index); |
|
| 4789 | 4789 | } |
| 4790 | - } elseif( isset( $env->functions[$nameLC] ) && is_callable( $env->functions[$nameLC] ) ) { |
|
| 4790 | + } elseif (isset($env->functions[$nameLC]) && is_callable($env->functions[$nameLC])) { |
|
| 4791 | 4791 | try { |
| 4792 | - $result = call_user_func_array( $env->functions[$nameLC], $args ); |
|
| 4792 | + $result = call_user_func_array($env->functions[$nameLC], $args); |
|
| 4793 | 4793 | } catch (Exception $e) { |
| 4794 | - throw new Less_Exception_Compiler('error evaluating function `' . $this->name . '` '.$e->getMessage().' index: '. $this->index); |
|
| 4794 | + throw new Less_Exception_Compiler('error evaluating function `'.$this->name.'` '.$e->getMessage().' index: '.$this->index); |
|
| 4795 | 4795 | } |
| 4796 | 4796 | } |
| 4797 | 4797 | } |
| 4798 | 4798 | |
| 4799 | - if( $result !== null ){ |
|
| 4799 | + if ($result!==null) { |
|
| 4800 | 4800 | return $result; |
| 4801 | 4801 | } |
| 4802 | 4802 | |
| 4803 | 4803 | |
| 4804 | - return new Less_Tree_Call( $this->name, $args, $this->index, $this->currentFileInfo ); |
|
| 4804 | + return new Less_Tree_Call($this->name, $args, $this->index, $this->currentFileInfo); |
|
| 4805 | 4805 | } |
| 4806 | 4806 | |
| 4807 | 4807 | /** |
| 4808 | 4808 | * @see Less_Tree::genCSS |
| 4809 | 4809 | */ |
| 4810 | - public function genCSS( $output ){ |
|
| 4810 | + public function genCSS($output) { |
|
| 4811 | 4811 | |
| 4812 | - $output->add( $this->name . '(', $this->currentFileInfo, $this->index ); |
|
| 4812 | + $output->add($this->name.'(', $this->currentFileInfo, $this->index); |
|
| 4813 | 4813 | $args_len = count($this->args); |
| 4814 | - for($i = 0; $i < $args_len; $i++ ){ |
|
| 4815 | - $this->args[$i]->genCSS( $output ); |
|
| 4816 | - if( $i + 1 < $args_len ){ |
|
| 4817 | - $output->add( ', ' ); |
|
| 4814 | + for ($i = 0; $i<$args_len; $i++) { |
|
| 4815 | + $this->args[$i]->genCSS($output); |
|
| 4816 | + if ($i+1<$args_len) { |
|
| 4817 | + $output->add(', '); |
|
| 4818 | 4818 | } |
| 4819 | 4819 | } |
| 4820 | 4820 | |
| 4821 | - $output->add( ')' ); |
|
| 4821 | + $output->add(')'); |
|
| 4822 | 4822 | } |
| 4823 | 4823 | |
| 4824 | 4824 | |
@@ -4835,15 +4835,15 @@ discard block |
||
| 4835 | 4835 | * @package Less |
| 4836 | 4836 | * @subpackage tree |
| 4837 | 4837 | */ |
| 4838 | -class Less_Tree_Color extends Less_Tree{ |
|
| 4838 | +class Less_Tree_Color extends Less_Tree { |
|
| 4839 | 4839 | public $rgb; |
| 4840 | 4840 | public $alpha; |
| 4841 | 4841 | public $isTransparentKeyword; |
| 4842 | 4842 | public $type = 'Color'; |
| 4843 | 4843 | |
| 4844 | - public function __construct($rgb, $a = 1, $isTransparentKeyword = null ){ |
|
| 4844 | + public function __construct($rgb, $a = 1, $isTransparentKeyword = null) { |
|
| 4845 | 4845 | |
| 4846 | - if( $isTransparentKeyword ){ |
|
| 4846 | + if ($isTransparentKeyword) { |
|
| 4847 | 4847 | $this->rgb = $rgb; |
| 4848 | 4848 | $this->alpha = $a; |
| 4849 | 4849 | $this->isTransparentKeyword = true; |
@@ -4851,46 +4851,46 @@ discard block |
||
| 4851 | 4851 | } |
| 4852 | 4852 | |
| 4853 | 4853 | $this->rgb = array(); |
| 4854 | - if( is_array($rgb) ){ |
|
| 4854 | + if (is_array($rgb)) { |
|
| 4855 | 4855 | $this->rgb = $rgb; |
| 4856 | - }else if( strlen($rgb) == 6 ){ |
|
| 4857 | - foreach(str_split($rgb, 2) as $c){ |
|
| 4856 | + }else if (strlen($rgb)==6) { |
|
| 4857 | + foreach (str_split($rgb, 2) as $c) { |
|
| 4858 | 4858 | $this->rgb[] = hexdec($c); |
| 4859 | 4859 | } |
| 4860 | - }else{ |
|
| 4861 | - foreach(str_split($rgb, 1) as $c){ |
|
| 4860 | + }else { |
|
| 4861 | + foreach (str_split($rgb, 1) as $c) { |
|
| 4862 | 4862 | $this->rgb[] = hexdec($c.$c); |
| 4863 | 4863 | } |
| 4864 | 4864 | } |
| 4865 | 4865 | $this->alpha = is_numeric($a) ? $a : 1; |
| 4866 | 4866 | } |
| 4867 | 4867 | |
| 4868 | - public function compile(){ |
|
| 4868 | + public function compile() { |
|
| 4869 | 4869 | return $this; |
| 4870 | 4870 | } |
| 4871 | 4871 | |
| 4872 | - public function luma(){ |
|
| 4872 | + public function luma() { |
|
| 4873 | 4873 | $r = $this->rgb[0] / 255; |
| 4874 | 4874 | $g = $this->rgb[1] / 255; |
| 4875 | 4875 | $b = $this->rgb[2] / 255; |
| 4876 | 4876 | |
| 4877 | - $r = ($r <= 0.03928) ? $r / 12.92 : pow((($r + 0.055) / 1.055), 2.4); |
|
| 4878 | - $g = ($g <= 0.03928) ? $g / 12.92 : pow((($g + 0.055) / 1.055), 2.4); |
|
| 4879 | - $b = ($b <= 0.03928) ? $b / 12.92 : pow((($b + 0.055) / 1.055), 2.4); |
|
| 4877 | + $r = ($r<=0.03928) ? $r / 12.92 : pow((($r+0.055) / 1.055), 2.4); |
|
| 4878 | + $g = ($g<=0.03928) ? $g / 12.92 : pow((($g+0.055) / 1.055), 2.4); |
|
| 4879 | + $b = ($b<=0.03928) ? $b / 12.92 : pow((($b+0.055) / 1.055), 2.4); |
|
| 4880 | 4880 | |
| 4881 | - return 0.2126 * $r + 0.7152 * $g + 0.0722 * $b; |
|
| 4881 | + return 0.2126 * $r+0.7152 * $g+0.0722 * $b; |
|
| 4882 | 4882 | } |
| 4883 | 4883 | |
| 4884 | 4884 | /** |
| 4885 | 4885 | * @see Less_Tree::genCSS |
| 4886 | 4886 | */ |
| 4887 | - public function genCSS( $output ){ |
|
| 4888 | - $output->add( $this->toCSS() ); |
|
| 4887 | + public function genCSS($output) { |
|
| 4888 | + $output->add($this->toCSS()); |
|
| 4889 | 4889 | } |
| 4890 | 4890 | |
| 4891 | - public function toCSS( $doNotCompress = false ){ |
|
| 4891 | + public function toCSS($doNotCompress = false) { |
|
| 4892 | 4892 | $compress = Less_Parser::$options['compress'] && !$doNotCompress; |
| 4893 | - $alpha = Less_Functions::fround( $this->alpha ); |
|
| 4893 | + $alpha = Less_Functions::fround($this->alpha); |
|
| 4894 | 4894 | |
| 4895 | 4895 | |
| 4896 | 4896 | // |
@@ -4899,28 +4899,28 @@ discard block |
||
| 4899 | 4899 | // which has better compatibility with older browsers. |
| 4900 | 4900 | // Values are capped between `0` and `255`, rounded and zero-padded. |
| 4901 | 4901 | // |
| 4902 | - if( $alpha < 1 ){ |
|
| 4903 | - if( ( $alpha === 0 || $alpha === 0.0 ) && isset($this->isTransparentKeyword) && $this->isTransparentKeyword ){ |
|
| 4902 | + if ($alpha<1) { |
|
| 4903 | + if (($alpha===0 || $alpha===0.0) && isset($this->isTransparentKeyword) && $this->isTransparentKeyword) { |
|
| 4904 | 4904 | return 'transparent'; |
| 4905 | 4905 | } |
| 4906 | 4906 | |
| 4907 | 4907 | $values = array(); |
| 4908 | - foreach($this->rgb as $c){ |
|
| 4909 | - $values[] = Less_Functions::clamp( round($c), 255); |
|
| 4908 | + foreach ($this->rgb as $c) { |
|
| 4909 | + $values[] = Less_Functions::clamp(round($c), 255); |
|
| 4910 | 4910 | } |
| 4911 | 4911 | $values[] = $alpha; |
| 4912 | 4912 | |
| 4913 | 4913 | $glue = ($compress ? ',' : ', '); |
| 4914 | - return "rgba(" . implode($glue, $values) . ")"; |
|
| 4915 | - }else{ |
|
| 4914 | + return "rgba(".implode($glue, $values).")"; |
|
| 4915 | + }else { |
|
| 4916 | 4916 | |
| 4917 | 4917 | $color = $this->toRGB(); |
| 4918 | 4918 | |
| 4919 | - if( $compress ){ |
|
| 4919 | + if ($compress) { |
|
| 4920 | 4920 | |
| 4921 | 4921 | // Convert color to short format |
| 4922 | - if( $color[1] === $color[2] && $color[3] === $color[4] && $color[5] === $color[6]) { |
|
| 4923 | - $color = '#'.$color[1] . $color[3] . $color[5]; |
|
| 4922 | + if ($color[1]===$color[2] && $color[3]===$color[4] && $color[5]===$color[6]) { |
|
| 4923 | + $color = '#'.$color[1].$color[3].$color[5]; |
|
| 4924 | 4924 | } |
| 4925 | 4925 | } |
| 4926 | 4926 | |
@@ -4938,20 +4938,20 @@ discard block |
||
| 4938 | 4938 | /** |
| 4939 | 4939 | * @param string $op |
| 4940 | 4940 | */ |
| 4941 | - public function operate( $op, $other) { |
|
| 4941 | + public function operate($op, $other) { |
|
| 4942 | 4942 | $rgb = array(); |
| 4943 | - $alpha = $this->alpha * (1 - $other->alpha) + $other->alpha; |
|
| 4944 | - for ($c = 0; $c < 3; $c++) { |
|
| 4945 | - $rgb[$c] = Less_Functions::operate( $op, $this->rgb[$c], $other->rgb[$c]); |
|
| 4943 | + $alpha = $this->alpha * (1-$other->alpha)+$other->alpha; |
|
| 4944 | + for ($c = 0; $c<3; $c++) { |
|
| 4945 | + $rgb[$c] = Less_Functions::operate($op, $this->rgb[$c], $other->rgb[$c]); |
|
| 4946 | 4946 | } |
| 4947 | 4947 | return new Less_Tree_Color($rgb, $alpha); |
| 4948 | 4948 | } |
| 4949 | 4949 | |
| 4950 | - public function toRGB(){ |
|
| 4950 | + public function toRGB() { |
|
| 4951 | 4951 | return $this->toHex($this->rgb); |
| 4952 | 4952 | } |
| 4953 | 4953 | |
| 4954 | - public function toHSL(){ |
|
| 4954 | + public function toHSL() { |
|
| 4955 | 4955 | $r = $this->rgb[0] / 255; |
| 4956 | 4956 | $g = $this->rgb[1] / 255; |
| 4957 | 4957 | $b = $this->rgb[2] / 255; |
@@ -4959,21 +4959,21 @@ discard block |
||
| 4959 | 4959 | |
| 4960 | 4960 | $max = max($r, $g, $b); |
| 4961 | 4961 | $min = min($r, $g, $b); |
| 4962 | - $l = ($max + $min) / 2; |
|
| 4963 | - $d = $max - $min; |
|
| 4962 | + $l = ($max+$min) / 2; |
|
| 4963 | + $d = $max-$min; |
|
| 4964 | 4964 | |
| 4965 | 4965 | $h = $s = 0; |
| 4966 | - if( $max !== $min ){ |
|
| 4967 | - $s = $l > 0.5 ? $d / (2 - $max - $min) : $d / ($max + $min); |
|
| 4966 | + if ($max!==$min) { |
|
| 4967 | + $s = $l>0.5 ? $d / (2-$max-$min) : $d / ($max+$min); |
|
| 4968 | 4968 | |
| 4969 | 4969 | switch ($max) { |
| 4970 | - case $r: $h = ($g - $b) / $d + ($g < $b ? 6 : 0); break; |
|
| 4971 | - case $g: $h = ($b - $r) / $d + 2; break; |
|
| 4972 | - case $b: $h = ($r - $g) / $d + 4; break; |
|
| 4970 | + case $r: $h = ($g-$b) / $d+($g<$b ? 6 : 0); break; |
|
| 4971 | + case $g: $h = ($b-$r) / $d+2; break; |
|
| 4972 | + case $b: $h = ($r-$g) / $d+4; break; |
|
| 4973 | 4973 | } |
| 4974 | 4974 | $h /= 6; |
| 4975 | 4975 | } |
| 4976 | - return array('h' => $h * 360, 's' => $s, 'l' => $l, 'a' => $a ); |
|
| 4976 | + return array('h' => $h * 360, 's' => $s, 'l' => $l, 'a' => $a); |
|
| 4977 | 4977 | } |
| 4978 | 4978 | |
| 4979 | 4979 | //Adapted from http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript |
@@ -4988,49 +4988,49 @@ discard block |
||
| 4988 | 4988 | |
| 4989 | 4989 | $v = $max; |
| 4990 | 4990 | |
| 4991 | - $d = $max - $min; |
|
| 4992 | - if ($max === 0) { |
|
| 4991 | + $d = $max-$min; |
|
| 4992 | + if ($max===0) { |
|
| 4993 | 4993 | $s = 0; |
| 4994 | - } else { |
|
| 4994 | + }else { |
|
| 4995 | 4995 | $s = $d / $max; |
| 4996 | 4996 | } |
| 4997 | 4997 | |
| 4998 | 4998 | $h = 0; |
| 4999 | - if( $max !== $min ){ |
|
| 5000 | - switch($max){ |
|
| 5001 | - case $r: $h = ($g - $b) / $d + ($g < $b ? 6 : 0); break; |
|
| 5002 | - case $g: $h = ($b - $r) / $d + 2; break; |
|
| 5003 | - case $b: $h = ($r - $g) / $d + 4; break; |
|
| 4999 | + if ($max!==$min) { |
|
| 5000 | + switch ($max) { |
|
| 5001 | + case $r: $h = ($g-$b) / $d+($g<$b ? 6 : 0); break; |
|
| 5002 | + case $g: $h = ($b-$r) / $d+2; break; |
|
| 5003 | + case $b: $h = ($r-$g) / $d+4; break; |
|
| 5004 | 5004 | } |
| 5005 | 5005 | $h /= 6; |
| 5006 | 5006 | } |
| 5007 | - return array('h'=> $h * 360, 's'=> $s, 'v'=> $v, 'a' => $a ); |
|
| 5007 | + return array('h'=> $h * 360, 's'=> $s, 'v'=> $v, 'a' => $a); |
|
| 5008 | 5008 | } |
| 5009 | 5009 | |
| 5010 | - public function toARGB(){ |
|
| 5011 | - $argb = array_merge( (array) Less_Parser::round($this->alpha * 255), $this->rgb); |
|
| 5012 | - return $this->toHex( $argb ); |
|
| 5010 | + public function toARGB() { |
|
| 5011 | + $argb = array_merge((array)Less_Parser::round($this->alpha * 255), $this->rgb); |
|
| 5012 | + return $this->toHex($argb); |
|
| 5013 | 5013 | } |
| 5014 | 5014 | |
| 5015 | - public function compare($x){ |
|
| 5015 | + public function compare($x) { |
|
| 5016 | 5016 | |
| 5017 | - if( !property_exists( $x, 'rgb' ) ){ |
|
| 5017 | + if (!property_exists($x, 'rgb')) { |
|
| 5018 | 5018 | return -1; |
| 5019 | 5019 | } |
| 5020 | 5020 | |
| 5021 | 5021 | |
| 5022 | - return ($x->rgb[0] === $this->rgb[0] && |
|
| 5023 | - $x->rgb[1] === $this->rgb[1] && |
|
| 5024 | - $x->rgb[2] === $this->rgb[2] && |
|
| 5025 | - $x->alpha === $this->alpha) ? 0 : -1; |
|
| 5022 | + return ($x->rgb[0]===$this->rgb[0] && |
|
| 5023 | + $x->rgb[1]===$this->rgb[1] && |
|
| 5024 | + $x->rgb[2]===$this->rgb[2] && |
|
| 5025 | + $x->alpha===$this->alpha) ? 0 : -1; |
|
| 5026 | 5026 | } |
| 5027 | 5027 | |
| 5028 | - public function toHex( $v ){ |
|
| 5028 | + public function toHex($v) { |
|
| 5029 | 5029 | |
| 5030 | 5030 | $ret = '#'; |
| 5031 | - foreach($v as $c){ |
|
| 5032 | - $c = Less_Functions::clamp( Less_Parser::round($c), 255); |
|
| 5033 | - if( $c < 16 ){ |
|
| 5031 | + foreach ($v as $c) { |
|
| 5032 | + $c = Less_Functions::clamp(Less_Parser::round($c), 255); |
|
| 5033 | + if ($c<16) { |
|
| 5034 | 5034 | $ret .= '0'; |
| 5035 | 5035 | } |
| 5036 | 5036 | $ret .= dechex($c); |
@@ -5043,16 +5043,16 @@ discard block |
||
| 5043 | 5043 | /** |
| 5044 | 5044 | * @param string $keyword |
| 5045 | 5045 | */ |
| 5046 | - public static function fromKeyword( $keyword ){ |
|
| 5046 | + public static function fromKeyword($keyword) { |
|
| 5047 | 5047 | $keyword = strtolower($keyword); |
| 5048 | 5048 | |
| 5049 | - if( Less_Colors::hasOwnProperty($keyword) ){ |
|
| 5049 | + if (Less_Colors::hasOwnProperty($keyword)) { |
|
| 5050 | 5050 | // detect named color |
| 5051 | 5051 | return new Less_Tree_Color(substr(Less_Colors::color($keyword), 1)); |
| 5052 | 5052 | } |
| 5053 | 5053 | |
| 5054 | - if( $keyword === 'transparent' ){ |
|
| 5055 | - return new Less_Tree_Color( array(0, 0, 0), 0, true); |
|
| 5054 | + if ($keyword==='transparent') { |
|
| 5055 | + return new Less_Tree_Color(array(0, 0, 0), 0, true); |
|
| 5056 | 5056 | } |
| 5057 | 5057 | } |
| 5058 | 5058 | |
@@ -5065,7 +5065,7 @@ discard block |
||
| 5065 | 5065 | * @package Less |
| 5066 | 5066 | * @subpackage tree |
| 5067 | 5067 | */ |
| 5068 | -class Less_Tree_Comment extends Less_Tree{ |
|
| 5068 | +class Less_Tree_Comment extends Less_Tree { |
|
| 5069 | 5069 | |
| 5070 | 5070 | public $value; |
| 5071 | 5071 | public $silent; |
@@ -5073,37 +5073,37 @@ discard block |
||
| 5073 | 5073 | public $currentFileInfo; |
| 5074 | 5074 | public $type = 'Comment'; |
| 5075 | 5075 | |
| 5076 | - public function __construct($value, $silent, $index = null, $currentFileInfo = null ){ |
|
| 5076 | + public function __construct($value, $silent, $index = null, $currentFileInfo = null) { |
|
| 5077 | 5077 | $this->value = $value; |
| 5078 | - $this->silent = !! $silent; |
|
| 5078 | + $this->silent = !!$silent; |
|
| 5079 | 5079 | $this->currentFileInfo = $currentFileInfo; |
| 5080 | 5080 | } |
| 5081 | 5081 | |
| 5082 | 5082 | /** |
| 5083 | 5083 | * @see Less_Tree::genCSS |
| 5084 | 5084 | */ |
| 5085 | - public function genCSS( $output ){ |
|
| 5085 | + public function genCSS($output) { |
|
| 5086 | 5086 | //if( $this->debugInfo ){ |
| 5087 | 5087 | //$output->add( tree.debugInfo($env, $this), $this->currentFileInfo, $this->index); |
| 5088 | 5088 | //} |
| 5089 | - $output->add( trim($this->value) );//TODO shouldn't need to trim, we shouldn't grab the \n |
|
| 5089 | + $output->add(trim($this->value)); //TODO shouldn't need to trim, we shouldn't grab the \n |
|
| 5090 | 5090 | } |
| 5091 | 5091 | |
| 5092 | - public function toCSS(){ |
|
| 5092 | + public function toCSS() { |
|
| 5093 | 5093 | return Less_Parser::$options['compress'] ? '' : $this->value; |
| 5094 | 5094 | } |
| 5095 | 5095 | |
| 5096 | - public function isSilent(){ |
|
| 5097 | - $isReference = ($this->currentFileInfo && isset($this->currentFileInfo['reference']) && (!isset($this->isReferenced) || !$this->isReferenced) ); |
|
| 5096 | + public function isSilent() { |
|
| 5097 | + $isReference = ($this->currentFileInfo && isset($this->currentFileInfo['reference']) && (!isset($this->isReferenced) || !$this->isReferenced)); |
|
| 5098 | 5098 | $isCompressed = Less_Parser::$options['compress'] && !preg_match('/^\/\*!/', $this->value); |
| 5099 | 5099 | return $this->silent || $isReference || $isCompressed; |
| 5100 | 5100 | } |
| 5101 | 5101 | |
| 5102 | - public function compile(){ |
|
| 5102 | + public function compile() { |
|
| 5103 | 5103 | return $this; |
| 5104 | 5104 | } |
| 5105 | 5105 | |
| 5106 | - public function markReferenced(){ |
|
| 5106 | + public function markReferenced() { |
|
| 5107 | 5107 | $this->isReferenced = true; |
| 5108 | 5108 | } |
| 5109 | 5109 | |
@@ -5116,7 +5116,7 @@ discard block |
||
| 5116 | 5116 | * @package Less |
| 5117 | 5117 | * @subpackage tree |
| 5118 | 5118 | */ |
| 5119 | -class Less_Tree_Condition extends Less_Tree{ |
|
| 5119 | +class Less_Tree_Condition extends Less_Tree { |
|
| 5120 | 5120 | |
| 5121 | 5121 | public $op; |
| 5122 | 5122 | public $lvalue; |
@@ -5133,16 +5133,16 @@ discard block |
||
| 5133 | 5133 | $this->negate = $negate; |
| 5134 | 5134 | } |
| 5135 | 5135 | |
| 5136 | - public function accept($visitor){ |
|
| 5137 | - $this->lvalue = $visitor->visitObj( $this->lvalue ); |
|
| 5138 | - $this->rvalue = $visitor->visitObj( $this->rvalue ); |
|
| 5136 | + public function accept($visitor) { |
|
| 5137 | + $this->lvalue = $visitor->visitObj($this->lvalue); |
|
| 5138 | + $this->rvalue = $visitor->visitObj($this->rvalue); |
|
| 5139 | 5139 | } |
| 5140 | 5140 | |
| 5141 | 5141 | public function compile($env) { |
| 5142 | 5142 | $a = $this->lvalue->compile($env); |
| 5143 | 5143 | $b = $this->rvalue->compile($env); |
| 5144 | 5144 | |
| 5145 | - switch( $this->op ){ |
|
| 5145 | + switch ($this->op) { |
|
| 5146 | 5146 | case 'and': |
| 5147 | 5147 | $result = $a && $b; |
| 5148 | 5148 | break; |
@@ -5152,25 +5152,25 @@ discard block |
||
| 5152 | 5152 | break; |
| 5153 | 5153 | |
| 5154 | 5154 | default: |
| 5155 | - if( Less_Parser::is_method($a, 'compare') ){ |
|
| 5155 | + if (Less_Parser::is_method($a, 'compare')) { |
|
| 5156 | 5156 | $result = $a->compare($b); |
| 5157 | - }elseif( Less_Parser::is_method($b, 'compare') ){ |
|
| 5157 | + }elseif (Less_Parser::is_method($b, 'compare')) { |
|
| 5158 | 5158 | $result = $b->compare($a); |
| 5159 | - }else{ |
|
| 5159 | + }else { |
|
| 5160 | 5160 | throw new Less_Exception_Compiler('Unable to perform comparison', null, $this->index); |
| 5161 | 5161 | } |
| 5162 | 5162 | |
| 5163 | 5163 | switch ($result) { |
| 5164 | 5164 | case -1: |
| 5165 | - $result = $this->op === '<' || $this->op === '=<' || $this->op === '<='; |
|
| 5165 | + $result = $this->op==='<' || $this->op==='=<' || $this->op==='<='; |
|
| 5166 | 5166 | break; |
| 5167 | 5167 | |
| 5168 | 5168 | case 0: |
| 5169 | - $result = $this->op === '=' || $this->op === '>=' || $this->op === '=<' || $this->op === '<='; |
|
| 5169 | + $result = $this->op==='=' || $this->op==='>=' || $this->op==='=<' || $this->op==='<='; |
|
| 5170 | 5170 | break; |
| 5171 | 5171 | |
| 5172 | 5172 | case 1: |
| 5173 | - $result = $this->op === '>' || $this->op === '>='; |
|
| 5173 | + $result = $this->op==='>' || $this->op==='>='; |
|
| 5174 | 5174 | break; |
| 5175 | 5175 | } |
| 5176 | 5176 | break; |
@@ -5188,29 +5188,29 @@ discard block |
||
| 5188 | 5188 | * @package Less |
| 5189 | 5189 | * @subpackage tree |
| 5190 | 5190 | */ |
| 5191 | -class Less_Tree_DefaultFunc{ |
|
| 5191 | +class Less_Tree_DefaultFunc { |
|
| 5192 | 5192 | |
| 5193 | 5193 | static $error_; |
| 5194 | 5194 | static $value_; |
| 5195 | 5195 | |
| 5196 | - public static function compile(){ |
|
| 5197 | - if( self::$error_ ){ |
|
| 5196 | + public static function compile() { |
|
| 5197 | + if (self::$error_) { |
|
| 5198 | 5198 | throw new Exception(self::$error_); |
| 5199 | 5199 | } |
| 5200 | - if( self::$value_ !== null ){ |
|
| 5200 | + if (self::$value_!==null) { |
|
| 5201 | 5201 | return self::$value_ ? new Less_Tree_Keyword('true') : new Less_Tree_Keyword('false'); |
| 5202 | 5202 | } |
| 5203 | 5203 | } |
| 5204 | 5204 | |
| 5205 | - public static function value( $v ){ |
|
| 5205 | + public static function value($v) { |
|
| 5206 | 5206 | self::$value_ = $v; |
| 5207 | 5207 | } |
| 5208 | 5208 | |
| 5209 | - public static function error( $e ){ |
|
| 5209 | + public static function error($e) { |
|
| 5210 | 5210 | self::$error_ = $e; |
| 5211 | 5211 | } |
| 5212 | 5212 | |
| 5213 | - public static function reset(){ |
|
| 5213 | + public static function reset() { |
|
| 5214 | 5214 | self::$value_ = self::$error_ = null; |
| 5215 | 5215 | } |
| 5216 | 5216 | } |
@@ -5221,13 +5221,13 @@ discard block |
||
| 5221 | 5221 | * @package Less |
| 5222 | 5222 | * @subpackage tree |
| 5223 | 5223 | */ |
| 5224 | -class Less_Tree_DetachedRuleset extends Less_Tree{ |
|
| 5224 | +class Less_Tree_DetachedRuleset extends Less_Tree { |
|
| 5225 | 5225 | |
| 5226 | 5226 | public $ruleset; |
| 5227 | 5227 | public $frames; |
| 5228 | 5228 | public $type = 'DetachedRuleset'; |
| 5229 | 5229 | |
| 5230 | - public function __construct( $ruleset, $frames = null ){ |
|
| 5230 | + public function __construct($ruleset, $frames = null) { |
|
| 5231 | 5231 | $this->ruleset = $ruleset; |
| 5232 | 5232 | $this->frames = $frames; |
| 5233 | 5233 | } |
@@ -5236,20 +5236,20 @@ discard block |
||
| 5236 | 5236 | $this->ruleset = $visitor->visitObj($this->ruleset); |
| 5237 | 5237 | } |
| 5238 | 5238 | |
| 5239 | - public function compile($env){ |
|
| 5240 | - if( $this->frames ){ |
|
| 5239 | + public function compile($env) { |
|
| 5240 | + if ($this->frames) { |
|
| 5241 | 5241 | $frames = $this->frames; |
| 5242 | - }else{ |
|
| 5242 | + }else { |
|
| 5243 | 5243 | $frames = $env->frames; |
| 5244 | 5244 | } |
| 5245 | 5245 | return new Less_Tree_DetachedRuleset($this->ruleset, $frames); |
| 5246 | 5246 | } |
| 5247 | 5247 | |
| 5248 | 5248 | public function callEval($env) { |
| 5249 | - if( $this->frames ){ |
|
| 5250 | - return $this->ruleset->compile( $env->copyEvalEnv( array_merge($this->frames,$env->frames) ) ); |
|
| 5249 | + if ($this->frames) { |
|
| 5250 | + return $this->ruleset->compile($env->copyEvalEnv(array_merge($this->frames, $env->frames))); |
|
| 5251 | 5251 | } |
| 5252 | - return $this->ruleset->compile( $env ); |
|
| 5252 | + return $this->ruleset->compile($env); |
|
| 5253 | 5253 | } |
| 5254 | 5254 | } |
| 5255 | 5255 | |
@@ -5261,29 +5261,29 @@ discard block |
||
| 5261 | 5261 | * @package Less |
| 5262 | 5262 | * @subpackage tree |
| 5263 | 5263 | */ |
| 5264 | -class Less_Tree_Dimension extends Less_Tree{ |
|
| 5264 | +class Less_Tree_Dimension extends Less_Tree { |
|
| 5265 | 5265 | |
| 5266 | 5266 | public $value; |
| 5267 | 5267 | public $unit; |
| 5268 | 5268 | public $type = 'Dimension'; |
| 5269 | 5269 | |
| 5270 | - public function __construct($value, $unit = null){ |
|
| 5270 | + public function __construct($value, $unit = null) { |
|
| 5271 | 5271 | $this->value = floatval($value); |
| 5272 | 5272 | |
| 5273 | - if( $unit && ($unit instanceof Less_Tree_Unit) ){ |
|
| 5273 | + if ($unit && ($unit instanceof Less_Tree_Unit)) { |
|
| 5274 | 5274 | $this->unit = $unit; |
| 5275 | - }elseif( $unit ){ |
|
| 5276 | - $this->unit = new Less_Tree_Unit( array($unit) ); |
|
| 5277 | - }else{ |
|
| 5275 | + }elseif ($unit) { |
|
| 5276 | + $this->unit = new Less_Tree_Unit(array($unit)); |
|
| 5277 | + }else { |
|
| 5278 | 5278 | $this->unit = new Less_Tree_Unit( ); |
| 5279 | 5279 | } |
| 5280 | 5280 | } |
| 5281 | 5281 | |
| 5282 | - public function accept( $visitor ){ |
|
| 5283 | - $this->unit = $visitor->visitObj( $this->unit ); |
|
| 5282 | + public function accept($visitor) { |
|
| 5283 | + $this->unit = $visitor->visitObj($this->unit); |
|
| 5284 | 5284 | } |
| 5285 | 5285 | |
| 5286 | - public function compile(){ |
|
| 5286 | + public function compile() { |
|
| 5287 | 5287 | return $this; |
| 5288 | 5288 | } |
| 5289 | 5289 | |
@@ -5294,39 +5294,39 @@ discard block |
||
| 5294 | 5294 | /** |
| 5295 | 5295 | * @see Less_Tree::genCSS |
| 5296 | 5296 | */ |
| 5297 | - public function genCSS( $output ){ |
|
| 5297 | + public function genCSS($output) { |
|
| 5298 | 5298 | |
| 5299 | - if( Less_Parser::$options['strictUnits'] && !$this->unit->isSingular() ){ |
|
| 5299 | + if (Less_Parser::$options['strictUnits'] && !$this->unit->isSingular()) { |
|
| 5300 | 5300 | throw new Less_Exception_Compiler("Multiple units in dimension. Correct the units or use the unit function. Bad unit: ".$this->unit->toString()); |
| 5301 | 5301 | } |
| 5302 | 5302 | |
| 5303 | - $value = Less_Functions::fround( $this->value ); |
|
| 5303 | + $value = Less_Functions::fround($this->value); |
|
| 5304 | 5304 | $strValue = (string)$value; |
| 5305 | 5305 | |
| 5306 | - if( $value !== 0 && $value < 0.000001 && $value > -0.000001 ){ |
|
| 5306 | + if ($value!==0 && $value<0.000001 && $value>-0.000001) { |
|
| 5307 | 5307 | // would be output 1e-6 etc. |
| 5308 | - $strValue = number_format($strValue,10); |
|
| 5309 | - $strValue = preg_replace('/\.?0+$/','', $strValue); |
|
| 5308 | + $strValue = number_format($strValue, 10); |
|
| 5309 | + $strValue = preg_replace('/\.?0+$/', '', $strValue); |
|
| 5310 | 5310 | } |
| 5311 | 5311 | |
| 5312 | - if( Less_Parser::$options['compress'] ){ |
|
| 5312 | + if (Less_Parser::$options['compress']) { |
|
| 5313 | 5313 | // Zero values doesn't need a unit |
| 5314 | - if( $value === 0 && $this->unit->isLength() ){ |
|
| 5315 | - $output->add( $strValue ); |
|
| 5314 | + if ($value===0 && $this->unit->isLength()) { |
|
| 5315 | + $output->add($strValue); |
|
| 5316 | 5316 | return $strValue; |
| 5317 | 5317 | } |
| 5318 | 5318 | |
| 5319 | 5319 | // Float values doesn't need a leading zero |
| 5320 | - if( $value > 0 && $value < 1 && $strValue[0] === '0' ){ |
|
| 5321 | - $strValue = substr($strValue,1); |
|
| 5320 | + if ($value>0 && $value<1 && $strValue[0]==='0') { |
|
| 5321 | + $strValue = substr($strValue, 1); |
|
| 5322 | 5322 | } |
| 5323 | 5323 | } |
| 5324 | 5324 | |
| 5325 | - $output->add( $strValue ); |
|
| 5326 | - $this->unit->genCSS( $output ); |
|
| 5325 | + $output->add($strValue); |
|
| 5326 | + $this->unit->genCSS($output); |
|
| 5327 | 5327 | } |
| 5328 | 5328 | |
| 5329 | - public function __toString(){ |
|
| 5329 | + public function __toString() { |
|
| 5330 | 5330 | return $this->toCSS(); |
| 5331 | 5331 | } |
| 5332 | 5332 | |
@@ -5337,97 +5337,97 @@ discard block |
||
| 5337 | 5337 | /** |
| 5338 | 5338 | * @param string $op |
| 5339 | 5339 | */ |
| 5340 | - public function operate( $op, $other){ |
|
| 5340 | + public function operate($op, $other) { |
|
| 5341 | 5341 | |
| 5342 | - $value = Less_Functions::operate( $op, $this->value, $other->value); |
|
| 5342 | + $value = Less_Functions::operate($op, $this->value, $other->value); |
|
| 5343 | 5343 | $unit = clone $this->unit; |
| 5344 | 5344 | |
| 5345 | - if( $op === '+' || $op === '-' ){ |
|
| 5345 | + if ($op==='+' || $op==='-') { |
|
| 5346 | 5346 | |
| 5347 | - if( !$unit->numerator && !$unit->denominator ){ |
|
| 5347 | + if (!$unit->numerator && !$unit->denominator) { |
|
| 5348 | 5348 | $unit->numerator = $other->unit->numerator; |
| 5349 | 5349 | $unit->denominator = $other->unit->denominator; |
| 5350 | - }elseif( !$other->unit->numerator && !$other->unit->denominator ){ |
|
| 5350 | + }elseif (!$other->unit->numerator && !$other->unit->denominator) { |
|
| 5351 | 5351 | // do nothing |
| 5352 | - }else{ |
|
| 5353 | - $other = $other->convertTo( $this->unit->usedUnits()); |
|
| 5352 | + }else { |
|
| 5353 | + $other = $other->convertTo($this->unit->usedUnits()); |
|
| 5354 | 5354 | |
| 5355 | - if( Less_Parser::$options['strictUnits'] && $other->unit->toString() !== $unit->toCSS() ){ |
|
| 5356 | - throw new Less_Exception_Compiler("Incompatible units. Change the units or use the unit function. Bad units: '".$unit->toString() . "' and ".$other->unit->toString()+"'."); |
|
| 5355 | + if (Less_Parser::$options['strictUnits'] && $other->unit->toString()!==$unit->toCSS()) { |
|
| 5356 | + throw new Less_Exception_Compiler("Incompatible units. Change the units or use the unit function. Bad units: '".$unit->toString()."' and ".$other->unit->toString()+"'."); |
|
| 5357 | 5357 | } |
| 5358 | 5358 | |
| 5359 | - $value = Less_Functions::operate( $op, $this->value, $other->value); |
|
| 5359 | + $value = Less_Functions::operate($op, $this->value, $other->value); |
|
| 5360 | 5360 | } |
| 5361 | - }elseif( $op === '*' ){ |
|
| 5361 | + }elseif ($op==='*') { |
|
| 5362 | 5362 | $unit->numerator = array_merge($unit->numerator, $other->unit->numerator); |
| 5363 | 5363 | $unit->denominator = array_merge($unit->denominator, $other->unit->denominator); |
| 5364 | 5364 | sort($unit->numerator); |
| 5365 | 5365 | sort($unit->denominator); |
| 5366 | 5366 | $unit->cancel(); |
| 5367 | - }elseif( $op === '/' ){ |
|
| 5367 | + }elseif ($op==='/') { |
|
| 5368 | 5368 | $unit->numerator = array_merge($unit->numerator, $other->unit->denominator); |
| 5369 | 5369 | $unit->denominator = array_merge($unit->denominator, $other->unit->numerator); |
| 5370 | 5370 | sort($unit->numerator); |
| 5371 | 5371 | sort($unit->denominator); |
| 5372 | 5372 | $unit->cancel(); |
| 5373 | 5373 | } |
| 5374 | - return new Less_Tree_Dimension( $value, $unit); |
|
| 5374 | + return new Less_Tree_Dimension($value, $unit); |
|
| 5375 | 5375 | } |
| 5376 | 5376 | |
| 5377 | 5377 | public function compare($other) { |
| 5378 | 5378 | if ($other instanceof Less_Tree_Dimension) { |
| 5379 | 5379 | |
| 5380 | - if( $this->unit->isEmpty() || $other->unit->isEmpty() ){ |
|
| 5380 | + if ($this->unit->isEmpty() || $other->unit->isEmpty()) { |
|
| 5381 | 5381 | $a = $this; |
| 5382 | 5382 | $b = $other; |
| 5383 | - } else { |
|
| 5383 | + }else { |
|
| 5384 | 5384 | $a = $this->unify(); |
| 5385 | 5385 | $b = $other->unify(); |
| 5386 | - if( $a->unit->compare($b->unit) !== 0 ){ |
|
| 5386 | + if ($a->unit->compare($b->unit)!==0) { |
|
| 5387 | 5387 | return -1; |
| 5388 | 5388 | } |
| 5389 | 5389 | } |
| 5390 | 5390 | $aValue = $a->value; |
| 5391 | 5391 | $bValue = $b->value; |
| 5392 | 5392 | |
| 5393 | - if ($bValue > $aValue) { |
|
| 5393 | + if ($bValue>$aValue) { |
|
| 5394 | 5394 | return -1; |
| 5395 | - } elseif ($bValue < $aValue) { |
|
| 5395 | + } elseif ($bValue<$aValue) { |
|
| 5396 | 5396 | return 1; |
| 5397 | - } else { |
|
| 5397 | + }else { |
|
| 5398 | 5398 | return 0; |
| 5399 | 5399 | } |
| 5400 | - } else { |
|
| 5400 | + }else { |
|
| 5401 | 5401 | return -1; |
| 5402 | 5402 | } |
| 5403 | 5403 | } |
| 5404 | 5404 | |
| 5405 | 5405 | public function unify() { |
| 5406 | - return $this->convertTo(array('length'=> 'px', 'duration'=> 's', 'angle' => 'rad' )); |
|
| 5406 | + return $this->convertTo(array('length'=> 'px', 'duration'=> 's', 'angle' => 'rad')); |
|
| 5407 | 5407 | } |
| 5408 | 5408 | |
| 5409 | 5409 | public function convertTo($conversions) { |
| 5410 | 5410 | $value = $this->value; |
| 5411 | 5411 | $unit = clone $this->unit; |
| 5412 | 5412 | |
| 5413 | - if( is_string($conversions) ){ |
|
| 5413 | + if (is_string($conversions)) { |
|
| 5414 | 5414 | $derivedConversions = array(); |
| 5415 | - foreach( Less_Tree_UnitConversions::$groups as $i ){ |
|
| 5416 | - if( isset(Less_Tree_UnitConversions::${$i}[$conversions]) ){ |
|
| 5417 | - $derivedConversions = array( $i => $conversions); |
|
| 5415 | + foreach (Less_Tree_UnitConversions::$groups as $i) { |
|
| 5416 | + if (isset(Less_Tree_UnitConversions::${$i}[$conversions])) { |
|
| 5417 | + $derivedConversions = array($i => $conversions); |
|
| 5418 | 5418 | } |
| 5419 | 5419 | } |
| 5420 | 5420 | $conversions = $derivedConversions; |
| 5421 | 5421 | } |
| 5422 | 5422 | |
| 5423 | 5423 | |
| 5424 | - foreach($conversions as $groupName => $targetUnit){ |
|
| 5424 | + foreach ($conversions as $groupName => $targetUnit) { |
|
| 5425 | 5425 | $group = Less_Tree_UnitConversions::${$groupName}; |
| 5426 | 5426 | |
| 5427 | 5427 | //numerator |
| 5428 | - foreach($unit->numerator as $i => $atomicUnit){ |
|
| 5428 | + foreach ($unit->numerator as $i => $atomicUnit) { |
|
| 5429 | 5429 | $atomicUnit = $unit->numerator[$i]; |
| 5430 | - if( !isset($group[$atomicUnit]) ){ |
|
| 5430 | + if (!isset($group[$atomicUnit])) { |
|
| 5431 | 5431 | continue; |
| 5432 | 5432 | } |
| 5433 | 5433 | |
@@ -5437,9 +5437,9 @@ discard block |
||
| 5437 | 5437 | } |
| 5438 | 5438 | |
| 5439 | 5439 | //denominator |
| 5440 | - foreach($unit->denominator as $i => $atomicUnit){ |
|
| 5440 | + foreach ($unit->denominator as $i => $atomicUnit) { |
|
| 5441 | 5441 | $atomicUnit = $unit->denominator[$i]; |
| 5442 | - if( !isset($group[$atomicUnit]) ){ |
|
| 5442 | + if (!isset($group[$atomicUnit])) { |
|
| 5443 | 5443 | continue; |
| 5444 | 5444 | } |
| 5445 | 5445 | |
@@ -5451,7 +5451,7 @@ discard block |
||
| 5451 | 5451 | |
| 5452 | 5452 | $unit->cancel(); |
| 5453 | 5453 | |
| 5454 | - return new Less_Tree_Dimension( $value, $unit); |
|
| 5454 | + return new Less_Tree_Dimension($value, $unit); |
|
| 5455 | 5455 | } |
| 5456 | 5456 | } |
| 5457 | 5457 | |
@@ -5462,7 +5462,7 @@ discard block |
||
| 5462 | 5462 | * @package Less |
| 5463 | 5463 | * @subpackage tree |
| 5464 | 5464 | */ |
| 5465 | -class Less_Tree_Directive extends Less_Tree{ |
|
| 5465 | +class Less_Tree_Directive extends Less_Tree { |
|
| 5466 | 5466 | |
| 5467 | 5467 | public $name; |
| 5468 | 5468 | public $value; |
@@ -5473,10 +5473,10 @@ discard block |
||
| 5473 | 5473 | public $debugInfo; |
| 5474 | 5474 | public $type = 'Directive'; |
| 5475 | 5475 | |
| 5476 | - public function __construct($name, $value = null, $rules, $index = null, $currentFileInfo = null, $debugInfo = null ){ |
|
| 5476 | + public function __construct($name, $value = null, $rules, $index = null, $currentFileInfo = null, $debugInfo = null) { |
|
| 5477 | 5477 | $this->name = $name; |
| 5478 | 5478 | $this->value = $value; |
| 5479 | - if( $rules ){ |
|
| 5479 | + if ($rules) { |
|
| 5480 | 5480 | $this->rules = $rules; |
| 5481 | 5481 | $this->rules->allowImports = true; |
| 5482 | 5482 | } |
@@ -5487,12 +5487,12 @@ discard block |
||
| 5487 | 5487 | } |
| 5488 | 5488 | |
| 5489 | 5489 | |
| 5490 | - public function accept( $visitor ){ |
|
| 5491 | - if( $this->rules ){ |
|
| 5492 | - $this->rules = $visitor->visitObj( $this->rules ); |
|
| 5490 | + public function accept($visitor) { |
|
| 5491 | + if ($this->rules) { |
|
| 5492 | + $this->rules = $visitor->visitObj($this->rules); |
|
| 5493 | 5493 | } |
| 5494 | - if( $this->value ){ |
|
| 5495 | - $this->value = $visitor->visitObj( $this->value ); |
|
| 5494 | + if ($this->value) { |
|
| 5495 | + $this->value = $visitor->visitObj($this->value); |
|
| 5496 | 5496 | } |
| 5497 | 5497 | } |
| 5498 | 5498 | |
@@ -5500,55 +5500,55 @@ discard block |
||
| 5500 | 5500 | /** |
| 5501 | 5501 | * @see Less_Tree::genCSS |
| 5502 | 5502 | */ |
| 5503 | - public function genCSS( $output ){ |
|
| 5503 | + public function genCSS($output) { |
|
| 5504 | 5504 | $value = $this->value; |
| 5505 | 5505 | $rules = $this->rules; |
| 5506 | - $output->add( $this->name, $this->currentFileInfo, $this->index ); |
|
| 5507 | - if( $this->value ){ |
|
| 5506 | + $output->add($this->name, $this->currentFileInfo, $this->index); |
|
| 5507 | + if ($this->value) { |
|
| 5508 | 5508 | $output->add(' '); |
| 5509 | 5509 | $this->value->genCSS($output); |
| 5510 | 5510 | } |
| 5511 | - if( $this->rules ){ |
|
| 5512 | - Less_Tree::outputRuleset( $output, array($this->rules)); |
|
| 5513 | - } else { |
|
| 5511 | + if ($this->rules) { |
|
| 5512 | + Less_Tree::outputRuleset($output, array($this->rules)); |
|
| 5513 | + }else { |
|
| 5514 | 5514 | $output->add(';'); |
| 5515 | 5515 | } |
| 5516 | 5516 | } |
| 5517 | 5517 | |
| 5518 | - public function compile($env){ |
|
| 5518 | + public function compile($env) { |
|
| 5519 | 5519 | |
| 5520 | 5520 | $value = $this->value; |
| 5521 | 5521 | $rules = $this->rules; |
| 5522 | - if( $value ){ |
|
| 5522 | + if ($value) { |
|
| 5523 | 5523 | $value = $value->compile($env); |
| 5524 | 5524 | } |
| 5525 | 5525 | |
| 5526 | - if( $rules ){ |
|
| 5526 | + if ($rules) { |
|
| 5527 | 5527 | $rules = $rules->compile($env); |
| 5528 | 5528 | $rules->root = true; |
| 5529 | 5529 | } |
| 5530 | 5530 | |
| 5531 | - return new Less_Tree_Directive( $this->name, $value, $rules, $this->index, $this->currentFileInfo, $this->debugInfo ); |
|
| 5531 | + return new Less_Tree_Directive($this->name, $value, $rules, $this->index, $this->currentFileInfo, $this->debugInfo); |
|
| 5532 | 5532 | } |
| 5533 | 5533 | |
| 5534 | 5534 | |
| 5535 | - public function variable($name){ |
|
| 5536 | - if( $this->rules ){ |
|
| 5535 | + public function variable($name) { |
|
| 5536 | + if ($this->rules) { |
|
| 5537 | 5537 | return $this->rules->variable($name); |
| 5538 | 5538 | } |
| 5539 | 5539 | } |
| 5540 | 5540 | |
| 5541 | - public function find($selector){ |
|
| 5542 | - if( $this->rules ){ |
|
| 5541 | + public function find($selector) { |
|
| 5542 | + if ($this->rules) { |
|
| 5543 | 5543 | return $this->rules->find($selector, $this); |
| 5544 | 5544 | } |
| 5545 | 5545 | } |
| 5546 | 5546 | |
| 5547 | 5547 | //rulesets: function () { if (this.rules) return tree.Ruleset.prototype.rulesets.apply(this.rules); }, |
| 5548 | 5548 | |
| 5549 | - public function markReferenced(){ |
|
| 5549 | + public function markReferenced() { |
|
| 5550 | 5550 | $this->isReferenced = true; |
| 5551 | - if( $this->rules ){ |
|
| 5551 | + if ($this->rules) { |
|
| 5552 | 5552 | Less_Tree::ReferencedArray($this->rules->rules); |
| 5553 | 5553 | } |
| 5554 | 5554 | } |
@@ -5562,7 +5562,7 @@ discard block |
||
| 5562 | 5562 | * @package Less |
| 5563 | 5563 | * @subpackage tree |
| 5564 | 5564 | */ |
| 5565 | -class Less_Tree_Element extends Less_Tree{ |
|
| 5565 | +class Less_Tree_Element extends Less_Tree { |
|
| 5566 | 5566 | |
| 5567 | 5567 | public $combinator = ''; |
| 5568 | 5568 | public $value = ''; |
@@ -5572,12 +5572,12 @@ discard block |
||
| 5572 | 5572 | |
| 5573 | 5573 | public $value_is_object = false; |
| 5574 | 5574 | |
| 5575 | - public function __construct($combinator, $value, $index = null, $currentFileInfo = null ){ |
|
| 5575 | + public function __construct($combinator, $value, $index = null, $currentFileInfo = null) { |
|
| 5576 | 5576 | |
| 5577 | 5577 | $this->value = $value; |
| 5578 | 5578 | $this->value_is_object = is_object($value); |
| 5579 | 5579 | |
| 5580 | - if( $combinator ){ |
|
| 5580 | + if ($combinator) { |
|
| 5581 | 5581 | $this->combinator = $combinator; |
| 5582 | 5582 | } |
| 5583 | 5583 | |
@@ -5585,19 +5585,19 @@ discard block |
||
| 5585 | 5585 | $this->currentFileInfo = $currentFileInfo; |
| 5586 | 5586 | } |
| 5587 | 5587 | |
| 5588 | - public function accept( $visitor ){ |
|
| 5589 | - if( $this->value_is_object ){ //object or string |
|
| 5590 | - $this->value = $visitor->visitObj( $this->value ); |
|
| 5588 | + public function accept($visitor) { |
|
| 5589 | + if ($this->value_is_object) { //object or string |
|
| 5590 | + $this->value = $visitor->visitObj($this->value); |
|
| 5591 | 5591 | } |
| 5592 | 5592 | } |
| 5593 | 5593 | |
| 5594 | - public function compile($env){ |
|
| 5594 | + public function compile($env) { |
|
| 5595 | 5595 | |
| 5596 | - if( Less_Environment::$mixin_stack ){ |
|
| 5597 | - return new Less_Tree_Element($this->combinator, ($this->value_is_object ? $this->value->compile($env) : $this->value), $this->index, $this->currentFileInfo ); |
|
| 5596 | + if (Less_Environment::$mixin_stack) { |
|
| 5597 | + return new Less_Tree_Element($this->combinator, ($this->value_is_object ? $this->value->compile($env) : $this->value), $this->index, $this->currentFileInfo); |
|
| 5598 | 5598 | } |
| 5599 | 5599 | |
| 5600 | - if( $this->value_is_object ){ |
|
| 5600 | + if ($this->value_is_object) { |
|
| 5601 | 5601 | $this->value = $this->value->compile($env); |
| 5602 | 5602 | } |
| 5603 | 5603 | |
@@ -5607,25 +5607,25 @@ discard block |
||
| 5607 | 5607 | /** |
| 5608 | 5608 | * @see Less_Tree::genCSS |
| 5609 | 5609 | */ |
| 5610 | - public function genCSS( $output ){ |
|
| 5611 | - $output->add( $this->toCSS(), $this->currentFileInfo, $this->index ); |
|
| 5610 | + public function genCSS($output) { |
|
| 5611 | + $output->add($this->toCSS(), $this->currentFileInfo, $this->index); |
|
| 5612 | 5612 | } |
| 5613 | 5613 | |
| 5614 | - public function toCSS(){ |
|
| 5614 | + public function toCSS() { |
|
| 5615 | 5615 | |
| 5616 | - if( $this->value_is_object ){ |
|
| 5616 | + if ($this->value_is_object) { |
|
| 5617 | 5617 | $value = $this->value->toCSS(); |
| 5618 | - }else{ |
|
| 5618 | + }else { |
|
| 5619 | 5619 | $value = $this->value; |
| 5620 | 5620 | } |
| 5621 | 5621 | |
| 5622 | 5622 | |
| 5623 | - if( $value === '' && $this->combinator && $this->combinator === '&' ){ |
|
| 5623 | + if ($value==='' && $this->combinator && $this->combinator==='&') { |
|
| 5624 | 5624 | return ''; |
| 5625 | 5625 | } |
| 5626 | 5626 | |
| 5627 | 5627 | |
| 5628 | - return Less_Environment::$_outputMap[$this->combinator] . $value; |
|
| 5628 | + return Less_Environment::$_outputMap[$this->combinator].$value; |
|
| 5629 | 5629 | } |
| 5630 | 5630 | |
| 5631 | 5631 | } |
@@ -5637,61 +5637,61 @@ discard block |
||
| 5637 | 5637 | * @package Less |
| 5638 | 5638 | * @subpackage tree |
| 5639 | 5639 | */ |
| 5640 | -class Less_Tree_Expression extends Less_Tree{ |
|
| 5640 | +class Less_Tree_Expression extends Less_Tree { |
|
| 5641 | 5641 | |
| 5642 | 5642 | public $value = array(); |
| 5643 | 5643 | public $parens = false; |
| 5644 | 5644 | public $parensInOp = false; |
| 5645 | 5645 | public $type = 'Expression'; |
| 5646 | 5646 | |
| 5647 | - public function __construct( $value, $parens = null ){ |
|
| 5647 | + public function __construct($value, $parens = null) { |
|
| 5648 | 5648 | $this->value = $value; |
| 5649 | 5649 | $this->parens = $parens; |
| 5650 | 5650 | } |
| 5651 | 5651 | |
| 5652 | - public function accept( $visitor ){ |
|
| 5653 | - $this->value = $visitor->visitArray( $this->value ); |
|
| 5652 | + public function accept($visitor) { |
|
| 5653 | + $this->value = $visitor->visitArray($this->value); |
|
| 5654 | 5654 | } |
| 5655 | 5655 | |
| 5656 | 5656 | public function compile($env) { |
| 5657 | 5657 | |
| 5658 | 5658 | $doubleParen = false; |
| 5659 | 5659 | |
| 5660 | - if( $this->parens && !$this->parensInOp ){ |
|
| 5660 | + if ($this->parens && !$this->parensInOp) { |
|
| 5661 | 5661 | Less_Environment::$parensStack++; |
| 5662 | 5662 | } |
| 5663 | 5663 | |
| 5664 | 5664 | $returnValue = null; |
| 5665 | - if( $this->value ){ |
|
| 5665 | + if ($this->value) { |
|
| 5666 | 5666 | |
| 5667 | 5667 | $count = count($this->value); |
| 5668 | 5668 | |
| 5669 | - if( $count > 1 ){ |
|
| 5669 | + if ($count>1) { |
|
| 5670 | 5670 | |
| 5671 | 5671 | $ret = array(); |
| 5672 | - foreach($this->value as $e){ |
|
| 5672 | + foreach ($this->value as $e) { |
|
| 5673 | 5673 | $ret[] = $e->compile($env); |
| 5674 | 5674 | } |
| 5675 | 5675 | $returnValue = new Less_Tree_Expression($ret); |
| 5676 | 5676 | |
| 5677 | - }else{ |
|
| 5677 | + }else { |
|
| 5678 | 5678 | |
| 5679 | - if( ($this->value[0] instanceof Less_Tree_Expression) && $this->value[0]->parens && !$this->value[0]->parensInOp ){ |
|
| 5679 | + if (($this->value[0] instanceof Less_Tree_Expression) && $this->value[0]->parens && !$this->value[0]->parensInOp) { |
|
| 5680 | 5680 | $doubleParen = true; |
| 5681 | 5681 | } |
| 5682 | 5682 | |
| 5683 | 5683 | $returnValue = $this->value[0]->compile($env); |
| 5684 | 5684 | } |
| 5685 | 5685 | |
| 5686 | - } else { |
|
| 5686 | + }else { |
|
| 5687 | 5687 | $returnValue = $this; |
| 5688 | 5688 | } |
| 5689 | 5689 | |
| 5690 | - if( $this->parens ){ |
|
| 5691 | - if( !$this->parensInOp ){ |
|
| 5690 | + if ($this->parens) { |
|
| 5691 | + if (!$this->parensInOp) { |
|
| 5692 | 5692 | Less_Environment::$parensStack--; |
| 5693 | 5693 | |
| 5694 | - }elseif( !Less_Environment::isMathOn() && !$doubleParen ){ |
|
| 5694 | + }elseif (!Less_Environment::isMathOn() && !$doubleParen) { |
|
| 5695 | 5695 | $returnValue = new Less_Tree_Paren($returnValue); |
| 5696 | 5696 | |
| 5697 | 5697 | } |
@@ -5702,22 +5702,22 @@ discard block |
||
| 5702 | 5702 | /** |
| 5703 | 5703 | * @see Less_Tree::genCSS |
| 5704 | 5704 | */ |
| 5705 | - public function genCSS( $output ){ |
|
| 5705 | + public function genCSS($output) { |
|
| 5706 | 5706 | $val_len = count($this->value); |
| 5707 | - for( $i = 0; $i < $val_len; $i++ ){ |
|
| 5708 | - $this->value[$i]->genCSS( $output ); |
|
| 5709 | - if( $i + 1 < $val_len ){ |
|
| 5710 | - $output->add( ' ' ); |
|
| 5707 | + for ($i = 0; $i<$val_len; $i++) { |
|
| 5708 | + $this->value[$i]->genCSS($output); |
|
| 5709 | + if ($i+1<$val_len) { |
|
| 5710 | + $output->add(' '); |
|
| 5711 | 5711 | } |
| 5712 | 5712 | } |
| 5713 | 5713 | } |
| 5714 | 5714 | |
| 5715 | 5715 | public function throwAwayComments() { |
| 5716 | 5716 | |
| 5717 | - if( is_array($this->value) ){ |
|
| 5717 | + if (is_array($this->value)) { |
|
| 5718 | 5718 | $new_value = array(); |
| 5719 | - foreach($this->value as $v){ |
|
| 5720 | - if( $v instanceof Less_Tree_Comment ){ |
|
| 5719 | + foreach ($this->value as $v) { |
|
| 5720 | + if ($v instanceof Less_Tree_Comment) { |
|
| 5721 | 5721 | continue; |
| 5722 | 5722 | } |
| 5723 | 5723 | $new_value[] = $v; |
@@ -5734,7 +5734,7 @@ discard block |
||
| 5734 | 5734 | * @package Less |
| 5735 | 5735 | * @subpackage tree |
| 5736 | 5736 | */ |
| 5737 | -class Less_Tree_Extend extends Less_Tree{ |
|
| 5737 | +class Less_Tree_Extend extends Less_Tree { |
|
| 5738 | 5738 | |
| 5739 | 5739 | public $selector; |
| 5740 | 5740 | public $option; |
@@ -5753,13 +5753,13 @@ discard block |
||
| 5753 | 5753 | /** |
| 5754 | 5754 | * @param integer $index |
| 5755 | 5755 | */ |
| 5756 | - public function __construct($selector, $option, $index){ |
|
| 5756 | + public function __construct($selector, $option, $index) { |
|
| 5757 | 5757 | static $i = 0; |
| 5758 | 5758 | $this->selector = $selector; |
| 5759 | 5759 | $this->option = $option; |
| 5760 | 5760 | $this->index = $index; |
| 5761 | 5761 | |
| 5762 | - switch($option){ |
|
| 5762 | + switch ($option) { |
|
| 5763 | 5763 | case "all": |
| 5764 | 5764 | $this->allowBefore = true; |
| 5765 | 5765 | $this->allowAfter = true; |
@@ -5774,29 +5774,29 @@ discard block |
||
| 5774 | 5774 | $this->parent_ids = array($this->object_id); |
| 5775 | 5775 | } |
| 5776 | 5776 | |
| 5777 | - public function accept( $visitor ){ |
|
| 5778 | - $this->selector = $visitor->visitObj( $this->selector ); |
|
| 5777 | + public function accept($visitor) { |
|
| 5778 | + $this->selector = $visitor->visitObj($this->selector); |
|
| 5779 | 5779 | } |
| 5780 | 5780 | |
| 5781 | - public function compile( $env ){ |
|
| 5781 | + public function compile($env) { |
|
| 5782 | 5782 | Less_Parser::$has_extends = true; |
| 5783 | 5783 | $this->selector = $this->selector->compile($env); |
| 5784 | 5784 | return $this; |
| 5785 | 5785 | //return new Less_Tree_Extend( $this->selector->compile($env), $this->option, $this->index); |
| 5786 | 5786 | } |
| 5787 | 5787 | |
| 5788 | - public function findSelfSelectors( $selectors ){ |
|
| 5788 | + public function findSelfSelectors($selectors) { |
|
| 5789 | 5789 | $selfElements = array(); |
| 5790 | 5790 | |
| 5791 | 5791 | |
| 5792 | - for( $i = 0, $selectors_len = count($selectors); $i < $selectors_len; $i++ ){ |
|
| 5792 | + for ($i = 0, $selectors_len = count($selectors); $i<$selectors_len; $i++) { |
|
| 5793 | 5793 | $selectorElements = $selectors[$i]->elements; |
| 5794 | 5794 | // duplicate the logic in genCSS function inside the selector node. |
| 5795 | 5795 | // future TODO - move both logics into the selector joiner visitor |
| 5796 | - if( $i && $selectorElements && $selectorElements[0]->combinator === "") { |
|
| 5796 | + if ($i && $selectorElements && $selectorElements[0]->combinator==="") { |
|
| 5797 | 5797 | $selectorElements[0]->combinator = ' '; |
| 5798 | 5798 | } |
| 5799 | - $selfElements = array_merge( $selfElements, $selectors[$i]->elements ); |
|
| 5799 | + $selfElements = array_merge($selfElements, $selectors[$i]->elements); |
|
| 5800 | 5800 | } |
| 5801 | 5801 | |
| 5802 | 5802 | $this->selfSelectors = array(new Less_Tree_Selector($selfElements)); |
@@ -5819,7 +5819,7 @@ discard block |
||
| 5819 | 5819 | * @package Less |
| 5820 | 5820 | * @subpackage tree |
| 5821 | 5821 | */ |
| 5822 | -class Less_Tree_Import extends Less_Tree{ |
|
| 5822 | +class Less_Tree_Import extends Less_Tree { |
|
| 5823 | 5823 | |
| 5824 | 5824 | public $options; |
| 5825 | 5825 | public $index; |
@@ -5831,21 +5831,21 @@ discard block |
||
| 5831 | 5831 | public $root; |
| 5832 | 5832 | public $type = 'Import'; |
| 5833 | 5833 | |
| 5834 | - public function __construct($path, $features, $options, $index, $currentFileInfo = null ){ |
|
| 5834 | + public function __construct($path, $features, $options, $index, $currentFileInfo = null) { |
|
| 5835 | 5835 | $this->options = $options; |
| 5836 | 5836 | $this->index = $index; |
| 5837 | 5837 | $this->path = $path; |
| 5838 | 5838 | $this->features = $features; |
| 5839 | 5839 | $this->currentFileInfo = $currentFileInfo; |
| 5840 | 5840 | |
| 5841 | - if( is_array($options) ){ |
|
| 5841 | + if (is_array($options)) { |
|
| 5842 | 5842 | $this->options += array('inline'=>false); |
| 5843 | 5843 | |
| 5844 | - if( isset($this->options['less']) || $this->options['inline'] ){ |
|
| 5844 | + if (isset($this->options['less']) || $this->options['inline']) { |
|
| 5845 | 5845 | $this->css = !isset($this->options['less']) || !$this->options['less'] || $this->options['inline']; |
| 5846 | - } else { |
|
| 5846 | + }else { |
|
| 5847 | 5847 | $pathValue = $this->getPath(); |
| 5848 | - if( $pathValue && preg_match('/css([\?;].*)?$/',$pathValue) ){ |
|
| 5848 | + if ($pathValue && preg_match('/css([\?;].*)?$/', $pathValue)) { |
|
| 5849 | 5849 | $this->css = true; |
| 5850 | 5850 | } |
| 5851 | 5851 | } |
@@ -5862,14 +5862,14 @@ discard block |
||
| 5862 | 5862 | // ruleset. |
| 5863 | 5863 | // |
| 5864 | 5864 | |
| 5865 | - public function accept($visitor){ |
|
| 5865 | + public function accept($visitor) { |
|
| 5866 | 5866 | |
| 5867 | - if( $this->features ){ |
|
| 5867 | + if ($this->features) { |
|
| 5868 | 5868 | $this->features = $visitor->visitObj($this->features); |
| 5869 | 5869 | } |
| 5870 | 5870 | $this->path = $visitor->visitObj($this->path); |
| 5871 | 5871 | |
| 5872 | - if( !$this->options['inline'] && $this->root ){ |
|
| 5872 | + if (!$this->options['inline'] && $this->root) { |
|
| 5873 | 5873 | $this->root = $visitor->visit($this->root); |
| 5874 | 5874 | } |
| 5875 | 5875 | } |
@@ -5877,26 +5877,26 @@ discard block |
||
| 5877 | 5877 | /** |
| 5878 | 5878 | * @see Less_Tree::genCSS |
| 5879 | 5879 | */ |
| 5880 | - public function genCSS( $output ){ |
|
| 5881 | - if( $this->css ){ |
|
| 5880 | + public function genCSS($output) { |
|
| 5881 | + if ($this->css) { |
|
| 5882 | 5882 | |
| 5883 | - $output->add( '@import ', $this->currentFileInfo, $this->index ); |
|
| 5883 | + $output->add('@import ', $this->currentFileInfo, $this->index); |
|
| 5884 | 5884 | |
| 5885 | - $this->path->genCSS( $output ); |
|
| 5886 | - if( $this->features ){ |
|
| 5887 | - $output->add( ' ' ); |
|
| 5888 | - $this->features->genCSS( $output ); |
|
| 5885 | + $this->path->genCSS($output); |
|
| 5886 | + if ($this->features) { |
|
| 5887 | + $output->add(' '); |
|
| 5888 | + $this->features->genCSS($output); |
|
| 5889 | 5889 | } |
| 5890 | - $output->add( ';' ); |
|
| 5890 | + $output->add(';'); |
|
| 5891 | 5891 | } |
| 5892 | 5892 | } |
| 5893 | 5893 | |
| 5894 | - public function toCSS(){ |
|
| 5895 | - $features = $this->features ? ' ' . $this->features->toCSS() : ''; |
|
| 5894 | + public function toCSS() { |
|
| 5895 | + $features = $this->features ? ' '.$this->features->toCSS() : ''; |
|
| 5896 | 5896 | |
| 5897 | 5897 | if ($this->css) { |
| 5898 | - return "@import " . $this->path->toCSS() . $features . ";\n"; |
|
| 5899 | - } else { |
|
| 5898 | + return "@import ".$this->path->toCSS().$features.";\n"; |
|
| 5899 | + }else { |
|
| 5900 | 5900 | return ""; |
| 5901 | 5901 | } |
| 5902 | 5902 | } |
@@ -5904,37 +5904,37 @@ discard block |
||
| 5904 | 5904 | /** |
| 5905 | 5905 | * @return string |
| 5906 | 5906 | */ |
| 5907 | - public function getPath(){ |
|
| 5907 | + public function getPath() { |
|
| 5908 | 5908 | if ($this->path instanceof Less_Tree_Quoted) { |
| 5909 | 5909 | $path = $this->path->value; |
| 5910 | - $path = ( isset($this->css) || preg_match('/(\.[a-z]*$)|([\?;].*)$/',$path)) ? $path : $path . '.less'; |
|
| 5911 | - } else if ($this->path instanceof Less_Tree_URL) { |
|
| 5910 | + $path = (isset($this->css) || preg_match('/(\.[a-z]*$)|([\?;].*)$/', $path)) ? $path : $path.'.less'; |
|
| 5911 | + }else if ($this->path instanceof Less_Tree_URL) { |
|
| 5912 | 5912 | $path = $this->path->value->value; |
| 5913 | - }else{ |
|
| 5913 | + }else { |
|
| 5914 | 5914 | return null; |
| 5915 | 5915 | } |
| 5916 | 5916 | |
| 5917 | 5917 | //remove query string and fragment |
| 5918 | - return preg_replace('/[\?#][^\?]*$/','',$path); |
|
| 5918 | + return preg_replace('/[\?#][^\?]*$/', '', $path); |
|
| 5919 | 5919 | } |
| 5920 | 5920 | |
| 5921 | - public function compileForImport( $env ){ |
|
| 5922 | - return new Less_Tree_Import( $this->path->compile($env), $this->features, $this->options, $this->index, $this->currentFileInfo); |
|
| 5921 | + public function compileForImport($env) { |
|
| 5922 | + return new Less_Tree_Import($this->path->compile($env), $this->features, $this->options, $this->index, $this->currentFileInfo); |
|
| 5923 | 5923 | } |
| 5924 | 5924 | |
| 5925 | 5925 | public function compilePath($env) { |
| 5926 | 5926 | $path = $this->path->compile($env); |
| 5927 | 5927 | $rootpath = ''; |
| 5928 | - if( $this->currentFileInfo && $this->currentFileInfo['rootpath'] ){ |
|
| 5928 | + if ($this->currentFileInfo && $this->currentFileInfo['rootpath']) { |
|
| 5929 | 5929 | $rootpath = $this->currentFileInfo['rootpath']; |
| 5930 | 5930 | } |
| 5931 | 5931 | |
| 5932 | 5932 | |
| 5933 | - if( !($path instanceof Less_Tree_URL) ){ |
|
| 5934 | - if( $rootpath ){ |
|
| 5933 | + if (!($path instanceof Less_Tree_URL)) { |
|
| 5934 | + if ($rootpath) { |
|
| 5935 | 5935 | $pathValue = $path->value; |
| 5936 | 5936 | // Add the base path if the import is relative |
| 5937 | - if( $pathValue && Less_Environment::isPathRelative($pathValue) ){ |
|
| 5937 | + if ($pathValue && Less_Environment::isPathRelative($pathValue)) { |
|
| 5938 | 5938 | $path->value = $this->currentFileInfo['uri_root'].$pathValue; |
| 5939 | 5939 | } |
| 5940 | 5940 | } |
@@ -5946,55 +5946,55 @@ discard block |
||
| 5946 | 5946 | return $path; |
| 5947 | 5947 | } |
| 5948 | 5948 | |
| 5949 | - public function compile( $env ){ |
|
| 5949 | + public function compile($env) { |
|
| 5950 | 5950 | |
| 5951 | 5951 | $evald = $this->compileForImport($env); |
| 5952 | 5952 | |
| 5953 | 5953 | //get path & uri |
| 5954 | 5954 | $path_and_uri = null; |
| 5955 | - if( is_callable(Less_Parser::$options['import_callback']) ){ |
|
| 5956 | - $path_and_uri = call_user_func(Less_Parser::$options['import_callback'],$evald); |
|
| 5955 | + if (is_callable(Less_Parser::$options['import_callback'])) { |
|
| 5956 | + $path_and_uri = call_user_func(Less_Parser::$options['import_callback'], $evald); |
|
| 5957 | 5957 | } |
| 5958 | 5958 | |
| 5959 | - if( !$path_and_uri ){ |
|
| 5959 | + if (!$path_and_uri) { |
|
| 5960 | 5960 | $path_and_uri = $evald->PathAndUri(); |
| 5961 | 5961 | } |
| 5962 | 5962 | |
| 5963 | - if( $path_and_uri ){ |
|
| 5963 | + if ($path_and_uri) { |
|
| 5964 | 5964 | list($full_path, $uri) = $path_and_uri; |
| 5965 | - }else{ |
|
| 5965 | + }else { |
|
| 5966 | 5966 | $full_path = $uri = $evald->getPath(); |
| 5967 | 5967 | } |
| 5968 | 5968 | |
| 5969 | 5969 | |
| 5970 | 5970 | //import once |
| 5971 | - if( $evald->skip( $full_path, $env) ){ |
|
| 5971 | + if ($evald->skip($full_path, $env)) { |
|
| 5972 | 5972 | return array(); |
| 5973 | 5973 | } |
| 5974 | 5974 | |
| 5975 | - if( $this->options['inline'] ){ |
|
| 5975 | + if ($this->options['inline']) { |
|
| 5976 | 5976 | //todo needs to reference css file not import |
| 5977 | 5977 | //$contents = new Less_Tree_Anonymous($this->root, 0, array('filename'=>$this->importedFilename), true ); |
| 5978 | 5978 | |
| 5979 | 5979 | Less_Parser::AddParsedFile($full_path); |
| 5980 | - $contents = new Less_Tree_Anonymous( file_get_contents($full_path), 0, array(), true ); |
|
| 5980 | + $contents = new Less_Tree_Anonymous(file_get_contents($full_path), 0, array(), true); |
|
| 5981 | 5981 | |
| 5982 | - if( $this->features ){ |
|
| 5983 | - return new Less_Tree_Media( array($contents), $this->features->value ); |
|
| 5982 | + if ($this->features) { |
|
| 5983 | + return new Less_Tree_Media(array($contents), $this->features->value); |
|
| 5984 | 5984 | } |
| 5985 | 5985 | |
| 5986 | - return array( $contents ); |
|
| 5986 | + return array($contents); |
|
| 5987 | 5987 | } |
| 5988 | 5988 | |
| 5989 | 5989 | |
| 5990 | 5990 | // css ? |
| 5991 | - if( $evald->css ){ |
|
| 5992 | - $features = ( $evald->features ? $evald->features->compile($env) : null ); |
|
| 5993 | - return new Less_Tree_Import( $this->compilePath( $env), $features, $this->options, $this->index); |
|
| 5991 | + if ($evald->css) { |
|
| 5992 | + $features = ($evald->features ? $evald->features->compile($env) : null); |
|
| 5993 | + return new Less_Tree_Import($this->compilePath($env), $features, $this->options, $this->index); |
|
| 5994 | 5994 | } |
| 5995 | 5995 | |
| 5996 | 5996 | |
| 5997 | - return $this->ParseImport( $full_path, $uri, $env ); |
|
| 5997 | + return $this->ParseImport($full_path, $uri, $env); |
|
| 5998 | 5998 | } |
| 5999 | 5999 | |
| 6000 | 6000 | |
@@ -6003,57 +6003,57 @@ discard block |
||
| 6003 | 6003 | * |
| 6004 | 6004 | * @param Less_Tree_Import $evald |
| 6005 | 6005 | */ |
| 6006 | - public function PathAndUri(){ |
|
| 6006 | + public function PathAndUri() { |
|
| 6007 | 6007 | |
| 6008 | 6008 | $evald_path = $this->getPath(); |
| 6009 | 6009 | |
| 6010 | - if( $evald_path ){ |
|
| 6010 | + if ($evald_path) { |
|
| 6011 | 6011 | |
| 6012 | 6012 | $import_dirs = array(); |
| 6013 | 6013 | |
| 6014 | - if( Less_Environment::isPathRelative($evald_path) ){ |
|
| 6014 | + if (Less_Environment::isPathRelative($evald_path)) { |
|
| 6015 | 6015 | //if the path is relative, the file should be in the current directory |
| 6016 | - $import_dirs[ $this->currentFileInfo['currentDirectory'] ] = $this->currentFileInfo['uri_root']; |
|
| 6016 | + $import_dirs[$this->currentFileInfo['currentDirectory']] = $this->currentFileInfo['uri_root']; |
|
| 6017 | 6017 | |
| 6018 | - }else{ |
|
| 6018 | + }else { |
|
| 6019 | 6019 | //otherwise, the file should be relative to the server root |
| 6020 | - $import_dirs[ $this->currentFileInfo['entryPath'] ] = $this->currentFileInfo['entryUri']; |
|
| 6020 | + $import_dirs[$this->currentFileInfo['entryPath']] = $this->currentFileInfo['entryUri']; |
|
| 6021 | 6021 | |
| 6022 | 6022 | //if the user supplied entryPath isn't the actual root |
| 6023 | - $import_dirs[ $_SERVER['DOCUMENT_ROOT'] ] = ''; |
|
| 6023 | + $import_dirs[$_SERVER['DOCUMENT_ROOT']] = ''; |
|
| 6024 | 6024 | |
| 6025 | 6025 | } |
| 6026 | 6026 | |
| 6027 | 6027 | // always look in user supplied import directories |
| 6028 | - $import_dirs = array_merge( $import_dirs, Less_Parser::$options['import_dirs'] ); |
|
| 6028 | + $import_dirs = array_merge($import_dirs, Less_Parser::$options['import_dirs']); |
|
| 6029 | 6029 | |
| 6030 | 6030 | |
| 6031 | - foreach( $import_dirs as $rootpath => $rooturi){ |
|
| 6032 | - if( is_callable($rooturi) ){ |
|
| 6031 | + foreach ($import_dirs as $rootpath => $rooturi) { |
|
| 6032 | + if (is_callable($rooturi)) { |
|
| 6033 | 6033 | list($path, $uri) = call_user_func($rooturi, $evald_path); |
| 6034 | - if( is_string($path) ){ |
|
| 6034 | + if (is_string($path)) { |
|
| 6035 | 6035 | $full_path = $path; |
| 6036 | - return array( $full_path, $uri ); |
|
| 6036 | + return array($full_path, $uri); |
|
| 6037 | 6037 | } |
| 6038 | - }elseif( !empty($rootpath) ){ |
|
| 6038 | + }elseif (!empty($rootpath)) { |
|
| 6039 | 6039 | |
| 6040 | 6040 | |
| 6041 | - if( $rooturi ){ |
|
| 6042 | - if( strpos($evald_path,$rooturi) === 0 ){ |
|
| 6043 | - $evald_path = substr( $evald_path, strlen($rooturi) ); |
|
| 6041 | + if ($rooturi) { |
|
| 6042 | + if (strpos($evald_path, $rooturi)===0) { |
|
| 6043 | + $evald_path = substr($evald_path, strlen($rooturi)); |
|
| 6044 | 6044 | } |
| 6045 | 6045 | } |
| 6046 | 6046 | |
| 6047 | - $path = rtrim($rootpath,'/\\').'/'.ltrim($evald_path,'/\\'); |
|
| 6047 | + $path = rtrim($rootpath, '/\\').'/'.ltrim($evald_path, '/\\'); |
|
| 6048 | 6048 | |
| 6049 | - if( file_exists($path) ){ |
|
| 6049 | + if (file_exists($path)) { |
|
| 6050 | 6050 | $full_path = Less_Environment::normalizePath($path); |
| 6051 | 6051 | $uri = Less_Environment::normalizePath(dirname($rooturi.$evald_path)); |
| 6052 | - return array( $full_path, $uri ); |
|
| 6053 | - } elseif( file_exists($path.'.less') ){ |
|
| 6052 | + return array($full_path, $uri); |
|
| 6053 | + } elseif (file_exists($path.'.less')) { |
|
| 6054 | 6054 | $full_path = Less_Environment::normalizePath($path.'.less'); |
| 6055 | 6055 | $uri = Less_Environment::normalizePath(dirname($rooturi.$evald_path.'.less')); |
| 6056 | - return array( $full_path, $uri ); |
|
| 6056 | + return array($full_path, $uri); |
|
| 6057 | 6057 | } |
| 6058 | 6058 | } |
| 6059 | 6059 | } |
@@ -6066,14 +6066,14 @@ discard block |
||
| 6066 | 6066 | * |
| 6067 | 6067 | * @return Less_Tree_Media|array |
| 6068 | 6068 | */ |
| 6069 | - public function ParseImport( $full_path, $uri, $env ){ |
|
| 6069 | + public function ParseImport($full_path, $uri, $env) { |
|
| 6070 | 6070 | |
| 6071 | 6071 | $import_env = clone $env; |
| 6072 | - if( (isset($this->options['reference']) && $this->options['reference']) || isset($this->currentFileInfo['reference']) ){ |
|
| 6072 | + if ((isset($this->options['reference']) && $this->options['reference']) || isset($this->currentFileInfo['reference'])) { |
|
| 6073 | 6073 | $import_env->currentFileInfo['reference'] = true; |
| 6074 | 6074 | } |
| 6075 | 6075 | |
| 6076 | - if( (isset($this->options['multiple']) && $this->options['multiple']) ){ |
|
| 6076 | + if ((isset($this->options['multiple']) && $this->options['multiple'])) { |
|
| 6077 | 6077 | $import_env->importMultiple = true; |
| 6078 | 6078 | } |
| 6079 | 6079 | |
@@ -6081,7 +6081,7 @@ discard block |
||
| 6081 | 6081 | $root = $parser->parseFile($full_path, $uri, true); |
| 6082 | 6082 | |
| 6083 | 6083 | |
| 6084 | - $ruleset = new Less_Tree_Ruleset(array(), $root->rules ); |
|
| 6084 | + $ruleset = new Less_Tree_Ruleset(array(), $root->rules); |
|
| 6085 | 6085 | $ruleset->evalImports($import_env); |
| 6086 | 6086 | |
| 6087 | 6087 | return $this->features ? new Less_Tree_Media($ruleset->rules, $this->features->value) : $ruleset->rules; |
@@ -6093,13 +6093,13 @@ discard block |
||
| 6093 | 6093 | * |
| 6094 | 6094 | * @return boolean|null |
| 6095 | 6095 | */ |
| 6096 | - private function Skip($path, $env){ |
|
| 6096 | + private function Skip($path, $env) { |
|
| 6097 | 6097 | |
| 6098 | 6098 | $path = Less_Parser::winPath(realpath($path)); |
| 6099 | 6099 | |
| 6100 | - if( $path && Less_Parser::FileParsed($path) ){ |
|
| 6100 | + if ($path && Less_Parser::FileParsed($path)) { |
|
| 6101 | 6101 | |
| 6102 | - if( isset($this->currentFileInfo['reference']) ){ |
|
| 6102 | + if (isset($this->currentFileInfo['reference'])) { |
|
| 6103 | 6103 | return true; |
| 6104 | 6104 | } |
| 6105 | 6105 | |
@@ -6117,7 +6117,7 @@ discard block |
||
| 6117 | 6117 | * @package Less |
| 6118 | 6118 | * @subpackage tree |
| 6119 | 6119 | */ |
| 6120 | -class Less_Tree_Javascript extends Less_Tree{ |
|
| 6120 | +class Less_Tree_Javascript extends Less_Tree { |
|
| 6121 | 6121 | |
| 6122 | 6122 | public $type = 'Javascript'; |
| 6123 | 6123 | public $escaped; |
@@ -6128,13 +6128,13 @@ discard block |
||
| 6128 | 6128 | * @param boolean $index |
| 6129 | 6129 | * @param boolean $escaped |
| 6130 | 6130 | */ |
| 6131 | - public function __construct($string, $index, $escaped){ |
|
| 6131 | + public function __construct($string, $index, $escaped) { |
|
| 6132 | 6132 | $this->escaped = $escaped; |
| 6133 | 6133 | $this->expression = $string; |
| 6134 | 6134 | $this->index = $index; |
| 6135 | 6135 | } |
| 6136 | 6136 | |
| 6137 | - public function compile(){ |
|
| 6137 | + public function compile() { |
|
| 6138 | 6138 | return new Less_Tree_Anonymous('/* Sorry, can not do JavaScript evaluation in PHP... :( */'); |
| 6139 | 6139 | } |
| 6140 | 6140 | |
@@ -6147,7 +6147,7 @@ discard block |
||
| 6147 | 6147 | * @package Less |
| 6148 | 6148 | * @subpackage tree |
| 6149 | 6149 | */ |
| 6150 | -class Less_Tree_Keyword extends Less_Tree{ |
|
| 6150 | +class Less_Tree_Keyword extends Less_Tree { |
|
| 6151 | 6151 | |
| 6152 | 6152 | public $value; |
| 6153 | 6153 | public $type = 'Keyword'; |
@@ -6155,30 +6155,30 @@ discard block |
||
| 6155 | 6155 | /** |
| 6156 | 6156 | * @param string $value |
| 6157 | 6157 | */ |
| 6158 | - public function __construct($value){ |
|
| 6158 | + public function __construct($value) { |
|
| 6159 | 6159 | $this->value = $value; |
| 6160 | 6160 | } |
| 6161 | 6161 | |
| 6162 | - public function compile(){ |
|
| 6162 | + public function compile() { |
|
| 6163 | 6163 | return $this; |
| 6164 | 6164 | } |
| 6165 | 6165 | |
| 6166 | 6166 | /** |
| 6167 | 6167 | * @see Less_Tree::genCSS |
| 6168 | 6168 | */ |
| 6169 | - public function genCSS( $output ){ |
|
| 6169 | + public function genCSS($output) { |
|
| 6170 | 6170 | |
| 6171 | - if( $this->value === '%') { |
|
| 6171 | + if ($this->value==='%') { |
|
| 6172 | 6172 | throw new Less_Exception_Compiler("Invalid % without number"); |
| 6173 | 6173 | } |
| 6174 | 6174 | |
| 6175 | - $output->add( $this->value ); |
|
| 6175 | + $output->add($this->value); |
|
| 6176 | 6176 | } |
| 6177 | 6177 | |
| 6178 | 6178 | public function compare($other) { |
| 6179 | 6179 | if ($other instanceof Less_Tree_Keyword) { |
| 6180 | - return $other->value === $this->value ? 0 : 1; |
|
| 6181 | - } else { |
|
| 6180 | + return $other->value===$this->value ? 0 : 1; |
|
| 6181 | + }else { |
|
| 6182 | 6182 | return -1; |
| 6183 | 6183 | } |
| 6184 | 6184 | } |
@@ -6191,7 +6191,7 @@ discard block |
||
| 6191 | 6191 | * @package Less |
| 6192 | 6192 | * @subpackage tree |
| 6193 | 6193 | */ |
| 6194 | -class Less_Tree_Media extends Less_Tree{ |
|
| 6194 | +class Less_Tree_Media extends Less_Tree { |
|
| 6195 | 6195 | |
| 6196 | 6196 | public $features; |
| 6197 | 6197 | public $rules; |
@@ -6200,7 +6200,7 @@ discard block |
||
| 6200 | 6200 | public $isReferenced; |
| 6201 | 6201 | public $type = 'Media'; |
| 6202 | 6202 | |
| 6203 | - public function __construct($value = array(), $features = array(), $index = null, $currentFileInfo = null ){ |
|
| 6203 | + public function __construct($value = array(), $features = array(), $index = null, $currentFileInfo = null) { |
|
| 6204 | 6204 | |
| 6205 | 6205 | $this->index = $index; |
| 6206 | 6206 | $this->currentFileInfo = $currentFileInfo; |
@@ -6213,7 +6213,7 @@ discard block |
||
| 6213 | 6213 | $this->rules[0]->allowImports = true; |
| 6214 | 6214 | } |
| 6215 | 6215 | |
| 6216 | - public function accept( $visitor ){ |
|
| 6216 | + public function accept($visitor) { |
|
| 6217 | 6217 | $this->features = $visitor->visitObj($this->features); |
| 6218 | 6218 | $this->rules = $visitor->visitArray($this->rules); |
| 6219 | 6219 | } |
@@ -6221,27 +6221,27 @@ discard block |
||
| 6221 | 6221 | /** |
| 6222 | 6222 | * @see Less_Tree::genCSS |
| 6223 | 6223 | */ |
| 6224 | - public function genCSS( $output ){ |
|
| 6224 | + public function genCSS($output) { |
|
| 6225 | 6225 | |
| 6226 | - $output->add( '@media ', $this->currentFileInfo, $this->index ); |
|
| 6227 | - $this->features->genCSS( $output ); |
|
| 6228 | - Less_Tree::outputRuleset( $output, $this->rules); |
|
| 6226 | + $output->add('@media ', $this->currentFileInfo, $this->index); |
|
| 6227 | + $this->features->genCSS($output); |
|
| 6228 | + Less_Tree::outputRuleset($output, $this->rules); |
|
| 6229 | 6229 | |
| 6230 | 6230 | } |
| 6231 | 6231 | |
| 6232 | 6232 | public function compile($env) { |
| 6233 | 6233 | |
| 6234 | - $media = new Less_Tree_Media(array(), array(), $this->index, $this->currentFileInfo ); |
|
| 6234 | + $media = new Less_Tree_Media(array(), array(), $this->index, $this->currentFileInfo); |
|
| 6235 | 6235 | |
| 6236 | 6236 | $strictMathBypass = false; |
| 6237 | - if( Less_Parser::$options['strictMath'] === false) { |
|
| 6237 | + if (Less_Parser::$options['strictMath']===false) { |
|
| 6238 | 6238 | $strictMathBypass = true; |
| 6239 | 6239 | Less_Parser::$options['strictMath'] = true; |
| 6240 | 6240 | } |
| 6241 | 6241 | |
| 6242 | 6242 | $media->features = $this->features->compile($env); |
| 6243 | 6243 | |
| 6244 | - if( $strictMathBypass ){ |
|
| 6244 | + if ($strictMathBypass) { |
|
| 6245 | 6245 | Less_Parser::$options['strictMath'] = false; |
| 6246 | 6246 | } |
| 6247 | 6247 | |
@@ -6265,14 +6265,14 @@ discard block |
||
| 6265 | 6265 | return $this->rules[0]->find($selector, $this); |
| 6266 | 6266 | } |
| 6267 | 6267 | |
| 6268 | - public function emptySelectors(){ |
|
| 6269 | - $el = new Less_Tree_Element('','&', $this->index, $this->currentFileInfo ); |
|
| 6270 | - $sels = array( new Less_Tree_Selector(array($el), array(), null, $this->index, $this->currentFileInfo) ); |
|
| 6268 | + public function emptySelectors() { |
|
| 6269 | + $el = new Less_Tree_Element('', '&', $this->index, $this->currentFileInfo); |
|
| 6270 | + $sels = array(new Less_Tree_Selector(array($el), array(), null, $this->index, $this->currentFileInfo)); |
|
| 6271 | 6271 | $sels[0]->mediaEmpty = true; |
| 6272 | 6272 | return $sels; |
| 6273 | 6273 | } |
| 6274 | 6274 | |
| 6275 | - public function markReferenced(){ |
|
| 6275 | + public function markReferenced() { |
|
| 6276 | 6276 | $this->rules[0]->markReferenced(); |
| 6277 | 6277 | $this->isReferenced = true; |
| 6278 | 6278 | Less_Tree::ReferencedArray($this->rules[0]->rules); |
@@ -6282,7 +6282,7 @@ discard block |
||
| 6282 | 6282 | public function compileTop($env) { |
| 6283 | 6283 | $result = $this; |
| 6284 | 6284 | |
| 6285 | - if (count($env->mediaBlocks) > 1) { |
|
| 6285 | + if (count($env->mediaBlocks)>1) { |
|
| 6286 | 6286 | $selectors = $this->emptySelectors(); |
| 6287 | 6287 | $result = new Less_Tree_Ruleset($selectors, $env->mediaBlocks); |
| 6288 | 6288 | $result->multiMedia = true; |
@@ -6313,13 +6313,13 @@ discard block |
||
| 6313 | 6313 | |
| 6314 | 6314 | $permuted = $this->permute($path); |
| 6315 | 6315 | $expressions = array(); |
| 6316 | - foreach($permuted as $path){ |
|
| 6316 | + foreach ($permuted as $path) { |
|
| 6317 | 6317 | |
| 6318 | - for( $i=0, $len=count($path); $i < $len; $i++){ |
|
| 6318 | + for ($i = 0, $len = count($path); $i<$len; $i++) { |
|
| 6319 | 6319 | $path[$i] = Less_Parser::is_method($path[$i], 'toCSS') ? $path[$i] : new Less_Tree_Anonymous($path[$i]); |
| 6320 | 6320 | } |
| 6321 | 6321 | |
| 6322 | - for( $i = count($path) - 1; $i > 0; $i-- ){ |
|
| 6322 | + for ($i = count($path)-1; $i>0; $i--) { |
|
| 6323 | 6323 | array_splice($path, $i, 0, array(new Less_Tree_Anonymous('and'))); |
| 6324 | 6324 | } |
| 6325 | 6325 | |
@@ -6337,7 +6337,7 @@ discard block |
||
| 6337 | 6337 | if (!$arr) |
| 6338 | 6338 | return array(); |
| 6339 | 6339 | |
| 6340 | - if (count($arr) == 1) |
|
| 6340 | + if (count($arr)==1) |
|
| 6341 | 6341 | return $arr[0]; |
| 6342 | 6342 | |
| 6343 | 6343 | $result = array(); |
@@ -6356,9 +6356,9 @@ discard block |
||
| 6356 | 6356 | |
| 6357 | 6357 | public function bubbleSelectors($selectors) { |
| 6358 | 6358 | |
| 6359 | - if( !$selectors) return; |
|
| 6359 | + if (!$selectors) return; |
|
| 6360 | 6360 | |
| 6361 | - $this->rules = array(new Less_Tree_Ruleset( $selectors, array($this->rules[0]))); |
|
| 6361 | + $this->rules = array(new Less_Tree_Ruleset($selectors, array($this->rules[0]))); |
|
| 6362 | 6362 | } |
| 6363 | 6363 | |
| 6364 | 6364 | } |
@@ -6374,7 +6374,7 @@ discard block |
||
| 6374 | 6374 | * @package Less |
| 6375 | 6375 | * @subpackage tree |
| 6376 | 6376 | */ |
| 6377 | -class Less_Tree_NameValue extends Less_Tree{ |
|
| 6377 | +class Less_Tree_NameValue extends Less_Tree { |
|
| 6378 | 6378 | |
| 6379 | 6379 | public $name; |
| 6380 | 6380 | public $value; |
@@ -6382,14 +6382,14 @@ discard block |
||
| 6382 | 6382 | public $currentFileInfo; |
| 6383 | 6383 | public $type = 'NameValue'; |
| 6384 | 6384 | |
| 6385 | - public function __construct($name, $value = null, $index = null, $currentFileInfo = null ){ |
|
| 6385 | + public function __construct($name, $value = null, $index = null, $currentFileInfo = null) { |
|
| 6386 | 6386 | $this->name = $name; |
| 6387 | 6387 | $this->value = $value; |
| 6388 | 6388 | $this->index = $index; |
| 6389 | 6389 | $this->currentFileInfo = $currentFileInfo; |
| 6390 | 6390 | } |
| 6391 | 6391 | |
| 6392 | - public function genCSS( $output ){ |
|
| 6392 | + public function genCSS($output) { |
|
| 6393 | 6393 | |
| 6394 | 6394 | $output->add( |
| 6395 | 6395 | $this->name |
@@ -6399,7 +6399,7 @@ discard block |
||
| 6399 | 6399 | , $this->currentFileInfo, $this->index); |
| 6400 | 6400 | } |
| 6401 | 6401 | |
| 6402 | - public function compile ($env){ |
|
| 6402 | + public function compile($env) { |
|
| 6403 | 6403 | return $this; |
| 6404 | 6404 | } |
| 6405 | 6405 | } |
@@ -6411,12 +6411,12 @@ discard block |
||
| 6411 | 6411 | * @package Less |
| 6412 | 6412 | * @subpackage tree |
| 6413 | 6413 | */ |
| 6414 | -class Less_Tree_Negative extends Less_Tree{ |
|
| 6414 | +class Less_Tree_Negative extends Less_Tree { |
|
| 6415 | 6415 | |
| 6416 | 6416 | public $value; |
| 6417 | 6417 | public $type = 'Negative'; |
| 6418 | 6418 | |
| 6419 | - public function __construct($node){ |
|
| 6419 | + public function __construct($node) { |
|
| 6420 | 6420 | $this->value = $node; |
| 6421 | 6421 | } |
| 6422 | 6422 | |
@@ -6427,17 +6427,17 @@ discard block |
||
| 6427 | 6427 | /** |
| 6428 | 6428 | * @see Less_Tree::genCSS |
| 6429 | 6429 | */ |
| 6430 | - public function genCSS( $output ){ |
|
| 6431 | - $output->add( '-' ); |
|
| 6432 | - $this->value->genCSS( $output ); |
|
| 6430 | + public function genCSS($output) { |
|
| 6431 | + $output->add('-'); |
|
| 6432 | + $this->value->genCSS($output); |
|
| 6433 | 6433 | } |
| 6434 | 6434 | |
| 6435 | 6435 | public function compile($env) { |
| 6436 | - if( Less_Environment::isMathOn() ){ |
|
| 6437 | - $ret = new Less_Tree_Operation('*', array( new Less_Tree_Dimension(-1), $this->value ) ); |
|
| 6436 | + if (Less_Environment::isMathOn()) { |
|
| 6437 | + $ret = new Less_Tree_Operation('*', array(new Less_Tree_Dimension(-1), $this->value)); |
|
| 6438 | 6438 | return $ret->compile($env); |
| 6439 | 6439 | } |
| 6440 | - return new Less_Tree_Negative( $this->value->compile($env) ); |
|
| 6440 | + return new Less_Tree_Negative($this->value->compile($env)); |
|
| 6441 | 6441 | } |
| 6442 | 6442 | } |
| 6443 | 6443 | |
@@ -6447,7 +6447,7 @@ discard block |
||
| 6447 | 6447 | * @package Less |
| 6448 | 6448 | * @subpackage tree |
| 6449 | 6449 | */ |
| 6450 | -class Less_Tree_Operation extends Less_Tree{ |
|
| 6450 | +class Less_Tree_Operation extends Less_Tree { |
|
| 6451 | 6451 | |
| 6452 | 6452 | public $op; |
| 6453 | 6453 | public $operands; |
@@ -6457,7 +6457,7 @@ discard block |
||
| 6457 | 6457 | /** |
| 6458 | 6458 | * @param string $op |
| 6459 | 6459 | */ |
| 6460 | - public function __construct($op, $operands, $isSpaced = false){ |
|
| 6460 | + public function __construct($op, $operands, $isSpaced = false) { |
|
| 6461 | 6461 | $this->op = trim($op); |
| 6462 | 6462 | $this->operands = $operands; |
| 6463 | 6463 | $this->isSpaced = $isSpaced; |
@@ -6467,45 +6467,45 @@ discard block |
||
| 6467 | 6467 | $this->operands = $visitor->visitArray($this->operands); |
| 6468 | 6468 | } |
| 6469 | 6469 | |
| 6470 | - public function compile($env){ |
|
| 6470 | + public function compile($env) { |
|
| 6471 | 6471 | $a = $this->operands[0]->compile($env); |
| 6472 | 6472 | $b = $this->operands[1]->compile($env); |
| 6473 | 6473 | |
| 6474 | 6474 | |
| 6475 | - if( Less_Environment::isMathOn() ){ |
|
| 6475 | + if (Less_Environment::isMathOn()) { |
|
| 6476 | 6476 | |
| 6477 | - if( $a instanceof Less_Tree_Dimension && $b instanceof Less_Tree_Color ){ |
|
| 6477 | + if ($a instanceof Less_Tree_Dimension && $b instanceof Less_Tree_Color) { |
|
| 6478 | 6478 | $a = $a->toColor(); |
| 6479 | 6479 | |
| 6480 | - }elseif( $b instanceof Less_Tree_Dimension && $a instanceof Less_Tree_Color ){ |
|
| 6480 | + }elseif ($b instanceof Less_Tree_Dimension && $a instanceof Less_Tree_Color) { |
|
| 6481 | 6481 | $b = $b->toColor(); |
| 6482 | 6482 | |
| 6483 | 6483 | } |
| 6484 | 6484 | |
| 6485 | - if( !method_exists($a,'operate') ){ |
|
| 6485 | + if (!method_exists($a, 'operate')) { |
|
| 6486 | 6486 | throw new Less_Exception_Compiler("Operation on an invalid type"); |
| 6487 | 6487 | } |
| 6488 | 6488 | |
| 6489 | - return $a->operate( $this->op, $b); |
|
| 6489 | + return $a->operate($this->op, $b); |
|
| 6490 | 6490 | } |
| 6491 | 6491 | |
| 6492 | - return new Less_Tree_Operation($this->op, array($a, $b), $this->isSpaced ); |
|
| 6492 | + return new Less_Tree_Operation($this->op, array($a, $b), $this->isSpaced); |
|
| 6493 | 6493 | } |
| 6494 | 6494 | |
| 6495 | 6495 | |
| 6496 | 6496 | /** |
| 6497 | 6497 | * @see Less_Tree::genCSS |
| 6498 | 6498 | */ |
| 6499 | - public function genCSS( $output ){ |
|
| 6500 | - $this->operands[0]->genCSS( $output ); |
|
| 6501 | - if( $this->isSpaced ){ |
|
| 6502 | - $output->add( " " ); |
|
| 6499 | + public function genCSS($output) { |
|
| 6500 | + $this->operands[0]->genCSS($output); |
|
| 6501 | + if ($this->isSpaced) { |
|
| 6502 | + $output->add(" "); |
|
| 6503 | 6503 | } |
| 6504 | - $output->add( $this->op ); |
|
| 6505 | - if( $this->isSpaced ){ |
|
| 6506 | - $output->add( ' ' ); |
|
| 6504 | + $output->add($this->op); |
|
| 6505 | + if ($this->isSpaced) { |
|
| 6506 | + $output->add(' '); |
|
| 6507 | 6507 | } |
| 6508 | - $this->operands[1]->genCSS( $output ); |
|
| 6508 | + $this->operands[1]->genCSS($output); |
|
| 6509 | 6509 | } |
| 6510 | 6510 | |
| 6511 | 6511 | } |
@@ -6517,7 +6517,7 @@ discard block |
||
| 6517 | 6517 | * @package Less |
| 6518 | 6518 | * @subpackage tree |
| 6519 | 6519 | */ |
| 6520 | -class Less_Tree_Paren extends Less_Tree{ |
|
| 6520 | +class Less_Tree_Paren extends Less_Tree { |
|
| 6521 | 6521 | |
| 6522 | 6522 | public $value; |
| 6523 | 6523 | public $type = 'Paren'; |
@@ -6526,17 +6526,17 @@ discard block |
||
| 6526 | 6526 | $this->value = $value; |
| 6527 | 6527 | } |
| 6528 | 6528 | |
| 6529 | - public function accept($visitor){ |
|
| 6529 | + public function accept($visitor) { |
|
| 6530 | 6530 | $this->value = $visitor->visitObj($this->value); |
| 6531 | 6531 | } |
| 6532 | 6532 | |
| 6533 | 6533 | /** |
| 6534 | 6534 | * @see Less_Tree::genCSS |
| 6535 | 6535 | */ |
| 6536 | - public function genCSS( $output ){ |
|
| 6537 | - $output->add( '(' ); |
|
| 6538 | - $this->value->genCSS( $output ); |
|
| 6539 | - $output->add( ')' ); |
|
| 6536 | + public function genCSS($output) { |
|
| 6537 | + $output->add('('); |
|
| 6538 | + $this->value->genCSS($output); |
|
| 6539 | + $output->add(')'); |
|
| 6540 | 6540 | } |
| 6541 | 6541 | |
| 6542 | 6542 | public function compile($env) { |
@@ -6552,7 +6552,7 @@ discard block |
||
| 6552 | 6552 | * @package Less |
| 6553 | 6553 | * @subpackage tree |
| 6554 | 6554 | */ |
| 6555 | -class Less_Tree_Quoted extends Less_Tree{ |
|
| 6555 | +class Less_Tree_Quoted extends Less_Tree { |
|
| 6556 | 6556 | public $escaped; |
| 6557 | 6557 | public $value; |
| 6558 | 6558 | public $quote; |
@@ -6563,10 +6563,10 @@ discard block |
||
| 6563 | 6563 | /** |
| 6564 | 6564 | * @param string $str |
| 6565 | 6565 | */ |
| 6566 | - public function __construct($str, $content = '', $escaped = false, $index = false, $currentFileInfo = null ){ |
|
| 6566 | + public function __construct($str, $content = '', $escaped = false, $index = false, $currentFileInfo = null) { |
|
| 6567 | 6567 | $this->escaped = $escaped; |
| 6568 | 6568 | $this->value = $content; |
| 6569 | - if( $str ){ |
|
| 6569 | + if ($str) { |
|
| 6570 | 6570 | $this->quote = $str[0]; |
| 6571 | 6571 | } |
| 6572 | 6572 | $this->index = $index; |
@@ -6576,53 +6576,53 @@ discard block |
||
| 6576 | 6576 | /** |
| 6577 | 6577 | * @see Less_Tree::genCSS |
| 6578 | 6578 | */ |
| 6579 | - public function genCSS( $output ){ |
|
| 6580 | - if( !$this->escaped ){ |
|
| 6581 | - $output->add( $this->quote, $this->currentFileInfo, $this->index ); |
|
| 6579 | + public function genCSS($output) { |
|
| 6580 | + if (!$this->escaped) { |
|
| 6581 | + $output->add($this->quote, $this->currentFileInfo, $this->index); |
|
| 6582 | 6582 | } |
| 6583 | - $output->add( $this->value ); |
|
| 6584 | - if( !$this->escaped ){ |
|
| 6585 | - $output->add( $this->quote ); |
|
| 6583 | + $output->add($this->value); |
|
| 6584 | + if (!$this->escaped) { |
|
| 6585 | + $output->add($this->quote); |
|
| 6586 | 6586 | } |
| 6587 | 6587 | } |
| 6588 | 6588 | |
| 6589 | - public function compile($env){ |
|
| 6589 | + public function compile($env) { |
|
| 6590 | 6590 | |
| 6591 | 6591 | $value = $this->value; |
| 6592 | - if( preg_match_all('/`([^`]+)`/', $this->value, $matches) ){ |
|
| 6593 | - foreach($matches as $i => $match){ |
|
| 6592 | + if (preg_match_all('/`([^`]+)`/', $this->value, $matches)) { |
|
| 6593 | + foreach ($matches as $i => $match) { |
|
| 6594 | 6594 | $js = new Less_Tree_JavaScript($matches[1], $this->index, true); |
| 6595 | 6595 | $js = $js->compile()->value; |
| 6596 | 6596 | $value = str_replace($matches[0][$i], $js, $value); |
| 6597 | 6597 | } |
| 6598 | 6598 | } |
| 6599 | 6599 | |
| 6600 | - if( preg_match_all('/@\{([\w-]+)\}/',$value,$matches) ){ |
|
| 6601 | - foreach($matches[1] as $i => $match){ |
|
| 6602 | - $v = new Less_Tree_Variable('@' . $match, $this->index, $this->currentFileInfo ); |
|
| 6600 | + if (preg_match_all('/@\{([\w-]+)\}/', $value, $matches)) { |
|
| 6601 | + foreach ($matches[1] as $i => $match) { |
|
| 6602 | + $v = new Less_Tree_Variable('@'.$match, $this->index, $this->currentFileInfo); |
|
| 6603 | 6603 | $v = $v->compile($env); |
| 6604 | 6604 | $v = ($v instanceof Less_Tree_Quoted) ? $v->value : $v->toCSS(); |
| 6605 | 6605 | $value = str_replace($matches[0][$i], $v, $value); |
| 6606 | 6606 | } |
| 6607 | 6607 | } |
| 6608 | 6608 | |
| 6609 | - return new Less_Tree_Quoted($this->quote . $value . $this->quote, $value, $this->escaped, $this->index, $this->currentFileInfo); |
|
| 6609 | + return new Less_Tree_Quoted($this->quote.$value.$this->quote, $value, $this->escaped, $this->index, $this->currentFileInfo); |
|
| 6610 | 6610 | } |
| 6611 | 6611 | |
| 6612 | 6612 | public function compare($x) { |
| 6613 | 6613 | |
| 6614 | - if( !Less_Parser::is_method($x, 'toCSS') ){ |
|
| 6614 | + if (!Less_Parser::is_method($x, 'toCSS')) { |
|
| 6615 | 6615 | return -1; |
| 6616 | 6616 | } |
| 6617 | 6617 | |
| 6618 | 6618 | $left = $this->toCSS(); |
| 6619 | 6619 | $right = $x->toCSS(); |
| 6620 | 6620 | |
| 6621 | - if ($left === $right) { |
|
| 6621 | + if ($left===$right) { |
|
| 6622 | 6622 | return 0; |
| 6623 | 6623 | } |
| 6624 | 6624 | |
| 6625 | - return $left < $right ? -1 : 1; |
|
| 6625 | + return $left<$right ? -1 : 1; |
|
| 6626 | 6626 | } |
| 6627 | 6627 | } |
| 6628 | 6628 | |
@@ -6633,7 +6633,7 @@ discard block |
||
| 6633 | 6633 | * @package Less |
| 6634 | 6634 | * @subpackage tree |
| 6635 | 6635 | */ |
| 6636 | -class Less_Tree_Rule extends Less_Tree{ |
|
| 6636 | +class Less_Tree_Rule extends Less_Tree { |
|
| 6637 | 6637 | |
| 6638 | 6638 | public $name; |
| 6639 | 6639 | public $value; |
@@ -6648,73 +6648,73 @@ discard block |
||
| 6648 | 6648 | /** |
| 6649 | 6649 | * @param string $important |
| 6650 | 6650 | */ |
| 6651 | - public function __construct($name, $value = null, $important = null, $merge = null, $index = null, $currentFileInfo = null, $inline = false){ |
|
| 6651 | + public function __construct($name, $value = null, $important = null, $merge = null, $index = null, $currentFileInfo = null, $inline = false) { |
|
| 6652 | 6652 | $this->name = $name; |
| 6653 | 6653 | $this->value = ($value instanceof Less_Tree_Value || $value instanceof Less_Tree_Ruleset) ? $value : new Less_Tree_Value(array($value)); |
| 6654 | - $this->important = $important ? ' ' . trim($important) : ''; |
|
| 6654 | + $this->important = $important ? ' '.trim($important) : ''; |
|
| 6655 | 6655 | $this->merge = $merge; |
| 6656 | 6656 | $this->index = $index; |
| 6657 | 6657 | $this->currentFileInfo = $currentFileInfo; |
| 6658 | 6658 | $this->inline = $inline; |
| 6659 | - $this->variable = ( is_string($name) && $name[0] === '@'); |
|
| 6659 | + $this->variable = (is_string($name) && $name[0]==='@'); |
|
| 6660 | 6660 | } |
| 6661 | 6661 | |
| 6662 | 6662 | public function accept($visitor) { |
| 6663 | - $this->value = $visitor->visitObj( $this->value ); |
|
| 6663 | + $this->value = $visitor->visitObj($this->value); |
|
| 6664 | 6664 | } |
| 6665 | 6665 | |
| 6666 | 6666 | /** |
| 6667 | 6667 | * @see Less_Tree::genCSS |
| 6668 | 6668 | */ |
| 6669 | - public function genCSS( $output ){ |
|
| 6669 | + public function genCSS($output) { |
|
| 6670 | 6670 | |
| 6671 | - $output->add( $this->name . Less_Environment::$_outputMap[': '], $this->currentFileInfo, $this->index); |
|
| 6672 | - try{ |
|
| 6673 | - $this->value->genCSS( $output); |
|
| 6671 | + $output->add($this->name.Less_Environment::$_outputMap[': '], $this->currentFileInfo, $this->index); |
|
| 6672 | + try { |
|
| 6673 | + $this->value->genCSS($output); |
|
| 6674 | 6674 | |
| 6675 | - }catch( Less_Exception_Parser $e ){ |
|
| 6675 | + } catch (Less_Exception_Parser $e) { |
|
| 6676 | 6676 | $e->index = $this->index; |
| 6677 | 6677 | $e->currentFile = $this->currentFileInfo; |
| 6678 | 6678 | throw $e; |
| 6679 | 6679 | } |
| 6680 | - $output->add( $this->important . (($this->inline || (Less_Environment::$lastRule && Less_Parser::$options['compress'])) ? "" : ";"), $this->currentFileInfo, $this->index); |
|
| 6680 | + $output->add($this->important.(($this->inline || (Less_Environment::$lastRule && Less_Parser::$options['compress'])) ? "" : ";"), $this->currentFileInfo, $this->index); |
|
| 6681 | 6681 | } |
| 6682 | 6682 | |
| 6683 | - public function compile ($env){ |
|
| 6683 | + public function compile($env) { |
|
| 6684 | 6684 | |
| 6685 | 6685 | $name = $this->name; |
| 6686 | - if( is_array($name) ){ |
|
| 6686 | + if (is_array($name)) { |
|
| 6687 | 6687 | // expand 'primitive' name directly to get |
| 6688 | 6688 | // things faster (~10% for benchmark.less): |
| 6689 | - if( count($name) === 1 && $name[0] instanceof Less_Tree_Keyword ){ |
|
| 6689 | + if (count($name)===1 && $name[0] instanceof Less_Tree_Keyword) { |
|
| 6690 | 6690 | $name = $name[0]->value; |
| 6691 | - }else{ |
|
| 6692 | - $name = $this->CompileName($env,$name); |
|
| 6691 | + }else { |
|
| 6692 | + $name = $this->CompileName($env, $name); |
|
| 6693 | 6693 | } |
| 6694 | 6694 | } |
| 6695 | 6695 | |
| 6696 | 6696 | $strictMathBypass = Less_Parser::$options['strictMath']; |
| 6697 | - if( $name === "font" && !Less_Parser::$options['strictMath'] ){ |
|
| 6697 | + if ($name==="font" && !Less_Parser::$options['strictMath']) { |
|
| 6698 | 6698 | Less_Parser::$options['strictMath'] = true; |
| 6699 | 6699 | } |
| 6700 | 6700 | |
| 6701 | 6701 | try { |
| 6702 | 6702 | $evaldValue = $this->value->compile($env); |
| 6703 | 6703 | |
| 6704 | - if( !$this->variable && $evaldValue->type === "DetachedRuleset") { |
|
| 6704 | + if (!$this->variable && $evaldValue->type==="DetachedRuleset") { |
|
| 6705 | 6705 | throw new Less_Exception_Compiler("Rulesets cannot be evaluated on a property.", null, $this->index, $this->currentFileInfo); |
| 6706 | 6706 | } |
| 6707 | 6707 | |
| 6708 | - if( Less_Environment::$mixin_stack ){ |
|
| 6708 | + if (Less_Environment::$mixin_stack) { |
|
| 6709 | 6709 | $return = new Less_Tree_Rule($name, $evaldValue, $this->important, $this->merge, $this->index, $this->currentFileInfo, $this->inline); |
| 6710 | - }else{ |
|
| 6710 | + }else { |
|
| 6711 | 6711 | $this->name = $name; |
| 6712 | 6712 | $this->value = $evaldValue; |
| 6713 | 6713 | $return = $this; |
| 6714 | 6714 | } |
| 6715 | 6715 | |
| 6716 | - }catch( Less_Exception_Parser $e ){ |
|
| 6717 | - if( !is_numeric($e->index) ){ |
|
| 6716 | + } catch (Less_Exception_Parser $e) { |
|
| 6717 | + if (!is_numeric($e->index)) { |
|
| 6718 | 6718 | $e->index = $this->index; |
| 6719 | 6719 | $e->currentFile = $this->currentFileInfo; |
| 6720 | 6720 | } |
@@ -6727,15 +6727,15 @@ discard block |
||
| 6727 | 6727 | } |
| 6728 | 6728 | |
| 6729 | 6729 | |
| 6730 | - public function CompileName( $env, $name ){ |
|
| 6730 | + public function CompileName($env, $name) { |
|
| 6731 | 6731 | $output = new Less_Output(); |
| 6732 | - foreach($name as $n){ |
|
| 6732 | + foreach ($name as $n) { |
|
| 6733 | 6733 | $n->compile($env)->genCSS($output); |
| 6734 | 6734 | } |
| 6735 | 6735 | return $output->toString(); |
| 6736 | 6736 | } |
| 6737 | 6737 | |
| 6738 | - public function makeImportant(){ |
|
| 6738 | + public function makeImportant() { |
|
| 6739 | 6739 | return new Less_Tree_Rule($this->name, $this->value, '!important', $this->merge, $this->index, $this->currentFileInfo, $this->inline); |
| 6740 | 6740 | } |
| 6741 | 6741 | |
@@ -6748,7 +6748,7 @@ discard block |
||
| 6748 | 6748 | * @package Less |
| 6749 | 6749 | * @subpackage tree |
| 6750 | 6750 | */ |
| 6751 | -class Less_Tree_Ruleset extends Less_Tree{ |
|
| 6751 | +class Less_Tree_Ruleset extends Less_Tree { |
|
| 6752 | 6752 | |
| 6753 | 6753 | protected $lookups; |
| 6754 | 6754 | public $_variables; |
@@ -6771,20 +6771,20 @@ discard block |
||
| 6771 | 6771 | |
| 6772 | 6772 | public $first_oelements; |
| 6773 | 6773 | |
| 6774 | - public function SetRulesetIndex(){ |
|
| 6774 | + public function SetRulesetIndex() { |
|
| 6775 | 6775 | $this->ruleset_id = Less_Parser::$next_id++; |
| 6776 | 6776 | $this->originalRuleset = $this->ruleset_id; |
| 6777 | 6777 | |
| 6778 | - if( $this->selectors ){ |
|
| 6779 | - foreach($this->selectors as $sel){ |
|
| 6780 | - if( $sel->_oelements ){ |
|
| 6778 | + if ($this->selectors) { |
|
| 6779 | + foreach ($this->selectors as $sel) { |
|
| 6780 | + if ($sel->_oelements) { |
|
| 6781 | 6781 | $this->first_oelements[$sel->_oelements[0]] = true; |
| 6782 | 6782 | } |
| 6783 | 6783 | } |
| 6784 | 6784 | } |
| 6785 | 6785 | } |
| 6786 | 6786 | |
| 6787 | - public function __construct($selectors, $rules, $strictImports = null){ |
|
| 6787 | + public function __construct($selectors, $rules, $strictImports = null) { |
|
| 6788 | 6788 | $this->selectors = $selectors; |
| 6789 | 6789 | $this->rules = $rules; |
| 6790 | 6790 | $this->lookups = array(); |
@@ -6792,22 +6792,22 @@ discard block |
||
| 6792 | 6792 | $this->SetRulesetIndex(); |
| 6793 | 6793 | } |
| 6794 | 6794 | |
| 6795 | - public function accept( $visitor ){ |
|
| 6796 | - if( $this->paths ){ |
|
| 6795 | + public function accept($visitor) { |
|
| 6796 | + if ($this->paths) { |
|
| 6797 | 6797 | $paths_len = count($this->paths); |
| 6798 | - for($i = 0,$paths_len; $i < $paths_len; $i++ ){ |
|
| 6798 | + for ($i = 0, $paths_len; $i<$paths_len; $i++) { |
|
| 6799 | 6799 | $this->paths[$i] = $visitor->visitArray($this->paths[$i]); |
| 6800 | 6800 | } |
| 6801 | - }elseif( $this->selectors ){ |
|
| 6801 | + }elseif ($this->selectors) { |
|
| 6802 | 6802 | $this->selectors = $visitor->visitArray($this->selectors); |
| 6803 | 6803 | } |
| 6804 | 6804 | |
| 6805 | - if( $this->rules ){ |
|
| 6805 | + if ($this->rules) { |
|
| 6806 | 6806 | $this->rules = $visitor->visitArray($this->rules); |
| 6807 | 6807 | } |
| 6808 | 6808 | } |
| 6809 | 6809 | |
| 6810 | - public function compile($env){ |
|
| 6810 | + public function compile($env) { |
|
| 6811 | 6811 | |
| 6812 | 6812 | $ruleset = $this->PrepareRuleset($env); |
| 6813 | 6813 | |
@@ -6815,43 +6815,43 @@ discard block |
||
| 6815 | 6815 | // Store the frames around mixin definitions, |
| 6816 | 6816 | // so they can be evaluated like closures when the time comes. |
| 6817 | 6817 | $rsRuleCnt = count($ruleset->rules); |
| 6818 | - for( $i = 0; $i < $rsRuleCnt; $i++ ){ |
|
| 6819 | - if( $ruleset->rules[$i] instanceof Less_Tree_Mixin_Definition || $ruleset->rules[$i] instanceof Less_Tree_DetachedRuleset ){ |
|
| 6818 | + for ($i = 0; $i<$rsRuleCnt; $i++) { |
|
| 6819 | + if ($ruleset->rules[$i] instanceof Less_Tree_Mixin_Definition || $ruleset->rules[$i] instanceof Less_Tree_DetachedRuleset) { |
|
| 6820 | 6820 | $ruleset->rules[$i] = $ruleset->rules[$i]->compile($env); |
| 6821 | 6821 | } |
| 6822 | 6822 | } |
| 6823 | 6823 | |
| 6824 | 6824 | $mediaBlockCount = 0; |
| 6825 | - if( $env instanceof Less_Environment ){ |
|
| 6825 | + if ($env instanceof Less_Environment) { |
|
| 6826 | 6826 | $mediaBlockCount = count($env->mediaBlocks); |
| 6827 | 6827 | } |
| 6828 | 6828 | |
| 6829 | 6829 | // Evaluate mixin calls. |
| 6830 | - $this->EvalMixinCalls( $ruleset, $env, $rsRuleCnt ); |
|
| 6830 | + $this->EvalMixinCalls($ruleset, $env, $rsRuleCnt); |
|
| 6831 | 6831 | |
| 6832 | 6832 | |
| 6833 | 6833 | // Evaluate everything else |
| 6834 | - for( $i=0; $i<$rsRuleCnt; $i++ ){ |
|
| 6835 | - if(! ($ruleset->rules[$i] instanceof Less_Tree_Mixin_Definition || $ruleset->rules[$i] instanceof Less_Tree_DetachedRuleset) ){ |
|
| 6834 | + for ($i = 0; $i<$rsRuleCnt; $i++) { |
|
| 6835 | + if (!($ruleset->rules[$i] instanceof Less_Tree_Mixin_Definition || $ruleset->rules[$i] instanceof Less_Tree_DetachedRuleset)) { |
|
| 6836 | 6836 | $ruleset->rules[$i] = $ruleset->rules[$i]->compile($env); |
| 6837 | 6837 | } |
| 6838 | 6838 | } |
| 6839 | 6839 | |
| 6840 | 6840 | // Evaluate everything else |
| 6841 | - for( $i=0; $i<$rsRuleCnt; $i++ ){ |
|
| 6841 | + for ($i = 0; $i<$rsRuleCnt; $i++) { |
|
| 6842 | 6842 | $rule = $ruleset->rules[$i]; |
| 6843 | 6843 | |
| 6844 | 6844 | // for rulesets, check if it is a css guard and can be removed |
| 6845 | - if( $rule instanceof Less_Tree_Ruleset && $rule->selectors && count($rule->selectors) === 1 ){ |
|
| 6845 | + if ($rule instanceof Less_Tree_Ruleset && $rule->selectors && count($rule->selectors)===1) { |
|
| 6846 | 6846 | |
| 6847 | 6847 | // check if it can be folded in (e.g. & where) |
| 6848 | - if( $rule->selectors[0]->isJustParentSelector() ){ |
|
| 6849 | - array_splice($ruleset->rules,$i--,1); |
|
| 6848 | + if ($rule->selectors[0]->isJustParentSelector()) { |
|
| 6849 | + array_splice($ruleset->rules, $i--, 1); |
|
| 6850 | 6850 | $rsRuleCnt--; |
| 6851 | 6851 | |
| 6852 | - for($j = 0; $j < count($rule->rules); $j++ ){ |
|
| 6852 | + for ($j = 0; $j<count($rule->rules); $j++) { |
|
| 6853 | 6853 | $subRule = $rule->rules[$j]; |
| 6854 | - if( !($subRule instanceof Less_Tree_Rule) || !$subRule->variable ){ |
|
| 6854 | + if (!($subRule instanceof Less_Tree_Rule) || !$subRule->variable) { |
|
| 6855 | 6855 | array_splice($ruleset->rules, ++$i, 0, array($subRule)); |
| 6856 | 6856 | $rsRuleCnt++; |
| 6857 | 6857 | } |
@@ -6867,7 +6867,7 @@ discard block |
||
| 6867 | 6867 | |
| 6868 | 6868 | if ($mediaBlockCount) { |
| 6869 | 6869 | $len = count($env->mediaBlocks); |
| 6870 | - for($i = $mediaBlockCount; $i < $len; $i++ ){ |
|
| 6870 | + for ($i = $mediaBlockCount; $i<$len; $i++) { |
|
| 6871 | 6871 | $env->mediaBlocks[$i]->bubbleSelectors($ruleset->selectors); |
| 6872 | 6872 | } |
| 6873 | 6873 | } |
@@ -6881,23 +6881,23 @@ discard block |
||
| 6881 | 6881 | * @param Less_Tree_Ruleset $ruleset |
| 6882 | 6882 | * @param integer $rsRuleCnt |
| 6883 | 6883 | */ |
| 6884 | - private function EvalMixinCalls( $ruleset, $env, &$rsRuleCnt ){ |
|
| 6885 | - for($i=0; $i < $rsRuleCnt; $i++){ |
|
| 6884 | + private function EvalMixinCalls($ruleset, $env, &$rsRuleCnt) { |
|
| 6885 | + for ($i = 0; $i<$rsRuleCnt; $i++) { |
|
| 6886 | 6886 | $rule = $ruleset->rules[$i]; |
| 6887 | 6887 | |
| 6888 | - if( $rule instanceof Less_Tree_Mixin_Call ){ |
|
| 6888 | + if ($rule instanceof Less_Tree_Mixin_Call) { |
|
| 6889 | 6889 | $rule = $rule->compile($env); |
| 6890 | 6890 | |
| 6891 | 6891 | $temp = array(); |
| 6892 | - foreach($rule as $r){ |
|
| 6893 | - if( ($r instanceof Less_Tree_Rule) && $r->variable ){ |
|
| 6892 | + foreach ($rule as $r) { |
|
| 6893 | + if (($r instanceof Less_Tree_Rule) && $r->variable) { |
|
| 6894 | 6894 | // do not pollute the scope if the variable is |
| 6895 | 6895 | // already there. consider returning false here |
| 6896 | 6896 | // but we need a way to "return" variable from mixins |
| 6897 | - if( !$ruleset->variable($r->name) ){ |
|
| 6897 | + if (!$ruleset->variable($r->name)) { |
|
| 6898 | 6898 | $temp[] = $r; |
| 6899 | 6899 | } |
| 6900 | - }else{ |
|
| 6900 | + }else { |
|
| 6901 | 6901 | $temp[] = $r; |
| 6902 | 6902 | } |
| 6903 | 6903 | } |
@@ -6907,12 +6907,12 @@ discard block |
||
| 6907 | 6907 | $i += $temp_count; |
| 6908 | 6908 | $ruleset->resetCache(); |
| 6909 | 6909 | |
| 6910 | - }elseif( $rule instanceof Less_Tree_RulesetCall ){ |
|
| 6910 | + }elseif ($rule instanceof Less_Tree_RulesetCall) { |
|
| 6911 | 6911 | |
| 6912 | 6912 | $rule = $rule->compile($env); |
| 6913 | 6913 | $rules = array(); |
| 6914 | - foreach($rule->rules as $r){ |
|
| 6915 | - if( ($r instanceof Less_Tree_Rule) && $r->variable ){ |
|
| 6914 | + foreach ($rule->rules as $r) { |
|
| 6915 | + if (($r instanceof Less_Tree_Rule) && $r->variable) { |
|
| 6916 | 6916 | continue; |
| 6917 | 6917 | } |
| 6918 | 6918 | $rules[] = $r; |
@@ -6920,7 +6920,7 @@ discard block |
||
| 6920 | 6920 | |
| 6921 | 6921 | array_splice($ruleset->rules, $i, 1, $rules); |
| 6922 | 6922 | $temp_count = count($rules); |
| 6923 | - $rsRuleCnt += $temp_count - 1; |
|
| 6923 | + $rsRuleCnt += $temp_count-1; |
|
| 6924 | 6924 | $i += $temp_count-1; |
| 6925 | 6925 | $ruleset->resetCache(); |
| 6926 | 6926 | } |
@@ -6933,29 +6933,29 @@ discard block |
||
| 6933 | 6933 | * Compile the selectors and create a new ruleset object for the compile() method |
| 6934 | 6934 | * |
| 6935 | 6935 | */ |
| 6936 | - private function PrepareRuleset($env){ |
|
| 6936 | + private function PrepareRuleset($env) { |
|
| 6937 | 6937 | |
| 6938 | 6938 | $hasOnePassingSelector = false; |
| 6939 | 6939 | $selectors = array(); |
| 6940 | - if( $this->selectors ){ |
|
| 6940 | + if ($this->selectors) { |
|
| 6941 | 6941 | Less_Tree_DefaultFunc::error("it is currently only allowed in parametric mixin guards,"); |
| 6942 | 6942 | |
| 6943 | - foreach($this->selectors as $s){ |
|
| 6943 | + foreach ($this->selectors as $s) { |
|
| 6944 | 6944 | $selector = $s->compile($env); |
| 6945 | 6945 | $selectors[] = $selector; |
| 6946 | - if( $selector->evaldCondition ){ |
|
| 6946 | + if ($selector->evaldCondition) { |
|
| 6947 | 6947 | $hasOnePassingSelector = true; |
| 6948 | 6948 | } |
| 6949 | 6949 | } |
| 6950 | 6950 | |
| 6951 | 6951 | Less_Tree_DefaultFunc::reset(); |
| 6952 | - } else { |
|
| 6952 | + }else { |
|
| 6953 | 6953 | $hasOnePassingSelector = true; |
| 6954 | 6954 | } |
| 6955 | 6955 | |
| 6956 | - if( $this->rules && $hasOnePassingSelector ){ |
|
| 6956 | + if ($this->rules && $hasOnePassingSelector) { |
|
| 6957 | 6957 | $rules = $this->rules; |
| 6958 | - }else{ |
|
| 6958 | + }else { |
|
| 6959 | 6959 | $rules = array(); |
| 6960 | 6960 | } |
| 6961 | 6961 | |
@@ -6973,7 +6973,7 @@ discard block |
||
| 6973 | 6973 | |
| 6974 | 6974 | |
| 6975 | 6975 | // Evaluate imports |
| 6976 | - if( $ruleset->root || $ruleset->allowImports || !$ruleset->strictImports ){ |
|
| 6976 | + if ($ruleset->root || $ruleset->allowImports || !$ruleset->strictImports) { |
|
| 6977 | 6977 | $ruleset->evalImports($env); |
| 6978 | 6978 | } |
| 6979 | 6979 | |
@@ -6983,17 +6983,17 @@ discard block |
||
| 6983 | 6983 | function evalImports($env) { |
| 6984 | 6984 | |
| 6985 | 6985 | $rules_len = count($this->rules); |
| 6986 | - for($i=0; $i < $rules_len; $i++){ |
|
| 6986 | + for ($i = 0; $i<$rules_len; $i++) { |
|
| 6987 | 6987 | $rule = $this->rules[$i]; |
| 6988 | 6988 | |
| 6989 | - if( $rule instanceof Less_Tree_Import ){ |
|
| 6989 | + if ($rule instanceof Less_Tree_Import) { |
|
| 6990 | 6990 | $rules = $rule->compile($env); |
| 6991 | - if( is_array($rules) ){ |
|
| 6991 | + if (is_array($rules)) { |
|
| 6992 | 6992 | array_splice($this->rules, $i, 1, $rules); |
| 6993 | 6993 | $temp_count = count($rules)-1; |
| 6994 | 6994 | $i += $temp_count; |
| 6995 | 6995 | $rules_len += $temp_count; |
| 6996 | - }else{ |
|
| 6996 | + }else { |
|
| 6997 | 6997 | array_splice($this->rules, $i, 1, array($rules)); |
| 6998 | 6998 | } |
| 6999 | 6999 | |
@@ -7002,67 +7002,67 @@ discard block |
||
| 7002 | 7002 | } |
| 7003 | 7003 | } |
| 7004 | 7004 | |
| 7005 | - function makeImportant(){ |
|
| 7005 | + function makeImportant() { |
|
| 7006 | 7006 | |
| 7007 | 7007 | $important_rules = array(); |
| 7008 | - foreach($this->rules as $rule){ |
|
| 7009 | - if( $rule instanceof Less_Tree_Rule || $rule instanceof Less_Tree_Ruleset ){ |
|
| 7008 | + foreach ($this->rules as $rule) { |
|
| 7009 | + if ($rule instanceof Less_Tree_Rule || $rule instanceof Less_Tree_Ruleset) { |
|
| 7010 | 7010 | $important_rules[] = $rule->makeImportant(); |
| 7011 | - }else{ |
|
| 7011 | + }else { |
|
| 7012 | 7012 | $important_rules[] = $rule; |
| 7013 | 7013 | } |
| 7014 | 7014 | } |
| 7015 | 7015 | |
| 7016 | - return new Less_Tree_Ruleset($this->selectors, $important_rules, $this->strictImports ); |
|
| 7016 | + return new Less_Tree_Ruleset($this->selectors, $important_rules, $this->strictImports); |
|
| 7017 | 7017 | } |
| 7018 | 7018 | |
| 7019 | - public function matchArgs($args){ |
|
| 7019 | + public function matchArgs($args) { |
|
| 7020 | 7020 | return !$args; |
| 7021 | 7021 | } |
| 7022 | 7022 | |
| 7023 | 7023 | // lets you call a css selector with a guard |
| 7024 | - public function matchCondition( $args, $env ){ |
|
| 7024 | + public function matchCondition($args, $env) { |
|
| 7025 | 7025 | $lastSelector = end($this->selectors); |
| 7026 | 7026 | |
| 7027 | - if( !$lastSelector->evaldCondition ){ |
|
| 7027 | + if (!$lastSelector->evaldCondition) { |
|
| 7028 | 7028 | return false; |
| 7029 | 7029 | } |
| 7030 | - if( $lastSelector->condition && !$lastSelector->condition->compile( $env->copyEvalEnv( $env->frames ) ) ){ |
|
| 7030 | + if ($lastSelector->condition && !$lastSelector->condition->compile($env->copyEvalEnv($env->frames))) { |
|
| 7031 | 7031 | return false; |
| 7032 | 7032 | } |
| 7033 | 7033 | return true; |
| 7034 | 7034 | } |
| 7035 | 7035 | |
| 7036 | - function resetCache(){ |
|
| 7036 | + function resetCache() { |
|
| 7037 | 7037 | $this->_rulesets = null; |
| 7038 | 7038 | $this->_variables = null; |
| 7039 | 7039 | $this->lookups = array(); |
| 7040 | 7040 | } |
| 7041 | 7041 | |
| 7042 | - public function variables(){ |
|
| 7042 | + public function variables() { |
|
| 7043 | 7043 | $this->_variables = array(); |
| 7044 | - foreach( $this->rules as $r){ |
|
| 7045 | - if ($r instanceof Less_Tree_Rule && $r->variable === true) { |
|
| 7044 | + foreach ($this->rules as $r) { |
|
| 7045 | + if ($r instanceof Less_Tree_Rule && $r->variable===true) { |
|
| 7046 | 7046 | $this->_variables[$r->name] = $r; |
| 7047 | 7047 | } |
| 7048 | 7048 | } |
| 7049 | 7049 | } |
| 7050 | 7050 | |
| 7051 | - public function variable($name){ |
|
| 7051 | + public function variable($name) { |
|
| 7052 | 7052 | |
| 7053 | - if( is_null($this->_variables) ){ |
|
| 7053 | + if (is_null($this->_variables)) { |
|
| 7054 | 7054 | $this->variables(); |
| 7055 | 7055 | } |
| 7056 | 7056 | return isset($this->_variables[$name]) ? $this->_variables[$name] : null; |
| 7057 | 7057 | } |
| 7058 | 7058 | |
| 7059 | - public function find( $selector, $self = null ){ |
|
| 7059 | + public function find($selector, $self = null) { |
|
| 7060 | 7060 | |
| 7061 | - $key = implode(' ',$selector->_oelements); |
|
| 7061 | + $key = implode(' ', $selector->_oelements); |
|
| 7062 | 7062 | |
| 7063 | - if( !isset($this->lookups[$key]) ){ |
|
| 7063 | + if (!isset($this->lookups[$key])) { |
|
| 7064 | 7064 | |
| 7065 | - if( !$self ){ |
|
| 7065 | + if (!$self) { |
|
| 7066 | 7066 | $self = $this->ruleset_id; |
| 7067 | 7067 | } |
| 7068 | 7068 | |
@@ -7070,17 +7070,17 @@ discard block |
||
| 7070 | 7070 | |
| 7071 | 7071 | $first_oelement = $selector->_oelements[0]; |
| 7072 | 7072 | |
| 7073 | - foreach($this->rules as $rule){ |
|
| 7074 | - if( $rule instanceof Less_Tree_Ruleset && $rule->ruleset_id != $self ){ |
|
| 7073 | + foreach ($this->rules as $rule) { |
|
| 7074 | + if ($rule instanceof Less_Tree_Ruleset && $rule->ruleset_id!=$self) { |
|
| 7075 | 7075 | |
| 7076 | - if( isset($rule->first_oelements[$first_oelement]) ){ |
|
| 7076 | + if (isset($rule->first_oelements[$first_oelement])) { |
|
| 7077 | 7077 | |
| 7078 | - foreach( $rule->selectors as $ruleSelector ){ |
|
| 7078 | + foreach ($rule->selectors as $ruleSelector) { |
|
| 7079 | 7079 | $match = $selector->match($ruleSelector); |
| 7080 | - if( $match ){ |
|
| 7081 | - if( $selector->elements_len > $match ){ |
|
| 7082 | - $this->lookups[$key] = array_merge($this->lookups[$key], $rule->find( new Less_Tree_Selector(array_slice($selector->elements, $match)), $self)); |
|
| 7083 | - } else { |
|
| 7080 | + if ($match) { |
|
| 7081 | + if ($selector->elements_len>$match) { |
|
| 7082 | + $this->lookups[$key] = array_merge($this->lookups[$key], $rule->find(new Less_Tree_Selector(array_slice($selector->elements, $match)), $self)); |
|
| 7083 | + }else { |
|
| 7084 | 7084 | $this->lookups[$key][] = $rule; |
| 7085 | 7085 | } |
| 7086 | 7086 | break; |
@@ -7098,18 +7098,18 @@ discard block |
||
| 7098 | 7098 | /** |
| 7099 | 7099 | * @see Less_Tree::genCSS |
| 7100 | 7100 | */ |
| 7101 | - public function genCSS( $output ){ |
|
| 7101 | + public function genCSS($output) { |
|
| 7102 | 7102 | |
| 7103 | - if( !$this->root ){ |
|
| 7103 | + if (!$this->root) { |
|
| 7104 | 7104 | Less_Environment::$tabLevel++; |
| 7105 | 7105 | } |
| 7106 | 7106 | |
| 7107 | 7107 | $tabRuleStr = $tabSetStr = ''; |
| 7108 | - if( !Less_Parser::$options['compress'] ){ |
|
| 7109 | - if( Less_Environment::$tabLevel ){ |
|
| 7110 | - $tabRuleStr = "\n".str_repeat( ' ' , Less_Environment::$tabLevel ); |
|
| 7111 | - $tabSetStr = "\n".str_repeat( ' ' , Less_Environment::$tabLevel-1 ); |
|
| 7112 | - }else{ |
|
| 7108 | + if (!Less_Parser::$options['compress']) { |
|
| 7109 | + if (Less_Environment::$tabLevel) { |
|
| 7110 | + $tabRuleStr = "\n".str_repeat(' ', Less_Environment::$tabLevel); |
|
| 7111 | + $tabSetStr = "\n".str_repeat(' ', Less_Environment::$tabLevel-1); |
|
| 7112 | + }else { |
|
| 7113 | 7113 | $tabSetStr = $tabRuleStr = "\n"; |
| 7114 | 7114 | } |
| 7115 | 7115 | } |
@@ -7117,19 +7117,19 @@ discard block |
||
| 7117 | 7117 | |
| 7118 | 7118 | $ruleNodes = array(); |
| 7119 | 7119 | $rulesetNodes = array(); |
| 7120 | - foreach($this->rules as $rule){ |
|
| 7120 | + foreach ($this->rules as $rule) { |
|
| 7121 | 7121 | |
| 7122 | 7122 | $class = get_class($rule); |
| 7123 | - if( ($class === 'Less_Tree_Media') || ($class === 'Less_Tree_Directive') || ($this->root && $class === 'Less_Tree_Comment') || ($class === 'Less_Tree_Ruleset' && $rule->rules) ){ |
|
| 7123 | + if (($class==='Less_Tree_Media') || ($class==='Less_Tree_Directive') || ($this->root && $class==='Less_Tree_Comment') || ($class==='Less_Tree_Ruleset' && $rule->rules)) { |
|
| 7124 | 7124 | $rulesetNodes[] = $rule; |
| 7125 | - }else{ |
|
| 7125 | + }else { |
|
| 7126 | 7126 | $ruleNodes[] = $rule; |
| 7127 | 7127 | } |
| 7128 | 7128 | } |
| 7129 | 7129 | |
| 7130 | 7130 | // If this is the root node, we don't render |
| 7131 | 7131 | // a selector, or {}. |
| 7132 | - if( !$this->root ){ |
|
| 7132 | + if (!$this->root) { |
|
| 7133 | 7133 | |
| 7134 | 7134 | /* |
| 7135 | 7135 | debugInfo = tree.debugInfo(env, this, tabSetStr); |
@@ -7141,102 +7141,102 @@ discard block |
||
| 7141 | 7141 | */ |
| 7142 | 7142 | |
| 7143 | 7143 | $paths_len = count($this->paths); |
| 7144 | - for( $i = 0; $i < $paths_len; $i++ ){ |
|
| 7144 | + for ($i = 0; $i<$paths_len; $i++) { |
|
| 7145 | 7145 | $path = $this->paths[$i]; |
| 7146 | 7146 | $firstSelector = true; |
| 7147 | 7147 | |
| 7148 | - foreach($path as $p){ |
|
| 7149 | - $p->genCSS( $output, $firstSelector ); |
|
| 7148 | + foreach ($path as $p) { |
|
| 7149 | + $p->genCSS($output, $firstSelector); |
|
| 7150 | 7150 | $firstSelector = false; |
| 7151 | 7151 | } |
| 7152 | 7152 | |
| 7153 | - if( $i + 1 < $paths_len ){ |
|
| 7154 | - $output->add( ',' . $tabSetStr ); |
|
| 7153 | + if ($i+1<$paths_len) { |
|
| 7154 | + $output->add(','.$tabSetStr); |
|
| 7155 | 7155 | } |
| 7156 | 7156 | } |
| 7157 | 7157 | |
| 7158 | - $output->add( (Less_Parser::$options['compress'] ? '{' : " {") . $tabRuleStr ); |
|
| 7158 | + $output->add((Less_Parser::$options['compress'] ? '{' : " {").$tabRuleStr); |
|
| 7159 | 7159 | } |
| 7160 | 7160 | |
| 7161 | 7161 | // Compile rules and rulesets |
| 7162 | 7162 | $ruleNodes_len = count($ruleNodes); |
| 7163 | 7163 | $rulesetNodes_len = count($rulesetNodes); |
| 7164 | - for( $i = 0; $i < $ruleNodes_len; $i++ ){ |
|
| 7164 | + for ($i = 0; $i<$ruleNodes_len; $i++) { |
|
| 7165 | 7165 | $rule = $ruleNodes[$i]; |
| 7166 | 7166 | |
| 7167 | 7167 | // @page{ directive ends up with root elements inside it, a mix of rules and rulesets |
| 7168 | 7168 | // In this instance we do not know whether it is the last property |
| 7169 | - if( $i + 1 === $ruleNodes_len && (!$this->root || $rulesetNodes_len === 0 || $this->firstRoot ) ){ |
|
| 7169 | + if ($i+1===$ruleNodes_len && (!$this->root || $rulesetNodes_len===0 || $this->firstRoot)) { |
|
| 7170 | 7170 | Less_Environment::$lastRule = true; |
| 7171 | 7171 | } |
| 7172 | 7172 | |
| 7173 | - $rule->genCSS( $output ); |
|
| 7173 | + $rule->genCSS($output); |
|
| 7174 | 7174 | |
| 7175 | - if( !Less_Environment::$lastRule ){ |
|
| 7176 | - $output->add( $tabRuleStr ); |
|
| 7177 | - }else{ |
|
| 7175 | + if (!Less_Environment::$lastRule) { |
|
| 7176 | + $output->add($tabRuleStr); |
|
| 7177 | + }else { |
|
| 7178 | 7178 | Less_Environment::$lastRule = false; |
| 7179 | 7179 | } |
| 7180 | 7180 | } |
| 7181 | 7181 | |
| 7182 | - if( !$this->root ){ |
|
| 7183 | - $output->add( $tabSetStr . '}' ); |
|
| 7182 | + if (!$this->root) { |
|
| 7183 | + $output->add($tabSetStr.'}'); |
|
| 7184 | 7184 | Less_Environment::$tabLevel--; |
| 7185 | 7185 | } |
| 7186 | 7186 | |
| 7187 | 7187 | $firstRuleset = true; |
| 7188 | 7188 | $space = ($this->root ? $tabRuleStr : $tabSetStr); |
| 7189 | - for( $i = 0; $i < $rulesetNodes_len; $i++ ){ |
|
| 7189 | + for ($i = 0; $i<$rulesetNodes_len; $i++) { |
|
| 7190 | 7190 | |
| 7191 | - if( $ruleNodes_len && $firstRuleset ){ |
|
| 7192 | - $output->add( $space ); |
|
| 7193 | - }elseif( !$firstRuleset ){ |
|
| 7194 | - $output->add( $space ); |
|
| 7191 | + if ($ruleNodes_len && $firstRuleset) { |
|
| 7192 | + $output->add($space); |
|
| 7193 | + }elseif (!$firstRuleset) { |
|
| 7194 | + $output->add($space); |
|
| 7195 | 7195 | } |
| 7196 | 7196 | $firstRuleset = false; |
| 7197 | - $rulesetNodes[$i]->genCSS( $output); |
|
| 7197 | + $rulesetNodes[$i]->genCSS($output); |
|
| 7198 | 7198 | } |
| 7199 | 7199 | |
| 7200 | - if( !Less_Parser::$options['compress'] && $this->firstRoot ){ |
|
| 7201 | - $output->add( "\n" ); |
|
| 7200 | + if (!Less_Parser::$options['compress'] && $this->firstRoot) { |
|
| 7201 | + $output->add("\n"); |
|
| 7202 | 7202 | } |
| 7203 | 7203 | |
| 7204 | 7204 | } |
| 7205 | 7205 | |
| 7206 | 7206 | |
| 7207 | - function markReferenced(){ |
|
| 7208 | - if( !$this->selectors ){ |
|
| 7207 | + function markReferenced() { |
|
| 7208 | + if (!$this->selectors) { |
|
| 7209 | 7209 | return; |
| 7210 | 7210 | } |
| 7211 | - foreach($this->selectors as $selector){ |
|
| 7211 | + foreach ($this->selectors as $selector) { |
|
| 7212 | 7212 | $selector->markReferenced(); |
| 7213 | 7213 | } |
| 7214 | 7214 | } |
| 7215 | 7215 | |
| 7216 | - public function joinSelectors( $context, $selectors ){ |
|
| 7216 | + public function joinSelectors($context, $selectors) { |
|
| 7217 | 7217 | $paths = array(); |
| 7218 | - if( is_array($selectors) ){ |
|
| 7219 | - foreach($selectors as $selector) { |
|
| 7220 | - $this->joinSelector( $paths, $context, $selector); |
|
| 7218 | + if (is_array($selectors)) { |
|
| 7219 | + foreach ($selectors as $selector) { |
|
| 7220 | + $this->joinSelector($paths, $context, $selector); |
|
| 7221 | 7221 | } |
| 7222 | 7222 | } |
| 7223 | 7223 | return $paths; |
| 7224 | 7224 | } |
| 7225 | 7225 | |
| 7226 | - public function joinSelector( &$paths, $context, $selector){ |
|
| 7226 | + public function joinSelector(&$paths, $context, $selector) { |
|
| 7227 | 7227 | |
| 7228 | 7228 | $hasParentSelector = false; |
| 7229 | 7229 | |
| 7230 | - foreach($selector->elements as $el) { |
|
| 7231 | - if( $el->value === '&') { |
|
| 7230 | + foreach ($selector->elements as $el) { |
|
| 7231 | + if ($el->value==='&') { |
|
| 7232 | 7232 | $hasParentSelector = true; |
| 7233 | 7233 | } |
| 7234 | 7234 | } |
| 7235 | 7235 | |
| 7236 | - if( !$hasParentSelector ){ |
|
| 7237 | - if( $context ){ |
|
| 7238 | - foreach($context as $context_el){ |
|
| 7239 | - $paths[] = array_merge($context_el, array($selector) ); |
|
| 7236 | + if (!$hasParentSelector) { |
|
| 7237 | + if ($context) { |
|
| 7238 | + foreach ($context as $context_el) { |
|
| 7239 | + $paths[] = array_merge($context_el, array($selector)); |
|
| 7240 | 7240 | } |
| 7241 | 7241 | }else { |
| 7242 | 7242 | $paths[] = array($selector); |
@@ -7264,38 +7264,38 @@ discard block |
||
| 7264 | 7264 | $newSelectors = array(array()); |
| 7265 | 7265 | |
| 7266 | 7266 | |
| 7267 | - foreach( $selector->elements as $el){ |
|
| 7267 | + foreach ($selector->elements as $el) { |
|
| 7268 | 7268 | |
| 7269 | 7269 | // non parent reference elements just get added |
| 7270 | - if( $el->value !== '&' ){ |
|
| 7270 | + if ($el->value!=='&') { |
|
| 7271 | 7271 | $currentElements[] = $el; |
| 7272 | - } else { |
|
| 7272 | + }else { |
|
| 7273 | 7273 | // the new list of selectors to add |
| 7274 | 7274 | $selectorsMultiplied = array(); |
| 7275 | 7275 | |
| 7276 | 7276 | // merge the current list of non parent selector elements |
| 7277 | 7277 | // on to the current list of selectors to add |
| 7278 | - if( $currentElements ){ |
|
| 7279 | - $this->mergeElementsOnToSelectors( $currentElements, $newSelectors); |
|
| 7278 | + if ($currentElements) { |
|
| 7279 | + $this->mergeElementsOnToSelectors($currentElements, $newSelectors); |
|
| 7280 | 7280 | } |
| 7281 | 7281 | |
| 7282 | 7282 | // loop through our current selectors |
| 7283 | - foreach($newSelectors as $sel){ |
|
| 7283 | + foreach ($newSelectors as $sel) { |
|
| 7284 | 7284 | |
| 7285 | 7285 | // if we don't have any parent paths, the & might be in a mixin so that it can be used |
| 7286 | 7286 | // whether there are parents or not |
| 7287 | - if( !$context ){ |
|
| 7287 | + if (!$context) { |
|
| 7288 | 7288 | // the combinator used on el should now be applied to the next element instead so that |
| 7289 | 7289 | // it is not lost |
| 7290 | - if( $sel ){ |
|
| 7291 | - $sel[0]->elements = array_slice($sel[0]->elements,0); |
|
| 7292 | - $sel[0]->elements[] = new Less_Tree_Element($el->combinator, '', $el->index, $el->currentFileInfo ); |
|
| 7290 | + if ($sel) { |
|
| 7291 | + $sel[0]->elements = array_slice($sel[0]->elements, 0); |
|
| 7292 | + $sel[0]->elements[] = new Less_Tree_Element($el->combinator, '', $el->index, $el->currentFileInfo); |
|
| 7293 | 7293 | } |
| 7294 | 7294 | $selectorsMultiplied[] = $sel; |
| 7295 | 7295 | }else { |
| 7296 | 7296 | |
| 7297 | 7297 | // and the parent selectors |
| 7298 | - foreach($context as $parentSel){ |
|
| 7298 | + foreach ($context as $parentSel) { |
|
| 7299 | 7299 | // We need to put the current selectors |
| 7300 | 7300 | // then join the last selector's elements on to the parents selectors |
| 7301 | 7301 | |
@@ -7307,10 +7307,10 @@ discard block |
||
| 7307 | 7307 | |
| 7308 | 7308 | //construct the joined selector - if & is the first thing this will be empty, |
| 7309 | 7309 | // if not newJoinedSelector will be the last set of elements in the selector |
| 7310 | - if( $sel ){ |
|
| 7310 | + if ($sel) { |
|
| 7311 | 7311 | $newSelectorPath = $sel; |
| 7312 | 7312 | $lastSelector = array_pop($newSelectorPath); |
| 7313 | - $newJoinedSelector = $selector->createDerived( array_slice($lastSelector->elements,0) ); |
|
| 7313 | + $newJoinedSelector = $selector->createDerived(array_slice($lastSelector->elements, 0)); |
|
| 7314 | 7314 | $newJoinedSelectorEmpty = false; |
| 7315 | 7315 | } |
| 7316 | 7316 | else { |
@@ -7318,17 +7318,17 @@ discard block |
||
| 7318 | 7318 | } |
| 7319 | 7319 | |
| 7320 | 7320 | //put together the parent selectors after the join |
| 7321 | - if ( count($parentSel) > 1) { |
|
| 7322 | - $afterParentJoin = array_merge($afterParentJoin, array_slice($parentSel,1) ); |
|
| 7321 | + if (count($parentSel)>1) { |
|
| 7322 | + $afterParentJoin = array_merge($afterParentJoin, array_slice($parentSel, 1)); |
|
| 7323 | 7323 | } |
| 7324 | 7324 | |
| 7325 | - if ( $parentSel ){ |
|
| 7325 | + if ($parentSel) { |
|
| 7326 | 7326 | $newJoinedSelectorEmpty = false; |
| 7327 | 7327 | |
| 7328 | 7328 | // join the elements so far with the first part of the parent |
| 7329 | - $newJoinedSelector->elements[] = new Less_Tree_Element( $el->combinator, $parentSel[0]->elements[0]->value, $el->index, $el->currentFileInfo); |
|
| 7329 | + $newJoinedSelector->elements[] = new Less_Tree_Element($el->combinator, $parentSel[0]->elements[0]->value, $el->index, $el->currentFileInfo); |
|
| 7330 | 7330 | |
| 7331 | - $newJoinedSelector->elements = array_merge( $newJoinedSelector->elements, array_slice($parentSel[0]->elements, 1) ); |
|
| 7331 | + $newJoinedSelector->elements = array_merge($newJoinedSelector->elements, array_slice($parentSel[0]->elements, 1)); |
|
| 7332 | 7332 | } |
| 7333 | 7333 | |
| 7334 | 7334 | if (!$newJoinedSelectorEmpty) { |
@@ -7353,32 +7353,32 @@ discard block |
||
| 7353 | 7353 | |
| 7354 | 7354 | // if we have any elements left over (e.g. .a& .b == .b) |
| 7355 | 7355 | // add them on to all the current selectors |
| 7356 | - if( $currentElements ){ |
|
| 7356 | + if ($currentElements) { |
|
| 7357 | 7357 | $this->mergeElementsOnToSelectors($currentElements, $newSelectors); |
| 7358 | 7358 | } |
| 7359 | - foreach( $newSelectors as $new_sel){ |
|
| 7360 | - if( $new_sel ){ |
|
| 7359 | + foreach ($newSelectors as $new_sel) { |
|
| 7360 | + if ($new_sel) { |
|
| 7361 | 7361 | $paths[] = $new_sel; |
| 7362 | 7362 | } |
| 7363 | 7363 | } |
| 7364 | 7364 | } |
| 7365 | 7365 | |
| 7366 | - function mergeElementsOnToSelectors( $elements, &$selectors){ |
|
| 7366 | + function mergeElementsOnToSelectors($elements, &$selectors) { |
|
| 7367 | 7367 | |
| 7368 | - if( !$selectors ){ |
|
| 7369 | - $selectors[] = array( new Less_Tree_Selector($elements) ); |
|
| 7368 | + if (!$selectors) { |
|
| 7369 | + $selectors[] = array(new Less_Tree_Selector($elements)); |
|
| 7370 | 7370 | return; |
| 7371 | 7371 | } |
| 7372 | 7372 | |
| 7373 | 7373 | |
| 7374 | - foreach( $selectors as &$sel){ |
|
| 7374 | + foreach ($selectors as &$sel) { |
|
| 7375 | 7375 | |
| 7376 | 7376 | // if the previous thing in sel is a parent this needs to join on to it |
| 7377 | - if( $sel ){ |
|
| 7377 | + if ($sel) { |
|
| 7378 | 7378 | $last = count($sel)-1; |
| 7379 | - $sel[$last] = $sel[$last]->createDerived( array_merge($sel[$last]->elements, $elements) ); |
|
| 7380 | - }else{ |
|
| 7381 | - $sel[] = new Less_Tree_Selector( $elements ); |
|
| 7379 | + $sel[$last] = $sel[$last]->createDerived(array_merge($sel[$last]->elements, $elements)); |
|
| 7380 | + }else { |
|
| 7381 | + $sel[] = new Less_Tree_Selector($elements); |
|
| 7382 | 7382 | } |
| 7383 | 7383 | } |
| 7384 | 7384 | } |
@@ -7391,18 +7391,18 @@ discard block |
||
| 7391 | 7391 | * @package Less |
| 7392 | 7392 | * @subpackage tree |
| 7393 | 7393 | */ |
| 7394 | -class Less_Tree_RulesetCall extends Less_Tree{ |
|
| 7394 | +class Less_Tree_RulesetCall extends Less_Tree { |
|
| 7395 | 7395 | |
| 7396 | 7396 | public $variable; |
| 7397 | 7397 | public $type = "RulesetCall"; |
| 7398 | 7398 | |
| 7399 | - public function __construct($variable){ |
|
| 7399 | + public function __construct($variable) { |
|
| 7400 | 7400 | $this->variable = $variable; |
| 7401 | 7401 | } |
| 7402 | 7402 | |
| 7403 | 7403 | public function accept($visitor) {} |
| 7404 | 7404 | |
| 7405 | - public function compile( $env ){ |
|
| 7405 | + public function compile($env) { |
|
| 7406 | 7406 | $variable = new Less_Tree_Variable($this->variable); |
| 7407 | 7407 | $detachedRuleset = $variable->compile($env); |
| 7408 | 7408 | return $detachedRuleset->callEval($env); |
@@ -7417,7 +7417,7 @@ discard block |
||
| 7417 | 7417 | * @package Less |
| 7418 | 7418 | * @subpackage tree |
| 7419 | 7419 | */ |
| 7420 | -class Less_Tree_Selector extends Less_Tree{ |
|
| 7420 | +class Less_Tree_Selector extends Less_Tree { |
|
| 7421 | 7421 | |
| 7422 | 7422 | public $elements; |
| 7423 | 7423 | public $condition; |
@@ -7439,17 +7439,17 @@ discard block |
||
| 7439 | 7439 | /** |
| 7440 | 7440 | * @param boolean $isReferenced |
| 7441 | 7441 | */ |
| 7442 | - public function __construct( $elements, $extendList = array() , $condition = null, $index=null, $currentFileInfo=null, $isReferenced=null ){ |
|
| 7442 | + public function __construct($elements, $extendList = array(), $condition = null, $index = null, $currentFileInfo = null, $isReferenced = null) { |
|
| 7443 | 7443 | |
| 7444 | 7444 | $this->elements = $elements; |
| 7445 | 7445 | $this->elements_len = count($elements); |
| 7446 | 7446 | $this->extendList = $extendList; |
| 7447 | 7447 | $this->condition = $condition; |
| 7448 | - if( $currentFileInfo ){ |
|
| 7448 | + if ($currentFileInfo) { |
|
| 7449 | 7449 | $this->currentFileInfo = $currentFileInfo; |
| 7450 | 7450 | } |
| 7451 | 7451 | $this->isReferenced = $isReferenced; |
| 7452 | - if( !$condition ){ |
|
| 7452 | + if (!$condition) { |
|
| 7453 | 7453 | $this->evaldCondition = true; |
| 7454 | 7454 | } |
| 7455 | 7455 | |
@@ -7459,30 +7459,30 @@ discard block |
||
| 7459 | 7459 | public function accept($visitor) { |
| 7460 | 7460 | $this->elements = $visitor->visitArray($this->elements); |
| 7461 | 7461 | $this->extendList = $visitor->visitArray($this->extendList); |
| 7462 | - if( $this->condition ){ |
|
| 7462 | + if ($this->condition) { |
|
| 7463 | 7463 | $this->condition = $visitor->visitObj($this->condition); |
| 7464 | 7464 | } |
| 7465 | 7465 | |
| 7466 | - if( $visitor instanceof Less_Visitor_extendFinder ){ |
|
| 7466 | + if ($visitor instanceof Less_Visitor_extendFinder) { |
|
| 7467 | 7467 | $this->CacheElements(); |
| 7468 | 7468 | } |
| 7469 | 7469 | } |
| 7470 | 7470 | |
| 7471 | - public function createDerived( $elements, $extendList = null, $evaldCondition = null ){ |
|
| 7472 | - $newSelector = new Less_Tree_Selector( $elements, ($extendList ? $extendList : $this->extendList), null, $this->index, $this->currentFileInfo, $this->isReferenced); |
|
| 7471 | + public function createDerived($elements, $extendList = null, $evaldCondition = null) { |
|
| 7472 | + $newSelector = new Less_Tree_Selector($elements, ($extendList ? $extendList : $this->extendList), null, $this->index, $this->currentFileInfo, $this->isReferenced); |
|
| 7473 | 7473 | $newSelector->evaldCondition = $evaldCondition ? $evaldCondition : $this->evaldCondition; |
| 7474 | 7474 | return $newSelector; |
| 7475 | 7475 | } |
| 7476 | 7476 | |
| 7477 | 7477 | |
| 7478 | - public function match( $other ){ |
|
| 7478 | + public function match($other) { |
|
| 7479 | 7479 | |
| 7480 | - if( !$other->_oelements || ($this->elements_len < $other->_oelements_len) ){ |
|
| 7480 | + if (!$other->_oelements || ($this->elements_len<$other->_oelements_len)) { |
|
| 7481 | 7481 | return 0; |
| 7482 | 7482 | } |
| 7483 | 7483 | |
| 7484 | - for( $i = 0; $i < $other->_oelements_len; $i++ ){ |
|
| 7485 | - if( $this->elements[$i]->value !== $other->_oelements[$i]) { |
|
| 7484 | + for ($i = 0; $i<$other->_oelements_len; $i++) { |
|
| 7485 | + if ($this->elements[$i]->value!==$other->_oelements[$i]) { |
|
| 7486 | 7486 | return 0; |
| 7487 | 7487 | } |
| 7488 | 7488 | } |
@@ -7491,20 +7491,20 @@ discard block |
||
| 7491 | 7491 | } |
| 7492 | 7492 | |
| 7493 | 7493 | |
| 7494 | - public function CacheElements(){ |
|
| 7494 | + public function CacheElements() { |
|
| 7495 | 7495 | |
| 7496 | 7496 | $this->_oelements = array(); |
| 7497 | 7497 | $css = ''; |
| 7498 | 7498 | |
| 7499 | - foreach($this->elements as $v){ |
|
| 7499 | + foreach ($this->elements as $v) { |
|
| 7500 | 7500 | |
| 7501 | 7501 | $css .= $v->combinator; |
| 7502 | - if( !$v->value_is_object ){ |
|
| 7502 | + if (!$v->value_is_object) { |
|
| 7503 | 7503 | $css .= $v->value; |
| 7504 | 7504 | continue; |
| 7505 | 7505 | } |
| 7506 | 7506 | |
| 7507 | - if( !property_exists($v->value,'value') || !is_string($v->value->value) ){ |
|
| 7507 | + if (!property_exists($v->value, 'value') || !is_string($v->value->value)) { |
|
| 7508 | 7508 | $this->cacheable = false; |
| 7509 | 7509 | return; |
| 7510 | 7510 | } |
@@ -7512,67 +7512,67 @@ discard block |
||
| 7512 | 7512 | } |
| 7513 | 7513 | |
| 7514 | 7514 | $this->_oelements_len = preg_match_all('/[,&#\.\w-](?:[\w-]|(?:\\\\.))*/', $css, $matches); |
| 7515 | - if( $this->_oelements_len ){ |
|
| 7515 | + if ($this->_oelements_len) { |
|
| 7516 | 7516 | $this->_oelements = $matches[0]; |
| 7517 | 7517 | |
| 7518 | - if( $this->_oelements[0] === '&' ){ |
|
| 7518 | + if ($this->_oelements[0]==='&') { |
|
| 7519 | 7519 | array_shift($this->_oelements); |
| 7520 | 7520 | $this->_oelements_len--; |
| 7521 | 7521 | } |
| 7522 | 7522 | } |
| 7523 | 7523 | } |
| 7524 | 7524 | |
| 7525 | - public function isJustParentSelector(){ |
|
| 7525 | + public function isJustParentSelector() { |
|
| 7526 | 7526 | return !$this->mediaEmpty && |
| 7527 | - count($this->elements) === 1 && |
|
| 7528 | - $this->elements[0]->value === '&' && |
|
| 7529 | - ($this->elements[0]->combinator === ' ' || $this->elements[0]->combinator === ''); |
|
| 7527 | + count($this->elements)===1 && |
|
| 7528 | + $this->elements[0]->value==='&' && |
|
| 7529 | + ($this->elements[0]->combinator===' ' || $this->elements[0]->combinator===''); |
|
| 7530 | 7530 | } |
| 7531 | 7531 | |
| 7532 | 7532 | public function compile($env) { |
| 7533 | 7533 | |
| 7534 | 7534 | $elements = array(); |
| 7535 | - foreach($this->elements as $el){ |
|
| 7535 | + foreach ($this->elements as $el) { |
|
| 7536 | 7536 | $elements[] = $el->compile($env); |
| 7537 | 7537 | } |
| 7538 | 7538 | |
| 7539 | 7539 | $extendList = array(); |
| 7540 | - foreach($this->extendList as $el){ |
|
| 7540 | + foreach ($this->extendList as $el) { |
|
| 7541 | 7541 | $extendList[] = $el->compile($el); |
| 7542 | 7542 | } |
| 7543 | 7543 | |
| 7544 | 7544 | $evaldCondition = false; |
| 7545 | - if( $this->condition ){ |
|
| 7545 | + if ($this->condition) { |
|
| 7546 | 7546 | $evaldCondition = $this->condition->compile($env); |
| 7547 | 7547 | } |
| 7548 | 7548 | |
| 7549 | - return $this->createDerived( $elements, $extendList, $evaldCondition ); |
|
| 7549 | + return $this->createDerived($elements, $extendList, $evaldCondition); |
|
| 7550 | 7550 | } |
| 7551 | 7551 | |
| 7552 | 7552 | |
| 7553 | 7553 | /** |
| 7554 | 7554 | * @see Less_Tree::genCSS |
| 7555 | 7555 | */ |
| 7556 | - public function genCSS( $output, $firstSelector = true ){ |
|
| 7556 | + public function genCSS($output, $firstSelector = true) { |
|
| 7557 | 7557 | |
| 7558 | - if( !$firstSelector && $this->elements[0]->combinator === "" ){ |
|
| 7558 | + if (!$firstSelector && $this->elements[0]->combinator==="") { |
|
| 7559 | 7559 | $output->add(' ', $this->currentFileInfo, $this->index); |
| 7560 | 7560 | } |
| 7561 | 7561 | |
| 7562 | - foreach($this->elements as $element){ |
|
| 7563 | - $element->genCSS( $output ); |
|
| 7562 | + foreach ($this->elements as $element) { |
|
| 7563 | + $element->genCSS($output); |
|
| 7564 | 7564 | } |
| 7565 | 7565 | } |
| 7566 | 7566 | |
| 7567 | - public function markReferenced(){ |
|
| 7567 | + public function markReferenced() { |
|
| 7568 | 7568 | $this->isReferenced = true; |
| 7569 | 7569 | } |
| 7570 | 7570 | |
| 7571 | - public function getIsReferenced(){ |
|
| 7571 | + public function getIsReferenced() { |
|
| 7572 | 7572 | return !isset($this->currentFileInfo['reference']) || !$this->currentFileInfo['reference'] || $this->isReferenced; |
| 7573 | 7573 | } |
| 7574 | 7574 | |
| 7575 | - public function getIsOutput(){ |
|
| 7575 | + public function getIsOutput() { |
|
| 7576 | 7576 | return $this->evaldCondition; |
| 7577 | 7577 | } |
| 7578 | 7578 | |
@@ -7585,23 +7585,23 @@ discard block |
||
| 7585 | 7585 | * @package Less |
| 7586 | 7586 | * @subpackage tree |
| 7587 | 7587 | */ |
| 7588 | -class Less_Tree_UnicodeDescriptor extends Less_Tree{ |
|
| 7588 | +class Less_Tree_UnicodeDescriptor extends Less_Tree { |
|
| 7589 | 7589 | |
| 7590 | 7590 | public $value; |
| 7591 | 7591 | public $type = 'UnicodeDescriptor'; |
| 7592 | 7592 | |
| 7593 | - public function __construct($value){ |
|
| 7593 | + public function __construct($value) { |
|
| 7594 | 7594 | $this->value = $value; |
| 7595 | 7595 | } |
| 7596 | 7596 | |
| 7597 | 7597 | /** |
| 7598 | 7598 | * @see Less_Tree::genCSS |
| 7599 | 7599 | */ |
| 7600 | - public function genCSS( $output ){ |
|
| 7601 | - $output->add( $this->value ); |
|
| 7600 | + public function genCSS($output) { |
|
| 7601 | + $output->add($this->value); |
|
| 7602 | 7602 | } |
| 7603 | 7603 | |
| 7604 | - public function compile(){ |
|
| 7604 | + public function compile() { |
|
| 7605 | 7605 | return $this; |
| 7606 | 7606 | } |
| 7607 | 7607 | } |
@@ -7614,46 +7614,46 @@ discard block |
||
| 7614 | 7614 | * @package Less |
| 7615 | 7615 | * @subpackage tree |
| 7616 | 7616 | */ |
| 7617 | -class Less_Tree_Unit extends Less_Tree{ |
|
| 7617 | +class Less_Tree_Unit extends Less_Tree { |
|
| 7618 | 7618 | |
| 7619 | 7619 | var $numerator = array(); |
| 7620 | 7620 | var $denominator = array(); |
| 7621 | 7621 | public $backupUnit; |
| 7622 | 7622 | public $type = 'Unit'; |
| 7623 | 7623 | |
| 7624 | - public function __construct($numerator = array(), $denominator = array(), $backupUnit = null ){ |
|
| 7624 | + public function __construct($numerator = array(), $denominator = array(), $backupUnit = null) { |
|
| 7625 | 7625 | $this->numerator = $numerator; |
| 7626 | 7626 | $this->denominator = $denominator; |
| 7627 | 7627 | $this->backupUnit = $backupUnit; |
| 7628 | 7628 | } |
| 7629 | 7629 | |
| 7630 | - public function __clone(){ |
|
| 7630 | + public function __clone() { |
|
| 7631 | 7631 | } |
| 7632 | 7632 | |
| 7633 | 7633 | /** |
| 7634 | 7634 | * @see Less_Tree::genCSS |
| 7635 | 7635 | */ |
| 7636 | - public function genCSS( $output ){ |
|
| 7637 | - |
|
| 7638 | - if( $this->numerator ){ |
|
| 7639 | - $output->add( $this->numerator[0] ); |
|
| 7640 | - }elseif( $this->denominator ){ |
|
| 7641 | - $output->add( $this->denominator[0] ); |
|
| 7642 | - }elseif( !Less_Parser::$options['strictUnits'] && $this->backupUnit ){ |
|
| 7643 | - $output->add( $this->backupUnit ); |
|
| 7644 | - return ; |
|
| 7636 | + public function genCSS($output) { |
|
| 7637 | + |
|
| 7638 | + if ($this->numerator) { |
|
| 7639 | + $output->add($this->numerator[0]); |
|
| 7640 | + }elseif ($this->denominator) { |
|
| 7641 | + $output->add($this->denominator[0]); |
|
| 7642 | + }elseif (!Less_Parser::$options['strictUnits'] && $this->backupUnit) { |
|
| 7643 | + $output->add($this->backupUnit); |
|
| 7644 | + return; |
|
| 7645 | 7645 | } |
| 7646 | 7646 | } |
| 7647 | 7647 | |
| 7648 | - public function toString(){ |
|
| 7649 | - $returnStr = implode('*',$this->numerator); |
|
| 7650 | - foreach($this->denominator as $d){ |
|
| 7648 | + public function toString() { |
|
| 7649 | + $returnStr = implode('*', $this->numerator); |
|
| 7650 | + foreach ($this->denominator as $d) { |
|
| 7651 | 7651 | $returnStr .= '/'.$d; |
| 7652 | 7652 | } |
| 7653 | 7653 | return $returnStr; |
| 7654 | 7654 | } |
| 7655 | 7655 | |
| 7656 | - public function __toString(){ |
|
| 7656 | + public function __toString() { |
|
| 7657 | 7657 | return $this->toString(); |
| 7658 | 7658 | } |
| 7659 | 7659 | |
@@ -7662,45 +7662,45 @@ discard block |
||
| 7662 | 7662 | * @param Less_Tree_Unit $other |
| 7663 | 7663 | */ |
| 7664 | 7664 | public function compare($other) { |
| 7665 | - return $this->is( $other->toString() ) ? 0 : -1; |
|
| 7665 | + return $this->is($other->toString()) ? 0 : -1; |
|
| 7666 | 7666 | } |
| 7667 | 7667 | |
| 7668 | - public function is($unitString){ |
|
| 7669 | - return $this->toString() === $unitString; |
|
| 7668 | + public function is($unitString) { |
|
| 7669 | + return $this->toString()===$unitString; |
|
| 7670 | 7670 | } |
| 7671 | 7671 | |
| 7672 | - public function isLength(){ |
|
| 7672 | + public function isLength() { |
|
| 7673 | 7673 | $css = $this->toCSS(); |
| 7674 | - return !!preg_match('/px|em|%|in|cm|mm|pc|pt|ex/',$css); |
|
| 7674 | + return !!preg_match('/px|em|%|in|cm|mm|pc|pt|ex/', $css); |
|
| 7675 | 7675 | } |
| 7676 | 7676 | |
| 7677 | 7677 | public function isAngle() { |
| 7678 | - return isset( Less_Tree_UnitConversions::$angle[$this->toCSS()] ); |
|
| 7678 | + return isset(Less_Tree_UnitConversions::$angle[$this->toCSS()]); |
|
| 7679 | 7679 | } |
| 7680 | 7680 | |
| 7681 | - public function isEmpty(){ |
|
| 7681 | + public function isEmpty() { |
|
| 7682 | 7682 | return !$this->numerator && !$this->denominator; |
| 7683 | 7683 | } |
| 7684 | 7684 | |
| 7685 | 7685 | public function isSingular() { |
| 7686 | - return count($this->numerator) <= 1 && !$this->denominator; |
|
| 7686 | + return count($this->numerator)<=1 && !$this->denominator; |
|
| 7687 | 7687 | } |
| 7688 | 7688 | |
| 7689 | 7689 | |
| 7690 | - public function usedUnits(){ |
|
| 7690 | + public function usedUnits() { |
|
| 7691 | 7691 | $result = array(); |
| 7692 | 7692 | |
| 7693 | - foreach(Less_Tree_UnitConversions::$groups as $groupName){ |
|
| 7693 | + foreach (Less_Tree_UnitConversions::$groups as $groupName) { |
|
| 7694 | 7694 | $group = Less_Tree_UnitConversions::${$groupName}; |
| 7695 | 7695 | |
| 7696 | - foreach($this->numerator as $atomicUnit){ |
|
| 7697 | - if( isset($group[$atomicUnit]) && !isset($result[$groupName]) ){ |
|
| 7696 | + foreach ($this->numerator as $atomicUnit) { |
|
| 7697 | + if (isset($group[$atomicUnit]) && !isset($result[$groupName])) { |
|
| 7698 | 7698 | $result[$groupName] = $atomicUnit; |
| 7699 | 7699 | } |
| 7700 | 7700 | } |
| 7701 | 7701 | |
| 7702 | - foreach($this->denominator as $atomicUnit){ |
|
| 7703 | - if( isset($group[$atomicUnit]) && !isset($result[$groupName]) ){ |
|
| 7702 | + foreach ($this->denominator as $atomicUnit) { |
|
| 7703 | + if (isset($group[$atomicUnit]) && !isset($result[$groupName])) { |
|
| 7704 | 7704 | $result[$groupName] = $atomicUnit; |
| 7705 | 7705 | } |
| 7706 | 7706 | } |
@@ -7709,40 +7709,40 @@ discard block |
||
| 7709 | 7709 | return $result; |
| 7710 | 7710 | } |
| 7711 | 7711 | |
| 7712 | - public function cancel(){ |
|
| 7712 | + public function cancel() { |
|
| 7713 | 7713 | $counter = array(); |
| 7714 | 7714 | $backup = null; |
| 7715 | 7715 | |
| 7716 | - foreach($this->numerator as $atomicUnit){ |
|
| 7717 | - if( !$backup ){ |
|
| 7716 | + foreach ($this->numerator as $atomicUnit) { |
|
| 7717 | + if (!$backup) { |
|
| 7718 | 7718 | $backup = $atomicUnit; |
| 7719 | 7719 | } |
| 7720 | - $counter[$atomicUnit] = ( isset($counter[$atomicUnit]) ? $counter[$atomicUnit] : 0) + 1; |
|
| 7720 | + $counter[$atomicUnit] = (isset($counter[$atomicUnit]) ? $counter[$atomicUnit] : 0)+1; |
|
| 7721 | 7721 | } |
| 7722 | 7722 | |
| 7723 | - foreach($this->denominator as $atomicUnit){ |
|
| 7724 | - if( !$backup ){ |
|
| 7723 | + foreach ($this->denominator as $atomicUnit) { |
|
| 7724 | + if (!$backup) { |
|
| 7725 | 7725 | $backup = $atomicUnit; |
| 7726 | 7726 | } |
| 7727 | - $counter[$atomicUnit] = ( isset($counter[$atomicUnit]) ? $counter[$atomicUnit] : 0) - 1; |
|
| 7727 | + $counter[$atomicUnit] = (isset($counter[$atomicUnit]) ? $counter[$atomicUnit] : 0)-1; |
|
| 7728 | 7728 | } |
| 7729 | 7729 | |
| 7730 | 7730 | $this->numerator = array(); |
| 7731 | 7731 | $this->denominator = array(); |
| 7732 | 7732 | |
| 7733 | - foreach($counter as $atomicUnit => $count){ |
|
| 7734 | - if( $count > 0 ){ |
|
| 7735 | - for( $i = 0; $i < $count; $i++ ){ |
|
| 7733 | + foreach ($counter as $atomicUnit => $count) { |
|
| 7734 | + if ($count>0) { |
|
| 7735 | + for ($i = 0; $i<$count; $i++) { |
|
| 7736 | 7736 | $this->numerator[] = $atomicUnit; |
| 7737 | 7737 | } |
| 7738 | - }elseif( $count < 0 ){ |
|
| 7739 | - for( $i = 0; $i < -$count; $i++ ){ |
|
| 7738 | + }elseif ($count<0) { |
|
| 7739 | + for ($i = 0; $i<-$count; $i++) { |
|
| 7740 | 7740 | $this->denominator[] = $atomicUnit; |
| 7741 | 7741 | } |
| 7742 | 7742 | } |
| 7743 | 7743 | } |
| 7744 | 7744 | |
| 7745 | - if( !$this->numerator && !$this->denominator && $backup ){ |
|
| 7745 | + if (!$this->numerator && !$this->denominator && $backup) { |
|
| 7746 | 7746 | $this->backupUnit = $backup; |
| 7747 | 7747 | } |
| 7748 | 7748 | |
@@ -7761,9 +7761,9 @@ discard block |
||
| 7761 | 7761 | * @package Less |
| 7762 | 7762 | * @subpackage tree |
| 7763 | 7763 | */ |
| 7764 | -class Less_Tree_UnitConversions{ |
|
| 7764 | +class Less_Tree_UnitConversions { |
|
| 7765 | 7765 | |
| 7766 | - public static $groups = array('length','duration','angle'); |
|
| 7766 | + public static $groups = array('length', 'duration', 'angle'); |
|
| 7767 | 7767 | |
| 7768 | 7768 | public static $length = array( |
| 7769 | 7769 | 'm'=> 1, |
@@ -7781,9 +7781,9 @@ discard block |
||
| 7781 | 7781 | ); |
| 7782 | 7782 | |
| 7783 | 7783 | public static $angle = array( |
| 7784 | - 'rad' => 0.1591549430919, // 1/(2*M_PI), |
|
| 7785 | - 'deg' => 0.002777778, // 1/360, |
|
| 7786 | - 'grad'=> 0.0025, // 1/400, |
|
| 7784 | + 'rad' => 0.1591549430919, // 1/(2*M_PI), |
|
| 7785 | + 'deg' => 0.002777778, // 1/360, |
|
| 7786 | + 'grad'=> 0.0025, // 1/400, |
|
| 7787 | 7787 | 'turn'=> 1 |
| 7788 | 7788 | ); |
| 7789 | 7789 | |
@@ -7795,7 +7795,7 @@ discard block |
||
| 7795 | 7795 | * @package Less |
| 7796 | 7796 | * @subpackage tree |
| 7797 | 7797 | */ |
| 7798 | -class Less_Tree_Url extends Less_Tree{ |
|
| 7798 | +class Less_Tree_Url extends Less_Tree { |
|
| 7799 | 7799 | |
| 7800 | 7800 | public $attrs; |
| 7801 | 7801 | public $value; |
@@ -7803,57 +7803,57 @@ discard block |
||
| 7803 | 7803 | public $isEvald; |
| 7804 | 7804 | public $type = 'Url'; |
| 7805 | 7805 | |
| 7806 | - public function __construct($value, $currentFileInfo = null, $isEvald = null){ |
|
| 7806 | + public function __construct($value, $currentFileInfo = null, $isEvald = null) { |
|
| 7807 | 7807 | $this->value = $value; |
| 7808 | 7808 | $this->currentFileInfo = $currentFileInfo; |
| 7809 | 7809 | $this->isEvald = $isEvald; |
| 7810 | 7810 | } |
| 7811 | 7811 | |
| 7812 | - public function accept( $visitor ){ |
|
| 7812 | + public function accept($visitor) { |
|
| 7813 | 7813 | $this->value = $visitor->visitObj($this->value); |
| 7814 | 7814 | } |
| 7815 | 7815 | |
| 7816 | 7816 | /** |
| 7817 | 7817 | * @see Less_Tree::genCSS |
| 7818 | 7818 | */ |
| 7819 | - public function genCSS( $output ){ |
|
| 7820 | - $output->add( 'url(' ); |
|
| 7821 | - $this->value->genCSS( $output ); |
|
| 7822 | - $output->add( ')' ); |
|
| 7819 | + public function genCSS($output) { |
|
| 7820 | + $output->add('url('); |
|
| 7821 | + $this->value->genCSS($output); |
|
| 7822 | + $output->add(')'); |
|
| 7823 | 7823 | } |
| 7824 | 7824 | |
| 7825 | 7825 | /** |
| 7826 | 7826 | * @param Less_Functions $ctx |
| 7827 | 7827 | */ |
| 7828 | - public function compile($ctx){ |
|
| 7828 | + public function compile($ctx) { |
|
| 7829 | 7829 | $val = $this->value->compile($ctx); |
| 7830 | 7830 | |
| 7831 | - if( !$this->isEvald ){ |
|
| 7831 | + if (!$this->isEvald) { |
|
| 7832 | 7832 | // Add the base path if the URL is relative |
| 7833 | - if( Less_Parser::$options['relativeUrls'] |
|
| 7833 | + if (Less_Parser::$options['relativeUrls'] |
|
| 7834 | 7834 | && $this->currentFileInfo |
| 7835 | 7835 | && is_string($val->value) |
| 7836 | 7836 | && Less_Environment::isPathRelative($val->value) |
| 7837 | - ){ |
|
| 7837 | + ) { |
|
| 7838 | 7838 | $rootpath = $this->currentFileInfo['uri_root']; |
| 7839 | - if ( !$val->quote ){ |
|
| 7840 | - $rootpath = preg_replace('/[\(\)\'"\s]/', '\\$1', $rootpath ); |
|
| 7839 | + if (!$val->quote) { |
|
| 7840 | + $rootpath = preg_replace('/[\(\)\'"\s]/', '\\$1', $rootpath); |
|
| 7841 | 7841 | } |
| 7842 | - $val->value = $rootpath . $val->value; |
|
| 7842 | + $val->value = $rootpath.$val->value; |
|
| 7843 | 7843 | } |
| 7844 | 7844 | |
| 7845 | - $val->value = Less_Environment::normalizePath( $val->value); |
|
| 7845 | + $val->value = Less_Environment::normalizePath($val->value); |
|
| 7846 | 7846 | } |
| 7847 | 7847 | |
| 7848 | 7848 | // Add cache buster if enabled |
| 7849 | - if( Less_Parser::$options['urlArgs'] ){ |
|
| 7850 | - if( !preg_match('/^\s*data:/',$val->value) ){ |
|
| 7851 | - $delimiter = strpos($val->value,'?') === false ? '?' : '&'; |
|
| 7852 | - $urlArgs = $delimiter . Less_Parser::$options['urlArgs']; |
|
| 7853 | - $hash_pos = strpos($val->value,'#'); |
|
| 7854 | - if( $hash_pos !== false ){ |
|
| 7855 | - $val->value = substr_replace($val->value,$urlArgs, $hash_pos, 0); |
|
| 7856 | - } else { |
|
| 7849 | + if (Less_Parser::$options['urlArgs']) { |
|
| 7850 | + if (!preg_match('/^\s*data:/', $val->value)) { |
|
| 7851 | + $delimiter = strpos($val->value, '?')===false ? '?' : '&'; |
|
| 7852 | + $urlArgs = $delimiter.Less_Parser::$options['urlArgs']; |
|
| 7853 | + $hash_pos = strpos($val->value, '#'); |
|
| 7854 | + if ($hash_pos!==false) { |
|
| 7855 | + $val->value = substr_replace($val->value, $urlArgs, $hash_pos, 0); |
|
| 7856 | + }else { |
|
| 7857 | 7857 | $val->value .= $urlArgs; |
| 7858 | 7858 | } |
| 7859 | 7859 | } |
@@ -7871,12 +7871,12 @@ discard block |
||
| 7871 | 7871 | * @package Less |
| 7872 | 7872 | * @subpackage tree |
| 7873 | 7873 | */ |
| 7874 | -class Less_Tree_Value extends Less_Tree{ |
|
| 7874 | +class Less_Tree_Value extends Less_Tree { |
|
| 7875 | 7875 | |
| 7876 | 7876 | public $type = 'Value'; |
| 7877 | 7877 | public $value; |
| 7878 | 7878 | |
| 7879 | - public function __construct($value){ |
|
| 7879 | + public function __construct($value) { |
|
| 7880 | 7880 | $this->value = $value; |
| 7881 | 7881 | } |
| 7882 | 7882 | |
@@ -7884,14 +7884,14 @@ discard block |
||
| 7884 | 7884 | $this->value = $visitor->visitArray($this->value); |
| 7885 | 7885 | } |
| 7886 | 7886 | |
| 7887 | - public function compile($env){ |
|
| 7887 | + public function compile($env) { |
|
| 7888 | 7888 | |
| 7889 | 7889 | $ret = array(); |
| 7890 | 7890 | $i = 0; |
| 7891 | - foreach($this->value as $i => $v){ |
|
| 7891 | + foreach ($this->value as $i => $v) { |
|
| 7892 | 7892 | $ret[] = $v->compile($env); |
| 7893 | 7893 | } |
| 7894 | - if( $i > 0 ){ |
|
| 7894 | + if ($i>0) { |
|
| 7895 | 7895 | return new Less_Tree_Value($ret); |
| 7896 | 7896 | } |
| 7897 | 7897 | return $ret[0]; |
@@ -7900,12 +7900,12 @@ discard block |
||
| 7900 | 7900 | /** |
| 7901 | 7901 | * @see Less_Tree::genCSS |
| 7902 | 7902 | */ |
| 7903 | - function genCSS( $output ){ |
|
| 7903 | + function genCSS($output) { |
|
| 7904 | 7904 | $len = count($this->value); |
| 7905 | - for($i = 0; $i < $len; $i++ ){ |
|
| 7906 | - $this->value[$i]->genCSS( $output ); |
|
| 7907 | - if( $i+1 < $len ){ |
|
| 7908 | - $output->add( Less_Environment::$_outputMap[','] ); |
|
| 7905 | + for ($i = 0; $i<$len; $i++) { |
|
| 7906 | + $this->value[$i]->genCSS($output); |
|
| 7907 | + if ($i+1<$len) { |
|
| 7908 | + $output->add(Less_Environment::$_outputMap[',']); |
|
| 7909 | 7909 | } |
| 7910 | 7910 | } |
| 7911 | 7911 | } |
@@ -7919,7 +7919,7 @@ discard block |
||
| 7919 | 7919 | * @package Less |
| 7920 | 7920 | * @subpackage tree |
| 7921 | 7921 | */ |
| 7922 | -class Less_Tree_Variable extends Less_Tree{ |
|
| 7922 | +class Less_Tree_Variable extends Less_Tree { |
|
| 7923 | 7923 | |
| 7924 | 7924 | public $name; |
| 7925 | 7925 | public $index; |
@@ -7938,35 +7938,35 @@ discard block |
||
| 7938 | 7938 | |
| 7939 | 7939 | public function compile($env) { |
| 7940 | 7940 | |
| 7941 | - if( $this->name[1] === '@' ){ |
|
| 7942 | - $v = new Less_Tree_Variable(substr($this->name, 1), $this->index + 1, $this->currentFileInfo); |
|
| 7943 | - $name = '@' . $v->compile($env)->value; |
|
| 7944 | - }else{ |
|
| 7941 | + if ($this->name[1]==='@') { |
|
| 7942 | + $v = new Less_Tree_Variable(substr($this->name, 1), $this->index+1, $this->currentFileInfo); |
|
| 7943 | + $name = '@'.$v->compile($env)->value; |
|
| 7944 | + }else { |
|
| 7945 | 7945 | $name = $this->name; |
| 7946 | 7946 | } |
| 7947 | 7947 | |
| 7948 | 7948 | if ($this->evaluating) { |
| 7949 | - throw new Less_Exception_Compiler("Recursive variable definition for " . $name, null, $this->index, $this->currentFileInfo); |
|
| 7949 | + throw new Less_Exception_Compiler("Recursive variable definition for ".$name, null, $this->index, $this->currentFileInfo); |
|
| 7950 | 7950 | } |
| 7951 | 7951 | |
| 7952 | 7952 | $this->evaluating = true; |
| 7953 | 7953 | |
| 7954 | - foreach($env->frames as $frame){ |
|
| 7955 | - if( $v = $frame->variable($name) ){ |
|
| 7954 | + foreach ($env->frames as $frame) { |
|
| 7955 | + if ($v = $frame->variable($name)) { |
|
| 7956 | 7956 | $r = $v->value->compile($env); |
| 7957 | 7957 | $this->evaluating = false; |
| 7958 | 7958 | return $r; |
| 7959 | 7959 | } |
| 7960 | 7960 | } |
| 7961 | 7961 | |
| 7962 | - throw new Less_Exception_Compiler("variable " . $name . " is undefined in file ".$this->currentFileInfo["filename"], null, $this->index, $this->currentFileInfo); |
|
| 7962 | + throw new Less_Exception_Compiler("variable ".$name." is undefined in file ".$this->currentFileInfo["filename"], null, $this->index, $this->currentFileInfo); |
|
| 7963 | 7963 | } |
| 7964 | 7964 | |
| 7965 | 7965 | } |
| 7966 | 7966 | |
| 7967 | 7967 | |
| 7968 | 7968 | |
| 7969 | -class Less_Tree_Mixin_Call extends Less_Tree{ |
|
| 7969 | +class Less_Tree_Mixin_Call extends Less_Tree { |
|
| 7970 | 7970 | |
| 7971 | 7971 | public $selector; |
| 7972 | 7972 | public $arguments; |
@@ -7980,7 +7980,7 @@ discard block |
||
| 7980 | 7980 | * less.js: tree.mixin.Call |
| 7981 | 7981 | * |
| 7982 | 7982 | */ |
| 7983 | - public function __construct($elements, $args, $index, $currentFileInfo, $important = false){ |
|
| 7983 | + public function __construct($elements, $args, $index, $currentFileInfo, $important = false) { |
|
| 7984 | 7984 | $this->selector = new Less_Tree_Selector($elements); |
| 7985 | 7985 | $this->arguments = $args; |
| 7986 | 7986 | $this->index = $index; |
@@ -7994,7 +7994,7 @@ discard block |
||
| 7994 | 7994 | //} |
| 7995 | 7995 | |
| 7996 | 7996 | |
| 7997 | - public function compile($env){ |
|
| 7997 | + public function compile($env) { |
|
| 7998 | 7998 | |
| 7999 | 7999 | $rules = array(); |
| 8000 | 8000 | $match = false; |
@@ -8004,15 +8004,15 @@ discard block |
||
| 8004 | 8004 | $conditionResult = array(); |
| 8005 | 8005 | |
| 8006 | 8006 | $args = array(); |
| 8007 | - foreach($this->arguments as $a){ |
|
| 8008 | - $args[] = array('name'=> $a['name'], 'value' => $a['value']->compile($env) ); |
|
| 8007 | + foreach ($this->arguments as $a) { |
|
| 8008 | + $args[] = array('name'=> $a['name'], 'value' => $a['value']->compile($env)); |
|
| 8009 | 8009 | } |
| 8010 | 8010 | |
| 8011 | - foreach($env->frames as $frame){ |
|
| 8011 | + foreach ($env->frames as $frame) { |
|
| 8012 | 8012 | |
| 8013 | 8013 | $mixins = $frame->find($this->selector); |
| 8014 | 8014 | |
| 8015 | - if( !$mixins ){ |
|
| 8015 | + if (!$mixins) { |
|
| 8016 | 8016 | continue; |
| 8017 | 8017 | } |
| 8018 | 8018 | |
@@ -8027,31 +8027,31 @@ discard block |
||
| 8027 | 8027 | // we make a final decision. |
| 8028 | 8028 | |
| 8029 | 8029 | $mixins_len = count($mixins); |
| 8030 | - for( $m = 0; $m < $mixins_len; $m++ ){ |
|
| 8030 | + for ($m = 0; $m<$mixins_len; $m++) { |
|
| 8031 | 8031 | $mixin = $mixins[$m]; |
| 8032 | 8032 | |
| 8033 | - if( $this->IsRecursive( $env, $mixin ) ){ |
|
| 8033 | + if ($this->IsRecursive($env, $mixin)) { |
|
| 8034 | 8034 | continue; |
| 8035 | 8035 | } |
| 8036 | 8036 | |
| 8037 | - if( $mixin->matchArgs($args, $env) ){ |
|
| 8037 | + if ($mixin->matchArgs($args, $env)) { |
|
| 8038 | 8038 | |
| 8039 | 8039 | $candidate = array('mixin' => $mixin, 'group' => $defNone); |
| 8040 | 8040 | |
| 8041 | - if( $mixin instanceof Less_Tree_Ruleset ){ |
|
| 8041 | + if ($mixin instanceof Less_Tree_Ruleset) { |
|
| 8042 | 8042 | |
| 8043 | - for( $f = 0; $f < 2; $f++ ){ |
|
| 8043 | + for ($f = 0; $f<2; $f++) { |
|
| 8044 | 8044 | Less_Tree_DefaultFunc::value($f); |
| 8045 | - $conditionResult[$f] = $mixin->matchCondition( $args, $env); |
|
| 8045 | + $conditionResult[$f] = $mixin->matchCondition($args, $env); |
|
| 8046 | 8046 | } |
| 8047 | - if( $conditionResult[0] || $conditionResult[1] ){ |
|
| 8048 | - if( $conditionResult[0] != $conditionResult[1] ){ |
|
| 8047 | + if ($conditionResult[0] || $conditionResult[1]) { |
|
| 8048 | + if ($conditionResult[0]!=$conditionResult[1]) { |
|
| 8049 | 8049 | $candidate['group'] = $conditionResult[1] ? $defTrue : $defFalse; |
| 8050 | 8050 | } |
| 8051 | 8051 | |
| 8052 | 8052 | $candidates[] = $candidate; |
| 8053 | 8053 | } |
| 8054 | - }else{ |
|
| 8054 | + }else { |
|
| 8055 | 8055 | $candidates[] = $candidate; |
| 8056 | 8056 | } |
| 8057 | 8057 | |
@@ -8063,29 +8063,29 @@ discard block |
||
| 8063 | 8063 | |
| 8064 | 8064 | |
| 8065 | 8065 | $count = array(0, 0, 0); |
| 8066 | - for( $m = 0; $m < count($candidates); $m++ ){ |
|
| 8067 | - $count[ $candidates[$m]['group'] ]++; |
|
| 8066 | + for ($m = 0; $m<count($candidates); $m++) { |
|
| 8067 | + $count[$candidates[$m]['group']]++; |
|
| 8068 | 8068 | } |
| 8069 | 8069 | |
| 8070 | - if( $count[$defNone] > 0 ){ |
|
| 8070 | + if ($count[$defNone]>0) { |
|
| 8071 | 8071 | $defaultResult = $defFalse; |
| 8072 | - } else { |
|
| 8072 | + }else { |
|
| 8073 | 8073 | $defaultResult = $defTrue; |
| 8074 | - if( ($count[$defTrue] + $count[$defFalse]) > 1 ){ |
|
| 8075 | - throw new Exception( 'Ambiguous use of `default()` found when matching for `'. $this->format($args) + '`' ); |
|
| 8074 | + if (($count[$defTrue]+$count[$defFalse])>1) { |
|
| 8075 | + throw new Exception('Ambiguous use of `default()` found when matching for `'.$this->format($args)+'`'); |
|
| 8076 | 8076 | } |
| 8077 | 8077 | } |
| 8078 | 8078 | |
| 8079 | 8079 | |
| 8080 | 8080 | $candidates_length = count($candidates); |
| 8081 | - $length_1 = ($candidates_length == 1); |
|
| 8081 | + $length_1 = ($candidates_length==1); |
|
| 8082 | 8082 | |
| 8083 | - for( $m = 0; $m < $candidates_length; $m++){ |
|
| 8083 | + for ($m = 0; $m<$candidates_length; $m++) { |
|
| 8084 | 8084 | $candidate = $candidates[$m]['group']; |
| 8085 | - if( ($candidate === $defNone) || ($candidate === $defaultResult) ){ |
|
| 8086 | - try{ |
|
| 8085 | + if (($candidate===$defNone) || ($candidate===$defaultResult)) { |
|
| 8086 | + try { |
|
| 8087 | 8087 | $mixin = $candidates[$m]['mixin']; |
| 8088 | - if( !($mixin instanceof Less_Tree_Mixin_Definition) ){ |
|
| 8088 | + if (!($mixin instanceof Less_Tree_Mixin_Definition)) { |
|
| 8089 | 8089 | $mixin = new Less_Tree_Mixin_Definition('', array(), $mixin->rules, null, false); |
| 8090 | 8090 | $mixin->originalRuleset = $mixins[$m]->originalRuleset; |
| 8091 | 8091 | } |
@@ -8097,8 +8097,8 @@ discard block |
||
| 8097 | 8097 | } |
| 8098 | 8098 | } |
| 8099 | 8099 | |
| 8100 | - if( $match ){ |
|
| 8101 | - if( !$this->currentFileInfo || !isset($this->currentFileInfo['reference']) || !$this->currentFileInfo['reference'] ){ |
|
| 8100 | + if ($match) { |
|
| 8101 | + if (!$this->currentFileInfo || !isset($this->currentFileInfo['reference']) || !$this->currentFileInfo['reference']) { |
|
| 8102 | 8102 | Less_Tree::ReferencedArray($rules); |
| 8103 | 8103 | } |
| 8104 | 8104 | |
@@ -8106,11 +8106,11 @@ discard block |
||
| 8106 | 8106 | } |
| 8107 | 8107 | } |
| 8108 | 8108 | |
| 8109 | - if( $isOneFound ){ |
|
| 8110 | - throw new Less_Exception_Compiler('No matching definition was found for `'.$this->Format( $args ).'`', null, $this->index, $this->currentFileInfo); |
|
| 8109 | + if ($isOneFound) { |
|
| 8110 | + throw new Less_Exception_Compiler('No matching definition was found for `'.$this->Format($args).'`', null, $this->index, $this->currentFileInfo); |
|
| 8111 | 8111 | |
| 8112 | - }else{ |
|
| 8113 | - throw new Less_Exception_Compiler(trim($this->selector->toCSS()) . " is undefined in ".$this->currentFileInfo['filename'], null, $this->index); |
|
| 8112 | + }else { |
|
| 8113 | + throw new Less_Exception_Compiler(trim($this->selector->toCSS())." is undefined in ".$this->currentFileInfo['filename'], null, $this->index); |
|
| 8114 | 8114 | } |
| 8115 | 8115 | |
| 8116 | 8116 | } |
@@ -8119,23 +8119,23 @@ discard block |
||
| 8119 | 8119 | * Format the args for use in exception messages |
| 8120 | 8120 | * |
| 8121 | 8121 | */ |
| 8122 | - private function Format($args){ |
|
| 8122 | + private function Format($args) { |
|
| 8123 | 8123 | $message = array(); |
| 8124 | - if( $args ){ |
|
| 8125 | - foreach($args as $a){ |
|
| 8124 | + if ($args) { |
|
| 8125 | + foreach ($args as $a) { |
|
| 8126 | 8126 | $argValue = ''; |
| 8127 | - if( $a['name'] ){ |
|
| 8127 | + if ($a['name']) { |
|
| 8128 | 8128 | $argValue += $a['name']+':'; |
| 8129 | 8129 | } |
| 8130 | - if( is_object($a['value']) ){ |
|
| 8130 | + if (is_object($a['value'])) { |
|
| 8131 | 8131 | $argValue += $a['value']->toCSS(); |
| 8132 | - }else{ |
|
| 8132 | + }else { |
|
| 8133 | 8133 | $argValue += '???'; |
| 8134 | 8134 | } |
| 8135 | 8135 | $message[] = $argValue; |
| 8136 | 8136 | } |
| 8137 | 8137 | } |
| 8138 | - return implode(', ',$message); |
|
| 8138 | + return implode(', ', $message); |
|
| 8139 | 8139 | } |
| 8140 | 8140 | |
| 8141 | 8141 | |
@@ -8144,16 +8144,16 @@ discard block |
||
| 8144 | 8144 | * |
| 8145 | 8145 | * @return bool |
| 8146 | 8146 | */ |
| 8147 | - private function IsRecursive( $env, $mixin ){ |
|
| 8147 | + private function IsRecursive($env, $mixin) { |
|
| 8148 | 8148 | |
| 8149 | - foreach($env->frames as $recur_frame){ |
|
| 8150 | - if( !($mixin instanceof Less_Tree_Mixin_Definition) ){ |
|
| 8149 | + foreach ($env->frames as $recur_frame) { |
|
| 8150 | + if (!($mixin instanceof Less_Tree_Mixin_Definition)) { |
|
| 8151 | 8151 | |
| 8152 | - if( $mixin === $recur_frame ){ |
|
| 8152 | + if ($mixin===$recur_frame) { |
|
| 8153 | 8153 | return true; |
| 8154 | 8154 | } |
| 8155 | 8155 | |
| 8156 | - if( isset($recur_frame->originalRuleset) && $mixin->ruleset_id === $recur_frame->originalRuleset ){ |
|
| 8156 | + if (isset($recur_frame->originalRuleset) && $mixin->ruleset_id===$recur_frame->originalRuleset) { |
|
| 8157 | 8157 | return true; |
| 8158 | 8158 | } |
| 8159 | 8159 | } |
@@ -8167,34 +8167,34 @@ discard block |
||
| 8167 | 8167 | |
| 8168 | 8168 | |
| 8169 | 8169 | |
| 8170 | -class Less_Tree_Mixin_Definition extends Less_Tree_Ruleset{ |
|
| 8170 | +class Less_Tree_Mixin_Definition extends Less_Tree_Ruleset { |
|
| 8171 | 8171 | public $name; |
| 8172 | 8172 | public $selectors; |
| 8173 | 8173 | public $params; |
| 8174 | - public $arity = 0; |
|
| 8174 | + public $arity = 0; |
|
| 8175 | 8175 | public $rules; |
| 8176 | 8176 | public $lookups = array(); |
| 8177 | 8177 | public $required = 0; |
| 8178 | - public $frames = array(); |
|
| 8178 | + public $frames = array(); |
|
| 8179 | 8179 | public $condition; |
| 8180 | 8180 | public $variadic; |
| 8181 | - public $type = 'MixinDefinition'; |
|
| 8181 | + public $type = 'MixinDefinition'; |
|
| 8182 | 8182 | |
| 8183 | 8183 | |
| 8184 | 8184 | // less.js : /lib/less/tree/mixin.js : tree.mixin.Definition |
| 8185 | - public function __construct($name, $params, $rules, $condition, $variadic = false, $frames = array() ){ |
|
| 8185 | + public function __construct($name, $params, $rules, $condition, $variadic = false, $frames = array()) { |
|
| 8186 | 8186 | $this->name = $name; |
| 8187 | - $this->selectors = array(new Less_Tree_Selector(array( new Less_Tree_Element(null, $name)))); |
|
| 8187 | + $this->selectors = array(new Less_Tree_Selector(array(new Less_Tree_Element(null, $name)))); |
|
| 8188 | 8188 | |
| 8189 | 8189 | $this->params = $params; |
| 8190 | 8190 | $this->condition = $condition; |
| 8191 | 8191 | $this->variadic = $variadic; |
| 8192 | 8192 | $this->rules = $rules; |
| 8193 | 8193 | |
| 8194 | - if( $params ){ |
|
| 8194 | + if ($params) { |
|
| 8195 | 8195 | $this->arity = count($params); |
| 8196 | - foreach( $params as $p ){ |
|
| 8197 | - if (! isset($p['name']) || ($p['name'] && !isset($p['value']))) { |
|
| 8196 | + foreach ($params as $p) { |
|
| 8197 | + if (!isset($p['name']) || ($p['name'] && !isset($p['value']))) { |
|
| 8198 | 8198 | $this->required++; |
| 8199 | 8199 | } |
| 8200 | 8200 | } |
@@ -8213,29 +8213,29 @@ discard block |
||
| 8213 | 8213 | //} |
| 8214 | 8214 | |
| 8215 | 8215 | |
| 8216 | - public function toCSS(){ |
|
| 8216 | + public function toCSS() { |
|
| 8217 | 8217 | return ''; |
| 8218 | 8218 | } |
| 8219 | 8219 | |
| 8220 | 8220 | // less.js : /lib/less/tree/mixin.js : tree.mixin.Definition.evalParams |
| 8221 | - public function compileParams($env, $mixinFrames, $args = array() , &$evaldArguments = array() ){ |
|
| 8221 | + public function compileParams($env, $mixinFrames, $args = array(), &$evaldArguments = array()) { |
|
| 8222 | 8222 | $frame = new Less_Tree_Ruleset(null, array()); |
| 8223 | 8223 | $params = $this->params; |
| 8224 | 8224 | $mixinEnv = null; |
| 8225 | 8225 | $argsLength = 0; |
| 8226 | 8226 | |
| 8227 | - if( $args ){ |
|
| 8227 | + if ($args) { |
|
| 8228 | 8228 | $argsLength = count($args); |
| 8229 | - for($i = 0; $i < $argsLength; $i++ ){ |
|
| 8229 | + for ($i = 0; $i<$argsLength; $i++) { |
|
| 8230 | 8230 | $arg = $args[$i]; |
| 8231 | 8231 | |
| 8232 | - if( $arg && $arg['name'] ){ |
|
| 8232 | + if ($arg && $arg['name']) { |
|
| 8233 | 8233 | $isNamedFound = false; |
| 8234 | 8234 | |
| 8235 | - foreach($params as $j => $param){ |
|
| 8236 | - if( !isset($evaldArguments[$j]) && $arg['name'] === $params[$j]['name']) { |
|
| 8235 | + foreach ($params as $j => $param) { |
|
| 8236 | + if (!isset($evaldArguments[$j]) && $arg['name']===$params[$j]['name']) { |
|
| 8237 | 8237 | $evaldArguments[$j] = $arg['value']->compile($env); |
| 8238 | - array_unshift($frame->rules, new Less_Tree_Rule( $arg['name'], $arg['value']->compile($env) ) ); |
|
| 8238 | + array_unshift($frame->rules, new Less_Tree_Rule($arg['name'], $arg['value']->compile($env))); |
|
| 8239 | 8239 | $isNamedFound = true; |
| 8240 | 8240 | break; |
| 8241 | 8241 | } |
@@ -8245,48 +8245,48 @@ discard block |
||
| 8245 | 8245 | $i--; |
| 8246 | 8246 | $argsLength--; |
| 8247 | 8247 | continue; |
| 8248 | - } else { |
|
| 8249 | - throw new Less_Exception_Compiler("Named argument for " . $this->name .' '.$args[$i]['name'] . ' not found'); |
|
| 8248 | + }else { |
|
| 8249 | + throw new Less_Exception_Compiler("Named argument for ".$this->name.' '.$args[$i]['name'].' not found'); |
|
| 8250 | 8250 | } |
| 8251 | 8251 | } |
| 8252 | 8252 | } |
| 8253 | 8253 | } |
| 8254 | 8254 | |
| 8255 | 8255 | $argIndex = 0; |
| 8256 | - foreach($params as $i => $param){ |
|
| 8256 | + foreach ($params as $i => $param) { |
|
| 8257 | 8257 | |
| 8258 | - if ( isset($evaldArguments[$i]) ){ continue; } |
|
| 8258 | + if (isset($evaldArguments[$i])) { continue; } |
|
| 8259 | 8259 | |
| 8260 | 8260 | $arg = null; |
| 8261 | - if( isset($args[$argIndex]) ){ |
|
| 8261 | + if (isset($args[$argIndex])) { |
|
| 8262 | 8262 | $arg = $args[$argIndex]; |
| 8263 | 8263 | } |
| 8264 | 8264 | |
| 8265 | 8265 | if (isset($param['name']) && $param['name']) { |
| 8266 | 8266 | |
| 8267 | - if( isset($param['variadic']) ){ |
|
| 8267 | + if (isset($param['variadic'])) { |
|
| 8268 | 8268 | $varargs = array(); |
| 8269 | - for ($j = $argIndex; $j < $argsLength; $j++) { |
|
| 8269 | + for ($j = $argIndex; $j<$argsLength; $j++) { |
|
| 8270 | 8270 | $varargs[] = $args[$j]['value']->compile($env); |
| 8271 | 8271 | } |
| 8272 | 8272 | $expression = new Less_Tree_Expression($varargs); |
| 8273 | 8273 | array_unshift($frame->rules, new Less_Tree_Rule($param['name'], $expression->compile($env))); |
| 8274 | - }else{ |
|
| 8274 | + }else { |
|
| 8275 | 8275 | $val = ($arg && $arg['value']) ? $arg['value'] : false; |
| 8276 | 8276 | |
| 8277 | 8277 | if ($val) { |
| 8278 | 8278 | $val = $val->compile($env); |
| 8279 | - } else if ( isset($param['value']) ) { |
|
| 8279 | + }else if (isset($param['value'])) { |
|
| 8280 | 8280 | |
| 8281 | - if( !$mixinEnv ){ |
|
| 8281 | + if (!$mixinEnv) { |
|
| 8282 | 8282 | $mixinEnv = new Less_Environment(); |
| 8283 | - $mixinEnv->frames = array_merge( array($frame), $mixinFrames); |
|
| 8283 | + $mixinEnv->frames = array_merge(array($frame), $mixinFrames); |
|
| 8284 | 8284 | } |
| 8285 | 8285 | |
| 8286 | 8286 | $val = $param['value']->compile($mixinEnv); |
| 8287 | 8287 | $frame->resetCache(); |
| 8288 | - } else { |
|
| 8289 | - throw new Less_Exception_Compiler("Wrong number of arguments for " . $this->name . " (" . $argsLength . ' for ' . $this->arity . ")"); |
|
| 8288 | + }else { |
|
| 8289 | + throw new Less_Exception_Compiler("Wrong number of arguments for ".$this->name." (".$argsLength.' for '.$this->arity.")"); |
|
| 8290 | 8290 | } |
| 8291 | 8291 | |
| 8292 | 8292 | array_unshift($frame->rules, new Less_Tree_Rule($param['name'], $val)); |
@@ -8294,8 +8294,8 @@ discard block |
||
| 8294 | 8294 | } |
| 8295 | 8295 | } |
| 8296 | 8296 | |
| 8297 | - if ( isset($param['variadic']) && $args) { |
|
| 8298 | - for ($j = $argIndex; $j < $argsLength; $j++) { |
|
| 8297 | + if (isset($param['variadic']) && $args) { |
|
| 8298 | + for ($j = $argIndex; $j<$argsLength; $j++) { |
|
| 8299 | 8299 | $evaldArguments[$j] = $args[$j]['value']->compile($env); |
| 8300 | 8300 | } |
| 8301 | 8301 | } |
@@ -8309,10 +8309,10 @@ discard block |
||
| 8309 | 8309 | } |
| 8310 | 8310 | |
| 8311 | 8311 | public function compile($env) { |
| 8312 | - if( $this->frames ){ |
|
| 8313 | - return new Less_Tree_Mixin_Definition($this->name, $this->params, $this->rules, $this->condition, $this->variadic, $this->frames ); |
|
| 8312 | + if ($this->frames) { |
|
| 8313 | + return new Less_Tree_Mixin_Definition($this->name, $this->params, $this->rules, $this->condition, $this->variadic, $this->frames); |
|
| 8314 | 8314 | } |
| 8315 | - return new Less_Tree_Mixin_Definition($this->name, $this->params, $this->rules, $this->condition, $this->variadic, $env->frames ); |
|
| 8315 | + return new Less_Tree_Mixin_Definition($this->name, $this->params, $this->rules, $this->condition, $this->variadic, $env->frames); |
|
| 8316 | 8316 | } |
| 8317 | 8317 | |
| 8318 | 8318 | public function evalCall($env, $args = NULL, $important = NULL) { |
@@ -8321,9 +8321,9 @@ discard block |
||
| 8321 | 8321 | |
| 8322 | 8322 | $_arguments = array(); |
| 8323 | 8323 | |
| 8324 | - if( $this->frames ){ |
|
| 8324 | + if ($this->frames) { |
|
| 8325 | 8325 | $mixinFrames = array_merge($this->frames, $env->frames); |
| 8326 | - }else{ |
|
| 8326 | + }else { |
|
| 8327 | 8327 | $mixinFrames = $env->frames; |
| 8328 | 8328 | } |
| 8329 | 8329 | |
@@ -8338,10 +8338,10 @@ discard block |
||
| 8338 | 8338 | |
| 8339 | 8339 | |
| 8340 | 8340 | $ruleSetEnv = new Less_Environment(); |
| 8341 | - $ruleSetEnv->frames = array_merge( array($this, $frame), $mixinFrames ); |
|
| 8342 | - $ruleset = $ruleset->compile( $ruleSetEnv ); |
|
| 8341 | + $ruleSetEnv->frames = array_merge(array($this, $frame), $mixinFrames); |
|
| 8342 | + $ruleset = $ruleset->compile($ruleSetEnv); |
|
| 8343 | 8343 | |
| 8344 | - if( $important ){ |
|
| 8344 | + if ($important) { |
|
| 8345 | 8345 | $ruleset = $ruleset->makeImportant(); |
| 8346 | 8346 | } |
| 8347 | 8347 | |
@@ -8353,16 +8353,16 @@ discard block |
||
| 8353 | 8353 | |
| 8354 | 8354 | public function matchCondition($args, $env) { |
| 8355 | 8355 | |
| 8356 | - if( !$this->condition ){ |
|
| 8356 | + if (!$this->condition) { |
|
| 8357 | 8357 | return true; |
| 8358 | 8358 | } |
| 8359 | 8359 | |
| 8360 | 8360 | // set array to prevent error on array_merge |
| 8361 | - if(!is_array($this->frames)) { |
|
| 8361 | + if (!is_array($this->frames)) { |
|
| 8362 | 8362 | $this->frames = array(); |
| 8363 | 8363 | } |
| 8364 | 8364 | |
| 8365 | - $frame = $this->compileParams($env, array_merge($this->frames,$env->frames), $args ); |
|
| 8365 | + $frame = $this->compileParams($env, array_merge($this->frames, $env->frames), $args); |
|
| 8366 | 8366 | |
| 8367 | 8367 | $compile_env = new Less_Environment(); |
| 8368 | 8368 | $compile_env->frames = array_merge( |
@@ -8376,27 +8376,27 @@ discard block |
||
| 8376 | 8376 | return (bool)$this->condition->compile($compile_env); |
| 8377 | 8377 | } |
| 8378 | 8378 | |
| 8379 | - public function matchArgs($args, $env = NULL){ |
|
| 8379 | + public function matchArgs($args, $env = NULL) { |
|
| 8380 | 8380 | $argsLength = count($args); |
| 8381 | 8381 | |
| 8382 | - if( !$this->variadic ){ |
|
| 8383 | - if( $argsLength < $this->required ){ |
|
| 8382 | + if (!$this->variadic) { |
|
| 8383 | + if ($argsLength<$this->required) { |
|
| 8384 | 8384 | return false; |
| 8385 | 8385 | } |
| 8386 | - if( $argsLength > count($this->params) ){ |
|
| 8386 | + if ($argsLength>count($this->params)) { |
|
| 8387 | 8387 | return false; |
| 8388 | 8388 | } |
| 8389 | - }else{ |
|
| 8390 | - if( $argsLength < ($this->required - 1)){ |
|
| 8389 | + }else { |
|
| 8390 | + if ($argsLength<($this->required-1)) { |
|
| 8391 | 8391 | return false; |
| 8392 | 8392 | } |
| 8393 | 8393 | } |
| 8394 | 8394 | |
| 8395 | 8395 | $len = min($argsLength, $this->arity); |
| 8396 | 8396 | |
| 8397 | - for( $i = 0; $i < $len; $i++ ){ |
|
| 8398 | - if( !isset($this->params[$i]['name']) && !isset($this->params[$i]['variadic']) ){ |
|
| 8399 | - if( $args[$i]['value']->compile($env)->toCSS() != $this->params[$i]['value']->compile($env)->toCSS() ){ |
|
| 8397 | + for ($i = 0; $i<$len; $i++) { |
|
| 8398 | + if (!isset($this->params[$i]['name']) && !isset($this->params[$i]['variadic'])) { |
|
| 8399 | + if ($args[$i]['value']->compile($env)->toCSS()!=$this->params[$i]['value']->compile($env)->toCSS()) { |
|
| 8400 | 8400 | return false; |
| 8401 | 8401 | } |
| 8402 | 8402 | } |
@@ -8414,13 +8414,13 @@ discard block |
||
| 8414 | 8414 | * @package Less |
| 8415 | 8415 | * @subpackage visitor |
| 8416 | 8416 | */ |
| 8417 | -class Less_Visitor_extendFinder extends Less_Visitor{ |
|
| 8417 | +class Less_Visitor_extendFinder extends Less_Visitor { |
|
| 8418 | 8418 | |
| 8419 | 8419 | public $contexts = array(); |
| 8420 | 8420 | public $allExtendsStack; |
| 8421 | 8421 | public $foundExtends; |
| 8422 | 8422 | |
| 8423 | - public function __construct(){ |
|
| 8423 | + public function __construct() { |
|
| 8424 | 8424 | $this->contexts = array(); |
| 8425 | 8425 | $this->allExtendsStack = array(array()); |
| 8426 | 8426 | parent::__construct(); |
@@ -8429,32 +8429,32 @@ discard block |
||
| 8429 | 8429 | /** |
| 8430 | 8430 | * @param Less_Tree_Ruleset $root |
| 8431 | 8431 | */ |
| 8432 | - public function run($root){ |
|
| 8432 | + public function run($root) { |
|
| 8433 | 8433 | $root = $this->visitObj($root); |
| 8434 | - $root->allExtends =& $this->allExtendsStack[0]; |
|
| 8434 | + $root->allExtends = & $this->allExtendsStack[0]; |
|
| 8435 | 8435 | return $root; |
| 8436 | 8436 | } |
| 8437 | 8437 | |
| 8438 | - public function visitRule($ruleNode, &$visitDeeper ){ |
|
| 8438 | + public function visitRule($ruleNode, &$visitDeeper) { |
|
| 8439 | 8439 | $visitDeeper = false; |
| 8440 | 8440 | } |
| 8441 | 8441 | |
| 8442 | - public function visitMixinDefinition( $mixinDefinitionNode, &$visitDeeper ){ |
|
| 8442 | + public function visitMixinDefinition($mixinDefinitionNode, &$visitDeeper) { |
|
| 8443 | 8443 | $visitDeeper = false; |
| 8444 | 8444 | } |
| 8445 | 8445 | |
| 8446 | - public function visitRuleset($rulesetNode){ |
|
| 8446 | + public function visitRuleset($rulesetNode) { |
|
| 8447 | 8447 | |
| 8448 | - if( $rulesetNode->root ){ |
|
| 8448 | + if ($rulesetNode->root) { |
|
| 8449 | 8449 | return; |
| 8450 | 8450 | } |
| 8451 | 8451 | |
| 8452 | 8452 | $allSelectorsExtendList = array(); |
| 8453 | 8453 | |
| 8454 | 8454 | // get &:extend(.a); rules which apply to all selectors in this ruleset |
| 8455 | - if( $rulesetNode->rules ){ |
|
| 8456 | - foreach($rulesetNode->rules as $rule){ |
|
| 8457 | - if( $rule instanceof Less_Tree_Extend ){ |
|
| 8455 | + if ($rulesetNode->rules) { |
|
| 8456 | + foreach ($rulesetNode->rules as $rule) { |
|
| 8457 | + if ($rule instanceof Less_Tree_Extend) { |
|
| 8458 | 8458 | $allSelectorsExtendList[] = $rule; |
| 8459 | 8459 | $rulesetNode->extendOnEveryPath = true; |
| 8460 | 8460 | } |
@@ -8464,14 +8464,14 @@ discard block |
||
| 8464 | 8464 | |
| 8465 | 8465 | // now find every selector and apply the extends that apply to all extends |
| 8466 | 8466 | // and the ones which apply to an individual extend |
| 8467 | - foreach($rulesetNode->paths as $selectorPath){ |
|
| 8467 | + foreach ($rulesetNode->paths as $selectorPath) { |
|
| 8468 | 8468 | $selector = end($selectorPath); //$selectorPath[ count($selectorPath)-1]; |
| 8469 | 8469 | |
| 8470 | 8470 | $j = 0; |
| 8471 | - foreach($selector->extendList as $extend){ |
|
| 8471 | + foreach ($selector->extendList as $extend) { |
|
| 8472 | 8472 | $this->allExtendsStackPush($rulesetNode, $selectorPath, $extend, $j); |
| 8473 | 8473 | } |
| 8474 | - foreach($allSelectorsExtendList as $extend){ |
|
| 8474 | + foreach ($allSelectorsExtendList as $extend) { |
|
| 8475 | 8475 | $this->allExtendsStackPush($rulesetNode, $selectorPath, $extend, $j); |
| 8476 | 8476 | } |
| 8477 | 8477 | } |
@@ -8479,12 +8479,12 @@ discard block |
||
| 8479 | 8479 | $this->contexts[] = $rulesetNode->selectors; |
| 8480 | 8480 | } |
| 8481 | 8481 | |
| 8482 | - public function allExtendsStackPush($rulesetNode, $selectorPath, $extend, &$j){ |
|
| 8482 | + public function allExtendsStackPush($rulesetNode, $selectorPath, $extend, &$j) { |
|
| 8483 | 8483 | $this->foundExtends = true; |
| 8484 | 8484 | $extend = clone $extend; |
| 8485 | - $extend->findSelfSelectors( $selectorPath ); |
|
| 8485 | + $extend->findSelfSelectors($selectorPath); |
|
| 8486 | 8486 | $extend->ruleset = $rulesetNode; |
| 8487 | - if( $j === 0 ){ |
|
| 8487 | + if ($j===0) { |
|
| 8488 | 8488 | $extend->firstExtendOnThisSelectorPath = true; |
| 8489 | 8489 | } |
| 8490 | 8490 | |
@@ -8494,27 +8494,27 @@ discard block |
||
| 8494 | 8494 | } |
| 8495 | 8495 | |
| 8496 | 8496 | |
| 8497 | - public function visitRulesetOut( $rulesetNode ){ |
|
| 8498 | - if( !is_object($rulesetNode) || !$rulesetNode->root ){ |
|
| 8497 | + public function visitRulesetOut($rulesetNode) { |
|
| 8498 | + if (!is_object($rulesetNode) || !$rulesetNode->root) { |
|
| 8499 | 8499 | array_pop($this->contexts); |
| 8500 | 8500 | } |
| 8501 | 8501 | } |
| 8502 | 8502 | |
| 8503 | - public function visitMedia( $mediaNode ){ |
|
| 8503 | + public function visitMedia($mediaNode) { |
|
| 8504 | 8504 | $mediaNode->allExtends = array(); |
| 8505 | - $this->allExtendsStack[] =& $mediaNode->allExtends; |
|
| 8505 | + $this->allExtendsStack[] = & $mediaNode->allExtends; |
|
| 8506 | 8506 | } |
| 8507 | 8507 | |
| 8508 | - public function visitMediaOut(){ |
|
| 8508 | + public function visitMediaOut() { |
|
| 8509 | 8509 | array_pop($this->allExtendsStack); |
| 8510 | 8510 | } |
| 8511 | 8511 | |
| 8512 | - public function visitDirective( $directiveNode ){ |
|
| 8512 | + public function visitDirective($directiveNode) { |
|
| 8513 | 8513 | $directiveNode->allExtends = array(); |
| 8514 | - $this->allExtendsStack[] =& $directiveNode->allExtends; |
|
| 8514 | + $this->allExtendsStack[] = & $directiveNode->allExtends; |
|
| 8515 | 8515 | } |
| 8516 | 8516 | |
| 8517 | - public function visitDirectiveOut(){ |
|
| 8517 | + public function visitDirectiveOut() { |
|
| 8518 | 8518 | array_pop($this->allExtendsStack); |
| 8519 | 8519 | } |
| 8520 | 8520 | } |
@@ -8667,46 +8667,46 @@ discard block |
||
| 8667 | 8667 | * @package Less |
| 8668 | 8668 | * @subpackage visitor |
| 8669 | 8669 | */ |
| 8670 | -class Less_Visitor_joinSelector extends Less_Visitor{ |
|
| 8670 | +class Less_Visitor_joinSelector extends Less_Visitor { |
|
| 8671 | 8671 | |
| 8672 | - public $contexts = array( array() ); |
|
| 8672 | + public $contexts = array(array()); |
|
| 8673 | 8673 | |
| 8674 | 8674 | /** |
| 8675 | 8675 | * @param Less_Tree_Ruleset $root |
| 8676 | 8676 | */ |
| 8677 | - public function run( $root ){ |
|
| 8677 | + public function run($root) { |
|
| 8678 | 8678 | return $this->visitObj($root); |
| 8679 | 8679 | } |
| 8680 | 8680 | |
| 8681 | - public function visitRule( $ruleNode, &$visitDeeper ){ |
|
| 8681 | + public function visitRule($ruleNode, &$visitDeeper) { |
|
| 8682 | 8682 | $visitDeeper = false; |
| 8683 | 8683 | } |
| 8684 | 8684 | |
| 8685 | - public function visitMixinDefinition( $mixinDefinitionNode, &$visitDeeper ){ |
|
| 8685 | + public function visitMixinDefinition($mixinDefinitionNode, &$visitDeeper) { |
|
| 8686 | 8686 | $visitDeeper = false; |
| 8687 | 8687 | } |
| 8688 | 8688 | |
| 8689 | - public function visitRuleset( $rulesetNode ){ |
|
| 8689 | + public function visitRuleset($rulesetNode) { |
|
| 8690 | 8690 | |
| 8691 | 8691 | $paths = array(); |
| 8692 | 8692 | |
| 8693 | - if( !$rulesetNode->root ){ |
|
| 8693 | + if (!$rulesetNode->root) { |
|
| 8694 | 8694 | $selectors = array(); |
| 8695 | 8695 | |
| 8696 | - if( $rulesetNode->selectors && $rulesetNode->selectors ){ |
|
| 8697 | - foreach($rulesetNode->selectors as $selector){ |
|
| 8698 | - if( $selector->getIsOutput() ){ |
|
| 8696 | + if ($rulesetNode->selectors && $rulesetNode->selectors) { |
|
| 8697 | + foreach ($rulesetNode->selectors as $selector) { |
|
| 8698 | + if ($selector->getIsOutput()) { |
|
| 8699 | 8699 | $selectors[] = $selector; |
| 8700 | 8700 | } |
| 8701 | 8701 | } |
| 8702 | 8702 | } |
| 8703 | 8703 | |
| 8704 | - if( !$selectors ){ |
|
| 8704 | + if (!$selectors) { |
|
| 8705 | 8705 | $rulesetNode->selectors = null; |
| 8706 | 8706 | $rulesetNode->rules = null; |
| 8707 | - }else{ |
|
| 8707 | + }else { |
|
| 8708 | 8708 | $context = end($this->contexts); //$context = $this->contexts[ count($this->contexts) - 1]; |
| 8709 | - $paths = $rulesetNode->joinSelectors( $context, $selectors); |
|
| 8709 | + $paths = $rulesetNode->joinSelectors($context, $selectors); |
|
| 8710 | 8710 | } |
| 8711 | 8711 | |
| 8712 | 8712 | $rulesetNode->paths = $paths; |
@@ -8715,14 +8715,14 @@ discard block |
||
| 8715 | 8715 | $this->contexts[] = $paths; //different from less.js. Placed after joinSelectors() so that $this->contexts will get correct $paths |
| 8716 | 8716 | } |
| 8717 | 8717 | |
| 8718 | - public function visitRulesetOut(){ |
|
| 8718 | + public function visitRulesetOut() { |
|
| 8719 | 8719 | array_pop($this->contexts); |
| 8720 | 8720 | } |
| 8721 | 8721 | |
| 8722 | 8722 | public function visitMedia($mediaNode) { |
| 8723 | 8723 | $context = end($this->contexts); //$context = $this->contexts[ count($this->contexts) - 1]; |
| 8724 | 8724 | |
| 8725 | - if( !count($context) || (is_object($context[0]) && $context[0]->multiMedia) ){ |
|
| 8725 | + if (!count($context) || (is_object($context[0]) && $context[0]->multiMedia)) { |
|
| 8726 | 8726 | $mediaNode->rules[0]->root = true; |
| 8727 | 8727 | } |
| 8728 | 8728 | } |
@@ -8737,29 +8737,29 @@ discard block |
||
| 8737 | 8737 | * @package Less |
| 8738 | 8738 | * @subpackage visitor |
| 8739 | 8739 | */ |
| 8740 | -class Less_Visitor_processExtends extends Less_Visitor{ |
|
| 8740 | +class Less_Visitor_processExtends extends Less_Visitor { |
|
| 8741 | 8741 | |
| 8742 | 8742 | public $allExtendsStack; |
| 8743 | 8743 | |
| 8744 | 8744 | /** |
| 8745 | 8745 | * @param Less_Tree_Ruleset $root |
| 8746 | 8746 | */ |
| 8747 | - public function run( $root ){ |
|
| 8747 | + public function run($root) { |
|
| 8748 | 8748 | $extendFinder = new Less_Visitor_extendFinder(); |
| 8749 | - $extendFinder->run( $root ); |
|
| 8750 | - if( !$extendFinder->foundExtends){ |
|
| 8749 | + $extendFinder->run($root); |
|
| 8750 | + if (!$extendFinder->foundExtends) { |
|
| 8751 | 8751 | return $root; |
| 8752 | 8752 | } |
| 8753 | 8753 | |
| 8754 | - $root->allExtends = $this->doExtendChaining( $root->allExtends, $root->allExtends); |
|
| 8754 | + $root->allExtends = $this->doExtendChaining($root->allExtends, $root->allExtends); |
|
| 8755 | 8755 | |
| 8756 | 8756 | $this->allExtendsStack = array(); |
| 8757 | 8757 | $this->allExtendsStack[] = &$root->allExtends; |
| 8758 | 8758 | |
| 8759 | - return $this->visitObj( $root ); |
|
| 8759 | + return $this->visitObj($root); |
|
| 8760 | 8760 | } |
| 8761 | 8761 | |
| 8762 | - private function doExtendChaining( $extendsList, $extendsListTarget, $iterationCount = 0){ |
|
| 8762 | + private function doExtendChaining($extendsList, $extendsListTarget, $iterationCount = 0) { |
|
| 8763 | 8763 | // |
| 8764 | 8764 | // chaining is different from normal extension.. if we extend an extend then we are not just copying, altering and pasting |
| 8765 | 8765 | // the selector we would do normally, but we are also adding an extend with the same target selector |
@@ -8778,33 +8778,33 @@ discard block |
||
| 8778 | 8778 | // and the second is the target. |
| 8779 | 8779 | // the seperation into two lists allows us to process a subset of chains with a bigger set, as is the |
| 8780 | 8780 | // case when processing media queries |
| 8781 | - for( $extendIndex = 0, $extendsList_len = count($extendsList); $extendIndex < $extendsList_len; $extendIndex++ ){ |
|
| 8782 | - for( $targetExtendIndex = 0; $targetExtendIndex < count($extendsListTarget); $targetExtendIndex++ ){ |
|
| 8781 | + for ($extendIndex = 0, $extendsList_len = count($extendsList); $extendIndex<$extendsList_len; $extendIndex++) { |
|
| 8782 | + for ($targetExtendIndex = 0; $targetExtendIndex<count($extendsListTarget); $targetExtendIndex++) { |
|
| 8783 | 8783 | |
| 8784 | 8784 | $extend = $extendsList[$extendIndex]; |
| 8785 | 8785 | $targetExtend = $extendsListTarget[$targetExtendIndex]; |
| 8786 | 8786 | |
| 8787 | 8787 | // look for circular references |
| 8788 | - if( in_array($targetExtend->object_id, $extend->parent_ids,true) ){ |
|
| 8788 | + if (in_array($targetExtend->object_id, $extend->parent_ids, true)) { |
|
| 8789 | 8789 | continue; |
| 8790 | 8790 | } |
| 8791 | 8791 | |
| 8792 | 8792 | // find a match in the target extends self selector (the bit before :extend) |
| 8793 | - $selectorPath = array( $targetExtend->selfSelectors[0] ); |
|
| 8794 | - $matches = $this->findMatch( $extend, $selectorPath); |
|
| 8793 | + $selectorPath = array($targetExtend->selfSelectors[0]); |
|
| 8794 | + $matches = $this->findMatch($extend, $selectorPath); |
|
| 8795 | 8795 | |
| 8796 | 8796 | |
| 8797 | - if( $matches ){ |
|
| 8797 | + if ($matches) { |
|
| 8798 | 8798 | |
| 8799 | 8799 | // we found a match, so for each self selector.. |
| 8800 | - foreach($extend->selfSelectors as $selfSelector ){ |
|
| 8800 | + foreach ($extend->selfSelectors as $selfSelector) { |
|
| 8801 | 8801 | |
| 8802 | 8802 | |
| 8803 | 8803 | // process the extend as usual |
| 8804 | - $newSelector = $this->extendSelector( $matches, $selectorPath, $selfSelector); |
|
| 8804 | + $newSelector = $this->extendSelector($matches, $selectorPath, $selfSelector); |
|
| 8805 | 8805 | |
| 8806 | 8806 | // but now we create a new extend from it |
| 8807 | - $newExtend = new Less_Tree_Extend( $targetExtend->selector, $targetExtend->option, 0); |
|
| 8807 | + $newExtend = new Less_Tree_Extend($targetExtend->selector, $targetExtend->option, 0); |
|
| 8808 | 8808 | $newExtend->selfSelectors = $newSelector; |
| 8809 | 8809 | |
| 8810 | 8810 | // add the extend onto the list of extends for that selector |
@@ -8816,12 +8816,12 @@ discard block |
||
| 8816 | 8816 | $newExtend->ruleset = $targetExtend->ruleset; |
| 8817 | 8817 | |
| 8818 | 8818 | //remember its parents for circular references |
| 8819 | - $newExtend->parent_ids = array_merge($newExtend->parent_ids,$targetExtend->parent_ids,$extend->parent_ids); |
|
| 8819 | + $newExtend->parent_ids = array_merge($newExtend->parent_ids, $targetExtend->parent_ids, $extend->parent_ids); |
|
| 8820 | 8820 | |
| 8821 | 8821 | // only process the selector once.. if we have :extend(.a,.b) then multiple |
| 8822 | 8822 | // extends will look at the same selector path, so when extending |
| 8823 | 8823 | // we know that any others will be duplicates in terms of what is added to the css |
| 8824 | - if( $targetExtend->firstExtendOnThisSelectorPath ){ |
|
| 8824 | + if ($targetExtend->firstExtendOnThisSelectorPath) { |
|
| 8825 | 8825 | $newExtend->firstExtendOnThisSelectorPath = true; |
| 8826 | 8826 | $targetExtend->ruleset->paths[] = $newSelector; |
| 8827 | 8827 | } |
@@ -8830,79 +8830,79 @@ discard block |
||
| 8830 | 8830 | } |
| 8831 | 8831 | } |
| 8832 | 8832 | |
| 8833 | - if( $extendsToAdd ){ |
|
| 8833 | + if ($extendsToAdd) { |
|
| 8834 | 8834 | // try to detect circular references to stop a stack overflow. |
| 8835 | 8835 | // may no longer be needed. $this->extendChainCount++; |
| 8836 | - if( $iterationCount > 100) { |
|
| 8836 | + if ($iterationCount>100) { |
|
| 8837 | 8837 | |
| 8838 | - try{ |
|
| 8838 | + try { |
|
| 8839 | 8839 | $selectorOne = $extendsToAdd[0]->selfSelectors[0]->toCSS(); |
| 8840 | 8840 | $selectorTwo = $extendsToAdd[0]->selector->toCSS(); |
| 8841 | - }catch(Exception $e){ |
|
| 8841 | + } catch (Exception $e) { |
|
| 8842 | 8842 | $selectorOne = "{unable to calculate}"; |
| 8843 | 8843 | $selectorTwo = "{unable to calculate}"; |
| 8844 | 8844 | } |
| 8845 | 8845 | |
| 8846 | - throw new Less_Exception_Parser("extend circular reference detected. One of the circular extends is currently:"+$selectorOne+":extend(" + $selectorTwo+")"); |
|
| 8846 | + throw new Less_Exception_Parser("extend circular reference detected. One of the circular extends is currently:"+$selectorOne+":extend(" +$selectorTwo+")"); |
|
| 8847 | 8847 | } |
| 8848 | 8848 | |
| 8849 | 8849 | // now process the new extends on the existing rules so that we can handle a extending b extending c ectending d extending e... |
| 8850 | - $extendsToAdd = $this->doExtendChaining( $extendsToAdd, $extendsListTarget, $iterationCount+1); |
|
| 8850 | + $extendsToAdd = $this->doExtendChaining($extendsToAdd, $extendsListTarget, $iterationCount+1); |
|
| 8851 | 8851 | } |
| 8852 | 8852 | |
| 8853 | 8853 | return array_merge($extendsList, $extendsToAdd); |
| 8854 | 8854 | } |
| 8855 | 8855 | |
| 8856 | 8856 | |
| 8857 | - protected function visitRule( $ruleNode, &$visitDeeper ){ |
|
| 8857 | + protected function visitRule($ruleNode, &$visitDeeper) { |
|
| 8858 | 8858 | $visitDeeper = false; |
| 8859 | 8859 | } |
| 8860 | 8860 | |
| 8861 | - protected function visitMixinDefinition( $mixinDefinitionNode, &$visitDeeper ){ |
|
| 8861 | + protected function visitMixinDefinition($mixinDefinitionNode, &$visitDeeper) { |
|
| 8862 | 8862 | $visitDeeper = false; |
| 8863 | 8863 | } |
| 8864 | 8864 | |
| 8865 | - protected function visitSelector( $selectorNode, &$visitDeeper ){ |
|
| 8865 | + protected function visitSelector($selectorNode, &$visitDeeper) { |
|
| 8866 | 8866 | $visitDeeper = false; |
| 8867 | 8867 | } |
| 8868 | 8868 | |
| 8869 | - protected function visitRuleset($rulesetNode){ |
|
| 8869 | + protected function visitRuleset($rulesetNode) { |
|
| 8870 | 8870 | |
| 8871 | 8871 | |
| 8872 | - if( $rulesetNode->root ){ |
|
| 8872 | + if ($rulesetNode->root) { |
|
| 8873 | 8873 | return; |
| 8874 | 8874 | } |
| 8875 | 8875 | |
| 8876 | - $allExtends = end($this->allExtendsStack); |
|
| 8876 | + $allExtends = end($this->allExtendsStack); |
|
| 8877 | 8877 | $paths_len = count($rulesetNode->paths); |
| 8878 | 8878 | |
| 8879 | 8879 | // look at each selector path in the ruleset, find any extend matches and then copy, find and replace |
| 8880 | - foreach($allExtends as $allExtend){ |
|
| 8881 | - for($pathIndex = 0; $pathIndex < $paths_len; $pathIndex++ ){ |
|
| 8880 | + foreach ($allExtends as $allExtend) { |
|
| 8881 | + for ($pathIndex = 0; $pathIndex<$paths_len; $pathIndex++) { |
|
| 8882 | 8882 | |
| 8883 | 8883 | // extending extends happens initially, before the main pass |
| 8884 | - if( isset($rulesetNode->extendOnEveryPath) && $rulesetNode->extendOnEveryPath ){ |
|
| 8884 | + if (isset($rulesetNode->extendOnEveryPath) && $rulesetNode->extendOnEveryPath) { |
|
| 8885 | 8885 | continue; |
| 8886 | 8886 | } |
| 8887 | 8887 | |
| 8888 | 8888 | $selectorPath = $rulesetNode->paths[$pathIndex]; |
| 8889 | 8889 | |
| 8890 | - if( end($selectorPath)->extendList ){ |
|
| 8890 | + if (end($selectorPath)->extendList) { |
|
| 8891 | 8891 | continue; |
| 8892 | 8892 | } |
| 8893 | 8893 | |
| 8894 | - $this->ExtendMatch( $rulesetNode, $allExtend, $selectorPath); |
|
| 8894 | + $this->ExtendMatch($rulesetNode, $allExtend, $selectorPath); |
|
| 8895 | 8895 | |
| 8896 | 8896 | } |
| 8897 | 8897 | } |
| 8898 | 8898 | } |
| 8899 | 8899 | |
| 8900 | 8900 | |
| 8901 | - private function ExtendMatch( $rulesetNode, $extend, $selectorPath ){ |
|
| 8901 | + private function ExtendMatch($rulesetNode, $extend, $selectorPath) { |
|
| 8902 | 8902 | $matches = $this->findMatch($extend, $selectorPath); |
| 8903 | 8903 | |
| 8904 | - if( $matches ){ |
|
| 8905 | - foreach($extend->selfSelectors as $selfSelector ){ |
|
| 8904 | + if ($matches) { |
|
| 8905 | + foreach ($extend->selfSelectors as $selfSelector) { |
|
| 8906 | 8906 | $rulesetNode->paths[] = $this->extendSelector($matches, $selectorPath, $selfSelector); |
| 8907 | 8907 | } |
| 8908 | 8908 | } |
@@ -8910,10 +8910,10 @@ discard block |
||
| 8910 | 8910 | |
| 8911 | 8911 | |
| 8912 | 8912 | |
| 8913 | - private function findMatch($extend, $haystackSelectorPath ){ |
|
| 8913 | + private function findMatch($extend, $haystackSelectorPath) { |
|
| 8914 | 8914 | |
| 8915 | 8915 | |
| 8916 | - if( !$this->HasMatches($extend, $haystackSelectorPath) ){ |
|
| 8916 | + if (!$this->HasMatches($extend, $haystackSelectorPath)) { |
|
| 8917 | 8917 | return false; |
| 8918 | 8918 | } |
| 8919 | 8919 | |
@@ -8932,41 +8932,41 @@ discard block |
||
| 8932 | 8932 | |
| 8933 | 8933 | // loop through the haystack elements |
| 8934 | 8934 | $haystack_path_len = count($haystackSelectorPath); |
| 8935 | - for($haystackSelectorIndex = 0; $haystackSelectorIndex < $haystack_path_len; $haystackSelectorIndex++ ){ |
|
| 8935 | + for ($haystackSelectorIndex = 0; $haystackSelectorIndex<$haystack_path_len; $haystackSelectorIndex++) { |
|
| 8936 | 8936 | $hackstackSelector = $haystackSelectorPath[$haystackSelectorIndex]; |
| 8937 | 8937 | |
| 8938 | 8938 | $haystack_elements_len = count($hackstackSelector->elements); |
| 8939 | - for($hackstackElementIndex = 0; $hackstackElementIndex < $haystack_elements_len; $hackstackElementIndex++ ){ |
|
| 8939 | + for ($hackstackElementIndex = 0; $hackstackElementIndex<$haystack_elements_len; $hackstackElementIndex++) { |
|
| 8940 | 8940 | |
| 8941 | 8941 | $haystackElement = $hackstackSelector->elements[$hackstackElementIndex]; |
| 8942 | 8942 | |
| 8943 | 8943 | // if we allow elements before our match we can add a potential match every time. otherwise only at the first element. |
| 8944 | - if( $extend->allowBefore || ($haystackSelectorIndex === 0 && $hackstackElementIndex === 0) ){ |
|
| 8944 | + if ($extend->allowBefore || ($haystackSelectorIndex===0 && $hackstackElementIndex===0)) { |
|
| 8945 | 8945 | $potentialMatches[] = array('pathIndex'=> $haystackSelectorIndex, 'index'=> $hackstackElementIndex, 'matched'=> 0, 'initialCombinator'=> $haystackElement->combinator); |
| 8946 | 8946 | $potentialMatches_len++; |
| 8947 | 8947 | } |
| 8948 | 8948 | |
| 8949 | - for($i = 0; $i < $potentialMatches_len; $i++ ){ |
|
| 8949 | + for ($i = 0; $i<$potentialMatches_len; $i++) { |
|
| 8950 | 8950 | |
| 8951 | 8951 | $potentialMatch = &$potentialMatches[$i]; |
| 8952 | - $potentialMatch = $this->PotentialMatch( $potentialMatch, $needleElements, $haystackElement, $hackstackElementIndex ); |
|
| 8952 | + $potentialMatch = $this->PotentialMatch($potentialMatch, $needleElements, $haystackElement, $hackstackElementIndex); |
|
| 8953 | 8953 | |
| 8954 | 8954 | |
| 8955 | 8955 | // if we are still valid and have finished, test whether we have elements after and whether these are allowed |
| 8956 | - if( $potentialMatch && $potentialMatch['matched'] === $extend->selector->elements_len ){ |
|
| 8956 | + if ($potentialMatch && $potentialMatch['matched']===$extend->selector->elements_len) { |
|
| 8957 | 8957 | $potentialMatch['finished'] = true; |
| 8958 | 8958 | |
| 8959 | - if( !$extend->allowAfter && ($hackstackElementIndex+1 < $haystack_elements_len || $haystackSelectorIndex+1 < $haystack_path_len) ){ |
|
| 8959 | + if (!$extend->allowAfter && ($hackstackElementIndex+1<$haystack_elements_len || $haystackSelectorIndex+1<$haystack_path_len)) { |
|
| 8960 | 8960 | $potentialMatch = null; |
| 8961 | 8961 | } |
| 8962 | 8962 | } |
| 8963 | 8963 | |
| 8964 | 8964 | // if null we remove, if not, we are still valid, so either push as a valid match or continue |
| 8965 | - if( $potentialMatch ){ |
|
| 8966 | - if( $potentialMatch['finished'] ){ |
|
| 8965 | + if ($potentialMatch) { |
|
| 8966 | + if ($potentialMatch['finished']) { |
|
| 8967 | 8967 | $potentialMatch['length'] = $extend->selector->elements_len; |
| 8968 | 8968 | $potentialMatch['endPathIndex'] = $haystackSelectorIndex; |
| 8969 | - $potentialMatch['endPathElementIndex'] = $hackstackElementIndex + 1; // index after end of match |
|
| 8969 | + $potentialMatch['endPathElementIndex'] = $hackstackElementIndex+1; // index after end of match |
|
| 8970 | 8970 | $potentialMatches = array(); // we don't allow matches to overlap, so start matching again |
| 8971 | 8971 | $potentialMatches_len = 0; |
| 8972 | 8972 | $matches[] = $potentialMatch; |
@@ -8987,20 +8987,20 @@ discard block |
||
| 8987 | 8987 | |
| 8988 | 8988 | // Before going through all the nested loops, lets check to see if a match is possible |
| 8989 | 8989 | // Reduces Bootstrap 3.1 compile time from ~6.5s to ~5.6s |
| 8990 | - private function HasMatches($extend, $haystackSelectorPath){ |
|
| 8990 | + private function HasMatches($extend, $haystackSelectorPath) { |
|
| 8991 | 8991 | |
| 8992 | - if( !$extend->selector->cacheable ){ |
|
| 8992 | + if (!$extend->selector->cacheable) { |
|
| 8993 | 8993 | return true; |
| 8994 | 8994 | } |
| 8995 | 8995 | |
| 8996 | 8996 | $first_el = $extend->selector->_oelements[0]; |
| 8997 | 8997 | |
| 8998 | - foreach($haystackSelectorPath as $hackstackSelector){ |
|
| 8999 | - if( !$hackstackSelector->cacheable ){ |
|
| 8998 | + foreach ($haystackSelectorPath as $hackstackSelector) { |
|
| 8999 | + if (!$hackstackSelector->cacheable) { |
|
| 9000 | 9000 | return true; |
| 9001 | 9001 | } |
| 9002 | 9002 | |
| 9003 | - if( in_array($first_el, $hackstackSelector->_oelements) ){ |
|
| 9003 | + if (in_array($first_el, $hackstackSelector->_oelements)) { |
|
| 9004 | 9004 | return true; |
| 9005 | 9005 | } |
| 9006 | 9006 | } |
@@ -9012,26 +9012,26 @@ discard block |
||
| 9012 | 9012 | /** |
| 9013 | 9013 | * @param integer $hackstackElementIndex |
| 9014 | 9014 | */ |
| 9015 | - private function PotentialMatch( $potentialMatch, $needleElements, $haystackElement, $hackstackElementIndex ){ |
|
| 9015 | + private function PotentialMatch($potentialMatch, $needleElements, $haystackElement, $hackstackElementIndex) { |
|
| 9016 | 9016 | |
| 9017 | 9017 | |
| 9018 | - if( $potentialMatch['matched'] > 0 ){ |
|
| 9018 | + if ($potentialMatch['matched']>0) { |
|
| 9019 | 9019 | |
| 9020 | 9020 | // selectors add " " onto the first element. When we use & it joins the selectors together, but if we don't |
| 9021 | 9021 | // then each selector in haystackSelectorPath has a space before it added in the toCSS phase. so we need to work out |
| 9022 | 9022 | // what the resulting combinator will be |
| 9023 | 9023 | $targetCombinator = $haystackElement->combinator; |
| 9024 | - if( $targetCombinator === '' && $hackstackElementIndex === 0 ){ |
|
| 9024 | + if ($targetCombinator==='' && $hackstackElementIndex===0) { |
|
| 9025 | 9025 | $targetCombinator = ' '; |
| 9026 | 9026 | } |
| 9027 | 9027 | |
| 9028 | - if( $needleElements[ $potentialMatch['matched'] ]->combinator !== $targetCombinator ){ |
|
| 9028 | + if ($needleElements[$potentialMatch['matched']]->combinator!==$targetCombinator) { |
|
| 9029 | 9029 | return null; |
| 9030 | 9030 | } |
| 9031 | 9031 | } |
| 9032 | 9032 | |
| 9033 | 9033 | // if we don't match, null our match to indicate failure |
| 9034 | - if( !$this->isElementValuesEqual( $needleElements[$potentialMatch['matched'] ]->value, $haystackElement->value) ){ |
|
| 9034 | + if (!$this->isElementValuesEqual($needleElements[$potentialMatch['matched']]->value, $haystackElement->value)) { |
|
| 9035 | 9035 | return null; |
| 9036 | 9036 | } |
| 9037 | 9037 | |
@@ -9042,23 +9042,23 @@ discard block |
||
| 9042 | 9042 | } |
| 9043 | 9043 | |
| 9044 | 9044 | |
| 9045 | - private function isElementValuesEqual( $elementValue1, $elementValue2 ){ |
|
| 9045 | + private function isElementValuesEqual($elementValue1, $elementValue2) { |
|
| 9046 | 9046 | |
| 9047 | - if( $elementValue1 === $elementValue2 ){ |
|
| 9047 | + if ($elementValue1===$elementValue2) { |
|
| 9048 | 9048 | return true; |
| 9049 | 9049 | } |
| 9050 | 9050 | |
| 9051 | - if( is_string($elementValue1) || is_string($elementValue2) ) { |
|
| 9051 | + if (is_string($elementValue1) || is_string($elementValue2)) { |
|
| 9052 | 9052 | return false; |
| 9053 | 9053 | } |
| 9054 | 9054 | |
| 9055 | - if( $elementValue1 instanceof Less_Tree_Attribute ){ |
|
| 9056 | - return $this->isAttributeValuesEqual( $elementValue1, $elementValue2 ); |
|
| 9055 | + if ($elementValue1 instanceof Less_Tree_Attribute) { |
|
| 9056 | + return $this->isAttributeValuesEqual($elementValue1, $elementValue2); |
|
| 9057 | 9057 | } |
| 9058 | 9058 | |
| 9059 | 9059 | $elementValue1 = $elementValue1->value; |
| 9060 | - if( $elementValue1 instanceof Less_Tree_Selector ){ |
|
| 9061 | - return $this->isSelectorValuesEqual( $elementValue1, $elementValue2 ); |
|
| 9060 | + if ($elementValue1 instanceof Less_Tree_Selector) { |
|
| 9061 | + return $this->isSelectorValuesEqual($elementValue1, $elementValue2); |
|
| 9062 | 9062 | } |
| 9063 | 9063 | |
| 9064 | 9064 | return false; |
@@ -9068,22 +9068,22 @@ discard block |
||
| 9068 | 9068 | /** |
| 9069 | 9069 | * @param Less_Tree_Selector $elementValue1 |
| 9070 | 9070 | */ |
| 9071 | - private function isSelectorValuesEqual( $elementValue1, $elementValue2 ){ |
|
| 9071 | + private function isSelectorValuesEqual($elementValue1, $elementValue2) { |
|
| 9072 | 9072 | |
| 9073 | 9073 | $elementValue2 = $elementValue2->value; |
| 9074 | - if( !($elementValue2 instanceof Less_Tree_Selector) || $elementValue1->elements_len !== $elementValue2->elements_len ){ |
|
| 9074 | + if (!($elementValue2 instanceof Less_Tree_Selector) || $elementValue1->elements_len!==$elementValue2->elements_len) { |
|
| 9075 | 9075 | return false; |
| 9076 | 9076 | } |
| 9077 | 9077 | |
| 9078 | - for( $i = 0; $i < $elementValue1->elements_len; $i++ ){ |
|
| 9078 | + for ($i = 0; $i<$elementValue1->elements_len; $i++) { |
|
| 9079 | 9079 | |
| 9080 | - if( $elementValue1->elements[$i]->combinator !== $elementValue2->elements[$i]->combinator ){ |
|
| 9081 | - if( $i !== 0 || ($elementValue1->elements[$i]->combinator || ' ') !== ($elementValue2->elements[$i]->combinator || ' ') ){ |
|
| 9080 | + if ($elementValue1->elements[$i]->combinator!==$elementValue2->elements[$i]->combinator) { |
|
| 9081 | + if ($i!==0 || ($elementValue1->elements[$i]->combinator || ' ')!==($elementValue2->elements[$i]->combinator || ' ')) { |
|
| 9082 | 9082 | return false; |
| 9083 | 9083 | } |
| 9084 | 9084 | } |
| 9085 | 9085 | |
| 9086 | - if( !$this->isElementValuesEqual($elementValue1->elements[$i]->value, $elementValue2->elements[$i]->value) ){ |
|
| 9086 | + if (!$this->isElementValuesEqual($elementValue1->elements[$i]->value, $elementValue2->elements[$i]->value)) { |
|
| 9087 | 9087 | return false; |
| 9088 | 9088 | } |
| 9089 | 9089 | } |
@@ -9095,27 +9095,27 @@ discard block |
||
| 9095 | 9095 | /** |
| 9096 | 9096 | * @param Less_Tree_Attribute $elementValue1 |
| 9097 | 9097 | */ |
| 9098 | - private function isAttributeValuesEqual( $elementValue1, $elementValue2 ){ |
|
| 9098 | + private function isAttributeValuesEqual($elementValue1, $elementValue2) { |
|
| 9099 | 9099 | |
| 9100 | - if( $elementValue1->op !== $elementValue2->op || $elementValue1->key !== $elementValue2->key ){ |
|
| 9100 | + if ($elementValue1->op!==$elementValue2->op || $elementValue1->key!==$elementValue2->key) { |
|
| 9101 | 9101 | return false; |
| 9102 | 9102 | } |
| 9103 | 9103 | |
| 9104 | - if( !$elementValue1->value || !$elementValue2->value ){ |
|
| 9105 | - if( $elementValue1->value || $elementValue2->value ) { |
|
| 9104 | + if (!$elementValue1->value || !$elementValue2->value) { |
|
| 9105 | + if ($elementValue1->value || $elementValue2->value) { |
|
| 9106 | 9106 | return false; |
| 9107 | 9107 | } |
| 9108 | 9108 | return true; |
| 9109 | 9109 | } |
| 9110 | 9110 | |
| 9111 | - $elementValue1 = ($elementValue1->value->value ? $elementValue1->value->value : $elementValue1->value ); |
|
| 9112 | - $elementValue2 = ($elementValue2->value->value ? $elementValue2->value->value : $elementValue2->value ); |
|
| 9111 | + $elementValue1 = ($elementValue1->value->value ? $elementValue1->value->value : $elementValue1->value); |
|
| 9112 | + $elementValue2 = ($elementValue2->value->value ? $elementValue2->value->value : $elementValue2->value); |
|
| 9113 | 9113 | |
| 9114 | - return $elementValue1 === $elementValue2; |
|
| 9114 | + return $elementValue1===$elementValue2; |
|
| 9115 | 9115 | } |
| 9116 | 9116 | |
| 9117 | 9117 | |
| 9118 | - private function extendSelector($matches, $selectorPath, $replacementSelector){ |
|
| 9118 | + private function extendSelector($matches, $selectorPath, $replacementSelector) { |
|
| 9119 | 9119 | |
| 9120 | 9120 | //for a set of matches, replace each match with the replacement selector |
| 9121 | 9121 | |
@@ -9124,11 +9124,11 @@ discard block |
||
| 9124 | 9124 | $path = array(); |
| 9125 | 9125 | $selectorPath_len = count($selectorPath); |
| 9126 | 9126 | |
| 9127 | - for($matchIndex = 0, $matches_len = count($matches); $matchIndex < $matches_len; $matchIndex++ ){ |
|
| 9127 | + for ($matchIndex = 0, $matches_len = count($matches); $matchIndex<$matches_len; $matchIndex++) { |
|
| 9128 | 9128 | |
| 9129 | 9129 | |
| 9130 | 9130 | $match = $matches[$matchIndex]; |
| 9131 | - $selector = $selectorPath[ $match['pathIndex'] ]; |
|
| 9131 | + $selector = $selectorPath[$match['pathIndex']]; |
|
| 9132 | 9132 | |
| 9133 | 9133 | $firstElement = new Less_Tree_Element( |
| 9134 | 9134 | $match['initialCombinator'], |
@@ -9137,63 +9137,63 @@ discard block |
||
| 9137 | 9137 | $replacementSelector->elements[0]->currentFileInfo |
| 9138 | 9138 | ); |
| 9139 | 9139 | |
| 9140 | - if( $match['pathIndex'] > $currentSelectorPathIndex && $currentSelectorPathElementIndex > 0 ){ |
|
| 9140 | + if ($match['pathIndex']>$currentSelectorPathIndex && $currentSelectorPathElementIndex>0) { |
|
| 9141 | 9141 | $last_path = end($path); |
| 9142 | - $last_path->elements = array_merge( $last_path->elements, array_slice( $selectorPath[$currentSelectorPathIndex]->elements, $currentSelectorPathElementIndex)); |
|
| 9142 | + $last_path->elements = array_merge($last_path->elements, array_slice($selectorPath[$currentSelectorPathIndex]->elements, $currentSelectorPathElementIndex)); |
|
| 9143 | 9143 | $currentSelectorPathElementIndex = 0; |
| 9144 | 9144 | $currentSelectorPathIndex++; |
| 9145 | 9145 | } |
| 9146 | 9146 | |
| 9147 | 9147 | $newElements = array_merge( |
| 9148 | - array_slice($selector->elements, $currentSelectorPathElementIndex, ($match['index'] - $currentSelectorPathElementIndex) ) // last parameter of array_slice is different than the last parameter of javascript's slice |
|
| 9148 | + array_slice($selector->elements, $currentSelectorPathElementIndex, ($match['index']-$currentSelectorPathElementIndex)) // last parameter of array_slice is different than the last parameter of javascript's slice |
|
| 9149 | 9149 | , array($firstElement) |
| 9150 | - , array_slice($replacementSelector->elements,1) |
|
| 9150 | + , array_slice($replacementSelector->elements, 1) |
|
| 9151 | 9151 | ); |
| 9152 | 9152 | |
| 9153 | - if( $currentSelectorPathIndex === $match['pathIndex'] && $matchIndex > 0 ){ |
|
| 9153 | + if ($currentSelectorPathIndex===$match['pathIndex'] && $matchIndex>0) { |
|
| 9154 | 9154 | $last_key = count($path)-1; |
| 9155 | - $path[$last_key]->elements = array_merge($path[$last_key]->elements,$newElements); |
|
| 9156 | - }else{ |
|
| 9157 | - $path = array_merge( $path, array_slice( $selectorPath, $currentSelectorPathIndex, $match['pathIndex'] )); |
|
| 9158 | - $path[] = new Less_Tree_Selector( $newElements ); |
|
| 9155 | + $path[$last_key]->elements = array_merge($path[$last_key]->elements, $newElements); |
|
| 9156 | + }else { |
|
| 9157 | + $path = array_merge($path, array_slice($selectorPath, $currentSelectorPathIndex, $match['pathIndex'])); |
|
| 9158 | + $path[] = new Less_Tree_Selector($newElements); |
|
| 9159 | 9159 | } |
| 9160 | 9160 | |
| 9161 | 9161 | $currentSelectorPathIndex = $match['endPathIndex']; |
| 9162 | 9162 | $currentSelectorPathElementIndex = $match['endPathElementIndex']; |
| 9163 | - if( $currentSelectorPathElementIndex >= count($selectorPath[$currentSelectorPathIndex]->elements) ){ |
|
| 9163 | + if ($currentSelectorPathElementIndex>=count($selectorPath[$currentSelectorPathIndex]->elements)) { |
|
| 9164 | 9164 | $currentSelectorPathElementIndex = 0; |
| 9165 | 9165 | $currentSelectorPathIndex++; |
| 9166 | 9166 | } |
| 9167 | 9167 | } |
| 9168 | 9168 | |
| 9169 | - if( $currentSelectorPathIndex < $selectorPath_len && $currentSelectorPathElementIndex > 0 ){ |
|
| 9169 | + if ($currentSelectorPathIndex<$selectorPath_len && $currentSelectorPathElementIndex>0) { |
|
| 9170 | 9170 | $last_path = end($path); |
| 9171 | - $last_path->elements = array_merge( $last_path->elements, array_slice($selectorPath[$currentSelectorPathIndex]->elements, $currentSelectorPathElementIndex)); |
|
| 9171 | + $last_path->elements = array_merge($last_path->elements, array_slice($selectorPath[$currentSelectorPathIndex]->elements, $currentSelectorPathElementIndex)); |
|
| 9172 | 9172 | $currentSelectorPathIndex++; |
| 9173 | 9173 | } |
| 9174 | 9174 | |
| 9175 | - $slice_len = $selectorPath_len - $currentSelectorPathIndex; |
|
| 9175 | + $slice_len = $selectorPath_len-$currentSelectorPathIndex; |
|
| 9176 | 9176 | $path = array_merge($path, array_slice($selectorPath, $currentSelectorPathIndex, $slice_len)); |
| 9177 | 9177 | |
| 9178 | 9178 | return $path; |
| 9179 | 9179 | } |
| 9180 | 9180 | |
| 9181 | 9181 | |
| 9182 | - protected function visitMedia( $mediaNode ){ |
|
| 9183 | - $newAllExtends = array_merge( $mediaNode->allExtends, end($this->allExtendsStack) ); |
|
| 9182 | + protected function visitMedia($mediaNode) { |
|
| 9183 | + $newAllExtends = array_merge($mediaNode->allExtends, end($this->allExtendsStack)); |
|
| 9184 | 9184 | $this->allExtendsStack[] = $this->doExtendChaining($newAllExtends, $mediaNode->allExtends); |
| 9185 | 9185 | } |
| 9186 | 9186 | |
| 9187 | - protected function visitMediaOut(){ |
|
| 9188 | - array_pop( $this->allExtendsStack ); |
|
| 9187 | + protected function visitMediaOut() { |
|
| 9188 | + array_pop($this->allExtendsStack); |
|
| 9189 | 9189 | } |
| 9190 | 9190 | |
| 9191 | - protected function visitDirective( $directiveNode ){ |
|
| 9192 | - $newAllExtends = array_merge( $directiveNode->allExtends, end($this->allExtendsStack) ); |
|
| 9191 | + protected function visitDirective($directiveNode) { |
|
| 9192 | + $newAllExtends = array_merge($directiveNode->allExtends, end($this->allExtendsStack)); |
|
| 9193 | 9193 | $this->allExtendsStack[] = $this->doExtendChaining($newAllExtends, $directiveNode->allExtends); |
| 9194 | 9194 | } |
| 9195 | 9195 | |
| 9196 | - protected function visitDirectiveOut(){ |
|
| 9196 | + protected function visitDirectiveOut() { |
|
| 9197 | 9197 | array_pop($this->allExtendsStack); |
| 9198 | 9198 | } |
| 9199 | 9199 | |
@@ -9205,65 +9205,65 @@ discard block |
||
| 9205 | 9205 | * @package Less |
| 9206 | 9206 | * @subpackage visitor |
| 9207 | 9207 | */ |
| 9208 | -class Less_Visitor_toCSS extends Less_VisitorReplacing{ |
|
| 9208 | +class Less_Visitor_toCSS extends Less_VisitorReplacing { |
|
| 9209 | 9209 | |
| 9210 | 9210 | private $charset; |
| 9211 | 9211 | |
| 9212 | - public function __construct(){ |
|
| 9212 | + public function __construct() { |
|
| 9213 | 9213 | parent::__construct(); |
| 9214 | 9214 | } |
| 9215 | 9215 | |
| 9216 | 9216 | /** |
| 9217 | 9217 | * @param Less_Tree_Ruleset $root |
| 9218 | 9218 | */ |
| 9219 | - public function run( $root ){ |
|
| 9219 | + public function run($root) { |
|
| 9220 | 9220 | return $this->visitObj($root); |
| 9221 | 9221 | } |
| 9222 | 9222 | |
| 9223 | - public function visitRule( $ruleNode ){ |
|
| 9224 | - if( $ruleNode->variable ){ |
|
| 9223 | + public function visitRule($ruleNode) { |
|
| 9224 | + if ($ruleNode->variable) { |
|
| 9225 | 9225 | return array(); |
| 9226 | 9226 | } |
| 9227 | 9227 | return $ruleNode; |
| 9228 | 9228 | } |
| 9229 | 9229 | |
| 9230 | - public function visitMixinDefinition($mixinNode){ |
|
| 9230 | + public function visitMixinDefinition($mixinNode) { |
|
| 9231 | 9231 | // mixin definitions do not get eval'd - this means they keep state |
| 9232 | 9232 | // so we have to clear that state here so it isn't used if toCSS is called twice |
| 9233 | 9233 | $mixinNode->frames = array(); |
| 9234 | 9234 | return array(); |
| 9235 | 9235 | } |
| 9236 | 9236 | |
| 9237 | - public function visitExtend(){ |
|
| 9237 | + public function visitExtend() { |
|
| 9238 | 9238 | return array(); |
| 9239 | 9239 | } |
| 9240 | 9240 | |
| 9241 | - public function visitComment( $commentNode ){ |
|
| 9242 | - if( $commentNode->isSilent() ){ |
|
| 9241 | + public function visitComment($commentNode) { |
|
| 9242 | + if ($commentNode->isSilent()) { |
|
| 9243 | 9243 | return array(); |
| 9244 | 9244 | } |
| 9245 | 9245 | return $commentNode; |
| 9246 | 9246 | } |
| 9247 | 9247 | |
| 9248 | - public function visitMedia( $mediaNode, &$visitDeeper ){ |
|
| 9248 | + public function visitMedia($mediaNode, &$visitDeeper) { |
|
| 9249 | 9249 | $mediaNode->accept($this); |
| 9250 | 9250 | $visitDeeper = false; |
| 9251 | 9251 | |
| 9252 | - if( !$mediaNode->rules ){ |
|
| 9252 | + if (!$mediaNode->rules) { |
|
| 9253 | 9253 | return array(); |
| 9254 | 9254 | } |
| 9255 | 9255 | return $mediaNode; |
| 9256 | 9256 | } |
| 9257 | 9257 | |
| 9258 | - public function visitDirective( $directiveNode ){ |
|
| 9259 | - if( isset($directiveNode->currentFileInfo['reference']) && (!property_exists($directiveNode,'isReferenced') || !$directiveNode->isReferenced) ){ |
|
| 9258 | + public function visitDirective($directiveNode) { |
|
| 9259 | + if (isset($directiveNode->currentFileInfo['reference']) && (!property_exists($directiveNode, 'isReferenced') || !$directiveNode->isReferenced)) { |
|
| 9260 | 9260 | return array(); |
| 9261 | 9261 | } |
| 9262 | - if( $directiveNode->name === '@charset' ){ |
|
| 9262 | + if ($directiveNode->name==='@charset') { |
|
| 9263 | 9263 | // Only output the debug info together with subsequent @charset definitions |
| 9264 | 9264 | // a comment (or @media statement) before the actual @charset directive would |
| 9265 | 9265 | // be considered illegal css as it has to be on the first line |
| 9266 | - if( isset($this->charset) && $this->charset ){ |
|
| 9266 | + if (isset($this->charset) && $this->charset) { |
|
| 9267 | 9267 | |
| 9268 | 9268 | //if( $directiveNode->debugInfo ){ |
| 9269 | 9269 | // $comment = new Less_Tree_Comment('/* ' . str_replace("\n",'',$directiveNode->toCSS())." */\n"); |
@@ -9279,14 +9279,14 @@ discard block |
||
| 9279 | 9279 | return $directiveNode; |
| 9280 | 9280 | } |
| 9281 | 9281 | |
| 9282 | - public function checkPropertiesInRoot( $rulesetNode ){ |
|
| 9282 | + public function checkPropertiesInRoot($rulesetNode) { |
|
| 9283 | 9283 | |
| 9284 | - if( !$rulesetNode->firstRoot ){ |
|
| 9284 | + if (!$rulesetNode->firstRoot) { |
|
| 9285 | 9285 | return; |
| 9286 | 9286 | } |
| 9287 | 9287 | |
| 9288 | - foreach($rulesetNode->rules as $ruleNode){ |
|
| 9289 | - if( $ruleNode instanceof Less_Tree_Rule && !$ruleNode->variable ){ |
|
| 9288 | + foreach ($rulesetNode->rules as $ruleNode) { |
|
| 9289 | + if ($ruleNode instanceof Less_Tree_Rule && !$ruleNode->variable) { |
|
| 9290 | 9290 | $msg = "properties must be inside selector blocks, they cannot be in the root. Index ".$ruleNode->index.($ruleNode->currentFileInfo ? (' Filename: '.$ruleNode->currentFileInfo['filename']) : null); |
| 9291 | 9291 | throw new Less_Exception_Compiler($msg); |
| 9292 | 9292 | } |
@@ -9294,14 +9294,14 @@ discard block |
||
| 9294 | 9294 | } |
| 9295 | 9295 | |
| 9296 | 9296 | |
| 9297 | - public function visitRuleset( $rulesetNode, &$visitDeeper ){ |
|
| 9297 | + public function visitRuleset($rulesetNode, &$visitDeeper) { |
|
| 9298 | 9298 | |
| 9299 | 9299 | $visitDeeper = false; |
| 9300 | 9300 | |
| 9301 | - $this->checkPropertiesInRoot( $rulesetNode ); |
|
| 9301 | + $this->checkPropertiesInRoot($rulesetNode); |
|
| 9302 | 9302 | |
| 9303 | - if( $rulesetNode->root ){ |
|
| 9304 | - return $this->visitRulesetRoot( $rulesetNode ); |
|
| 9303 | + if ($rulesetNode->root) { |
|
| 9304 | + return $this->visitRulesetRoot($rulesetNode); |
|
| 9305 | 9305 | } |
| 9306 | 9306 | |
| 9307 | 9307 | $rulesets = array(); |
@@ -9310,13 +9310,13 @@ discard block |
||
| 9310 | 9310 | |
| 9311 | 9311 | // Compile rules and rulesets |
| 9312 | 9312 | $nodeRuleCnt = count($rulesetNode->rules); |
| 9313 | - for( $i = 0; $i < $nodeRuleCnt; ){ |
|
| 9313 | + for ($i = 0; $i<$nodeRuleCnt;) { |
|
| 9314 | 9314 | $rule = $rulesetNode->rules[$i]; |
| 9315 | 9315 | |
| 9316 | - if( property_exists($rule,'rules') ){ |
|
| 9316 | + if (property_exists($rule, 'rules')) { |
|
| 9317 | 9317 | // visit because we are moving them out from being a child |
| 9318 | 9318 | $rulesets[] = $this->visitObj($rule); |
| 9319 | - array_splice($rulesetNode->rules,$i,1); |
|
| 9319 | + array_splice($rulesetNode->rules, $i, 1); |
|
| 9320 | 9320 | $nodeRuleCnt--; |
| 9321 | 9321 | continue; |
| 9322 | 9322 | } |
@@ -9326,27 +9326,27 @@ discard block |
||
| 9326 | 9326 | |
| 9327 | 9327 | // accept the visitor to remove rules and refactor itself |
| 9328 | 9328 | // then we can decide now whether we want it or not |
| 9329 | - if( $nodeRuleCnt > 0 ){ |
|
| 9329 | + if ($nodeRuleCnt>0) { |
|
| 9330 | 9330 | $rulesetNode->accept($this); |
| 9331 | 9331 | |
| 9332 | - if( $rulesetNode->rules ){ |
|
| 9332 | + if ($rulesetNode->rules) { |
|
| 9333 | 9333 | |
| 9334 | - if( count($rulesetNode->rules) > 1 ){ |
|
| 9335 | - $this->_mergeRules( $rulesetNode->rules ); |
|
| 9336 | - $this->_removeDuplicateRules( $rulesetNode->rules ); |
|
| 9334 | + if (count($rulesetNode->rules)>1) { |
|
| 9335 | + $this->_mergeRules($rulesetNode->rules); |
|
| 9336 | + $this->_removeDuplicateRules($rulesetNode->rules); |
|
| 9337 | 9337 | } |
| 9338 | 9338 | |
| 9339 | 9339 | // now decide whether we keep the ruleset |
| 9340 | - if( $rulesetNode->paths ){ |
|
| 9340 | + if ($rulesetNode->paths) { |
|
| 9341 | 9341 | //array_unshift($rulesets, $rulesetNode); |
| 9342 | - array_splice($rulesets,0,0,array($rulesetNode)); |
|
| 9342 | + array_splice($rulesets, 0, 0, array($rulesetNode)); |
|
| 9343 | 9343 | } |
| 9344 | 9344 | } |
| 9345 | 9345 | |
| 9346 | 9346 | } |
| 9347 | 9347 | |
| 9348 | 9348 | |
| 9349 | - if( count($rulesets) === 1 ){ |
|
| 9349 | + if (count($rulesets)===1) { |
|
| 9350 | 9350 | return $rulesets[0]; |
| 9351 | 9351 | } |
| 9352 | 9352 | return $rulesets; |
@@ -9358,9 +9358,9 @@ discard block |
||
| 9358 | 9358 | * |
| 9359 | 9359 | * return array|Less_Tree_Ruleset |
| 9360 | 9360 | */ |
| 9361 | - private function visitRulesetRoot( $rulesetNode ){ |
|
| 9362 | - $rulesetNode->accept( $this ); |
|
| 9363 | - if( $rulesetNode->firstRoot || $rulesetNode->rules ){ |
|
| 9361 | + private function visitRulesetRoot($rulesetNode) { |
|
| 9362 | + $rulesetNode->accept($this); |
|
| 9363 | + if ($rulesetNode->firstRoot || $rulesetNode->rules) { |
|
| 9364 | 9364 | return $rulesetNode; |
| 9365 | 9365 | } |
| 9366 | 9366 | return array(); |
@@ -9372,16 +9372,16 @@ discard block |
||
| 9372 | 9372 | * |
| 9373 | 9373 | * @return array |
| 9374 | 9374 | */ |
| 9375 | - private function visitRulesetPaths($rulesetNode){ |
|
| 9375 | + private function visitRulesetPaths($rulesetNode) { |
|
| 9376 | 9376 | |
| 9377 | 9377 | $paths = array(); |
| 9378 | - foreach($rulesetNode->paths as $p){ |
|
| 9379 | - if( $p[0]->elements[0]->combinator === ' ' ){ |
|
| 9378 | + foreach ($rulesetNode->paths as $p) { |
|
| 9379 | + if ($p[0]->elements[0]->combinator===' ') { |
|
| 9380 | 9380 | $p[0]->elements[0]->combinator = ''; |
| 9381 | 9381 | } |
| 9382 | 9382 | |
| 9383 | - foreach($p as $pi){ |
|
| 9384 | - if( $pi->getIsReferenced() && $pi->getIsOutput() ){ |
|
| 9383 | + foreach ($p as $pi) { |
|
| 9384 | + if ($pi->getIsReferenced() && $pi->getIsOutput()) { |
|
| 9385 | 9385 | $paths[] = $p; |
| 9386 | 9386 | break; |
| 9387 | 9387 | } |
@@ -9391,26 +9391,26 @@ discard block |
||
| 9391 | 9391 | return $paths; |
| 9392 | 9392 | } |
| 9393 | 9393 | |
| 9394 | - protected function _removeDuplicateRules( &$rules ){ |
|
| 9394 | + protected function _removeDuplicateRules(&$rules) { |
|
| 9395 | 9395 | // remove duplicates |
| 9396 | 9396 | $ruleCache = array(); |
| 9397 | - for( $i = count($rules)-1; $i >= 0 ; $i-- ){ |
|
| 9397 | + for ($i = count($rules)-1; $i>=0; $i--) { |
|
| 9398 | 9398 | $rule = $rules[$i]; |
| 9399 | - if( $rule instanceof Less_Tree_Rule || $rule instanceof Less_Tree_NameValue ){ |
|
| 9399 | + if ($rule instanceof Less_Tree_Rule || $rule instanceof Less_Tree_NameValue) { |
|
| 9400 | 9400 | |
| 9401 | - if( !isset($ruleCache[$rule->name]) ){ |
|
| 9401 | + if (!isset($ruleCache[$rule->name])) { |
|
| 9402 | 9402 | $ruleCache[$rule->name] = $rule; |
| 9403 | - }else{ |
|
| 9404 | - $ruleList =& $ruleCache[$rule->name]; |
|
| 9403 | + }else { |
|
| 9404 | + $ruleList = & $ruleCache[$rule->name]; |
|
| 9405 | 9405 | |
| 9406 | - if( $ruleList instanceof Less_Tree_Rule || $ruleList instanceof Less_Tree_NameValue ){ |
|
| 9407 | - $ruleList = $ruleCache[$rule->name] = array( $ruleCache[$rule->name]->toCSS() ); |
|
| 9406 | + if ($ruleList instanceof Less_Tree_Rule || $ruleList instanceof Less_Tree_NameValue) { |
|
| 9407 | + $ruleList = $ruleCache[$rule->name] = array($ruleCache[$rule->name]->toCSS()); |
|
| 9408 | 9408 | } |
| 9409 | 9409 | |
| 9410 | 9410 | $ruleCSS = $rule->toCSS(); |
| 9411 | - if( array_search($ruleCSS,$ruleList) !== false ){ |
|
| 9412 | - array_splice($rules,$i,1); |
|
| 9413 | - }else{ |
|
| 9411 | + if (array_search($ruleCSS, $ruleList)!==false) { |
|
| 9412 | + array_splice($rules, $i, 1); |
|
| 9413 | + }else { |
|
| 9414 | 9414 | $ruleList[] = $ruleCSS; |
| 9415 | 9415 | } |
| 9416 | 9416 | } |
@@ -9418,25 +9418,25 @@ discard block |
||
| 9418 | 9418 | } |
| 9419 | 9419 | } |
| 9420 | 9420 | |
| 9421 | - protected function _mergeRules( &$rules ){ |
|
| 9421 | + protected function _mergeRules(&$rules) { |
|
| 9422 | 9422 | $groups = array(); |
| 9423 | 9423 | |
| 9424 | 9424 | //obj($rules); |
| 9425 | 9425 | |
| 9426 | 9426 | $rules_len = count($rules); |
| 9427 | - for( $i = 0; $i < $rules_len; $i++ ){ |
|
| 9427 | + for ($i = 0; $i<$rules_len; $i++) { |
|
| 9428 | 9428 | $rule = $rules[$i]; |
| 9429 | 9429 | |
| 9430 | - if( ($rule instanceof Less_Tree_Rule) && $rule->merge ){ |
|
| 9430 | + if (($rule instanceof Less_Tree_Rule) && $rule->merge) { |
|
| 9431 | 9431 | |
| 9432 | 9432 | $key = $rule->name; |
| 9433 | - if( $rule->important ){ |
|
| 9433 | + if ($rule->important) { |
|
| 9434 | 9434 | $key .= ',!'; |
| 9435 | 9435 | } |
| 9436 | 9436 | |
| 9437 | - if( !isset($groups[$key]) ){ |
|
| 9437 | + if (!isset($groups[$key])) { |
|
| 9438 | 9438 | $groups[$key] = array(); |
| 9439 | - }else{ |
|
| 9439 | + }else { |
|
| 9440 | 9440 | array_splice($rules, $i--, 1); |
| 9441 | 9441 | $rules_len--; |
| 9442 | 9442 | } |
@@ -9446,16 +9446,16 @@ discard block |
||
| 9446 | 9446 | } |
| 9447 | 9447 | |
| 9448 | 9448 | |
| 9449 | - foreach($groups as $parts){ |
|
| 9449 | + foreach ($groups as $parts) { |
|
| 9450 | 9450 | |
| 9451 | - if( count($parts) > 1 ){ |
|
| 9451 | + if (count($parts)>1) { |
|
| 9452 | 9452 | $rule = $parts[0]; |
| 9453 | 9453 | $spacedGroups = array(); |
| 9454 | 9454 | $lastSpacedGroup = array(); |
| 9455 | 9455 | $parts_mapped = array(); |
| 9456 | - foreach($parts as $p){ |
|
| 9457 | - if( $p->merge === '+' ){ |
|
| 9458 | - if( $lastSpacedGroup ){ |
|
| 9456 | + foreach ($parts as $p) { |
|
| 9457 | + if ($p->merge==='+') { |
|
| 9458 | + if ($lastSpacedGroup) { |
|
| 9459 | 9459 | $spacedGroups[] = self::toExpression($lastSpacedGroup); |
| 9460 | 9460 | } |
| 9461 | 9461 | $lastSpacedGroup = array(); |
@@ -9470,19 +9470,19 @@ discard block |
||
| 9470 | 9470 | |
| 9471 | 9471 | } |
| 9472 | 9472 | |
| 9473 | - public static function toExpression($values){ |
|
| 9473 | + public static function toExpression($values) { |
|
| 9474 | 9474 | $mapped = array(); |
| 9475 | - foreach($values as $p){ |
|
| 9475 | + foreach ($values as $p) { |
|
| 9476 | 9476 | $mapped[] = $p->value; |
| 9477 | 9477 | } |
| 9478 | - return new Less_Tree_Expression( $mapped ); |
|
| 9478 | + return new Less_Tree_Expression($mapped); |
|
| 9479 | 9479 | } |
| 9480 | 9480 | |
| 9481 | - public static function toValue($values){ |
|
| 9481 | + public static function toValue($values) { |
|
| 9482 | 9482 | //return new Less_Tree_Value($values); ?? |
| 9483 | 9483 | |
| 9484 | 9484 | $mapped = array(); |
| 9485 | - foreach($values as $p){ |
|
| 9485 | + foreach ($values as $p) { |
|
| 9486 | 9486 | $mapped[] = $p; |
| 9487 | 9487 | } |
| 9488 | 9488 | return new Less_Tree_Value($mapped); |
@@ -9497,7 +9497,7 @@ discard block |
||
| 9497 | 9497 | * @package Less |
| 9498 | 9498 | * @subpackage exception |
| 9499 | 9499 | */ |
| 9500 | -class Less_Exception_Parser extends Exception{ |
|
| 9500 | +class Less_Exception_Parser extends Exception { |
|
| 9501 | 9501 | |
| 9502 | 9502 | /** |
| 9503 | 9503 | * The current file |
@@ -9527,12 +9527,12 @@ discard block |
||
| 9527 | 9527 | * @param Less_FileInfo|string $currentFile The file |
| 9528 | 9528 | * @param integer $code The exception code |
| 9529 | 9529 | */ |
| 9530 | - public function __construct($message = null, Exception $previous = null, $index = null, $currentFile = null, $code = 0){ |
|
| 9530 | + public function __construct($message = null, Exception $previous = null, $index = null, $currentFile = null, $code = 0) { |
|
| 9531 | 9531 | |
| 9532 | - if (PHP_VERSION_ID < 50300) { |
|
| 9532 | + if (PHP_VERSION_ID<50300) { |
|
| 9533 | 9533 | $this->previous = $previous; |
| 9534 | 9534 | parent::__construct($message, $code); |
| 9535 | - } else { |
|
| 9535 | + }else { |
|
| 9536 | 9536 | parent::__construct($message, $code, $previous); |
| 9537 | 9537 | } |
| 9538 | 9538 | |
@@ -9543,10 +9543,10 @@ discard block |
||
| 9543 | 9543 | } |
| 9544 | 9544 | |
| 9545 | 9545 | |
| 9546 | - protected function getInput(){ |
|
| 9546 | + protected function getInput() { |
|
| 9547 | 9547 | |
| 9548 | - if( !$this->input && $this->currentFile && $this->currentFile['filename'] && file_exists($this->currentFile['filename']) ){ |
|
| 9549 | - $this->input = file_get_contents( $this->currentFile['filename'] ); |
|
| 9548 | + if (!$this->input && $this->currentFile && $this->currentFile['filename'] && file_exists($this->currentFile['filename'])) { |
|
| 9549 | + $this->input = file_get_contents($this->currentFile['filename']); |
|
| 9550 | 9550 | } |
| 9551 | 9551 | } |
| 9552 | 9552 | |
@@ -9557,26 +9557,26 @@ discard block |
||
| 9557 | 9557 | * |
| 9558 | 9558 | * @return string |
| 9559 | 9559 | */ |
| 9560 | - public function genMessage(){ |
|
| 9560 | + public function genMessage() { |
|
| 9561 | 9561 | |
| 9562 | - if( $this->currentFile && $this->currentFile['filename'] ){ |
|
| 9562 | + if ($this->currentFile && $this->currentFile['filename']) { |
|
| 9563 | 9563 | $this->message .= ' in '.basename($this->currentFile['filename']); |
| 9564 | 9564 | } |
| 9565 | 9565 | |
| 9566 | - if( $this->index !== null ){ |
|
| 9566 | + if ($this->index!==null) { |
|
| 9567 | 9567 | $this->getInput(); |
| 9568 | - if( $this->input ){ |
|
| 9568 | + if ($this->input) { |
|
| 9569 | 9569 | $line = self::getLineNumber(); |
| 9570 | 9570 | $this->message .= ' on line '.$line.', column '.self::getColumn(); |
| 9571 | 9571 | |
| 9572 | - $lines = explode("\n",$this->input); |
|
| 9572 | + $lines = explode("\n", $this->input); |
|
| 9573 | 9573 | |
| 9574 | 9574 | $count = count($lines); |
| 9575 | 9575 | $start_line = max(0, $line-3); |
| 9576 | 9576 | $last_line = min($count, $start_line+6); |
| 9577 | 9577 | $num_len = strlen($last_line); |
| 9578 | - for( $i = $start_line; $i < $last_line; $i++ ){ |
|
| 9579 | - $this->message .= "\n".str_pad($i+1,$num_len,'0',STR_PAD_LEFT).'| '.$lines[$i]; |
|
| 9578 | + for ($i = $start_line; $i<$last_line; $i++) { |
|
| 9579 | + $this->message .= "\n".str_pad($i+1, $num_len, '0', STR_PAD_LEFT).'| '.$lines[$i]; |
|
| 9580 | 9580 | } |
| 9581 | 9581 | } |
| 9582 | 9582 | } |
@@ -9588,13 +9588,13 @@ discard block |
||
| 9588 | 9588 | * |
| 9589 | 9589 | * @return integer |
| 9590 | 9590 | */ |
| 9591 | - public function getLineNumber(){ |
|
| 9592 | - if( $this->index ){ |
|
| 9591 | + public function getLineNumber() { |
|
| 9592 | + if ($this->index) { |
|
| 9593 | 9593 | // https://bugs.php.net/bug.php?id=49790 |
| 9594 | 9594 | if (ini_get("mbstring.func_overload")) { |
| 9595 | - return substr_count(substr($this->input, 0, $this->index), "\n") + 1; |
|
| 9596 | - } else { |
|
| 9597 | - return substr_count($this->input, "\n", 0, $this->index) + 1; |
|
| 9595 | + return substr_count(substr($this->input, 0, $this->index), "\n")+1; |
|
| 9596 | + }else { |
|
| 9597 | + return substr_count($this->input, "\n", 0, $this->index)+1; |
|
| 9598 | 9598 | } |
| 9599 | 9599 | } |
| 9600 | 9600 | return 1; |
@@ -9606,11 +9606,11 @@ discard block |
||
| 9606 | 9606 | * |
| 9607 | 9607 | * @return integer |
| 9608 | 9608 | */ |
| 9609 | - public function getColumn(){ |
|
| 9609 | + public function getColumn() { |
|
| 9610 | 9610 | |
| 9611 | 9611 | $part = substr($this->input, 0, $this->index); |
| 9612 | - $pos = strrpos($part,"\n"); |
|
| 9613 | - return $this->index - $pos; |
|
| 9612 | + $pos = strrpos($part, "\n"); |
|
| 9613 | + return $this->index-$pos; |
|
| 9614 | 9614 | } |
| 9615 | 9615 | |
| 9616 | 9616 | } |
@@ -9622,7 +9622,7 @@ discard block |
||
| 9622 | 9622 | * @package Less |
| 9623 | 9623 | * @subpackage exception |
| 9624 | 9624 | */ |
| 9625 | -class Less_Exception_Chunk extends Less_Exception_Parser{ |
|
| 9625 | +class Less_Exception_Chunk extends Less_Exception_Parser { |
|
| 9626 | 9626 | |
| 9627 | 9627 | |
| 9628 | 9628 | protected $parserCurrentIndex = 0; |
@@ -9641,7 +9641,7 @@ discard block |
||
| 9641 | 9641 | * @param Less_FileInfo|string $currentFile The file |
| 9642 | 9642 | * @param integer $code The exception code |
| 9643 | 9643 | */ |
| 9644 | - public function __construct($input, Exception $previous = null, $index = null, $currentFile = null, $code = 0){ |
|
| 9644 | + public function __construct($input, Exception $previous = null, $index = null, $currentFile = null, $code = 0) { |
|
| 9645 | 9645 | |
| 9646 | 9646 | $this->message = 'ParseError: Unexpected input'; //default message |
| 9647 | 9647 | |
@@ -9662,7 +9662,7 @@ discard block |
||
| 9662 | 9662 | * We don't actually need the chunks |
| 9663 | 9663 | * |
| 9664 | 9664 | */ |
| 9665 | - protected function Chunks(){ |
|
| 9665 | + protected function Chunks() { |
|
| 9666 | 9666 | $level = 0; |
| 9667 | 9667 | $parenLevel = 0; |
| 9668 | 9668 | $lastMultiCommentEndBrace = null; |
@@ -9670,9 +9670,9 @@ discard block |
||
| 9670 | 9670 | $lastMultiComment = null; |
| 9671 | 9671 | $lastParen = null; |
| 9672 | 9672 | |
| 9673 | - for( $this->parserCurrentIndex = 0; $this->parserCurrentIndex < $this->input_len; $this->parserCurrentIndex++ ){ |
|
| 9673 | + for ($this->parserCurrentIndex = 0; $this->parserCurrentIndex<$this->input_len; $this->parserCurrentIndex++) { |
|
| 9674 | 9674 | $cc = $this->CharCode($this->parserCurrentIndex); |
| 9675 | - if ((($cc >= 97) && ($cc <= 122)) || ($cc < 34)) { |
|
| 9675 | + if ((($cc>=97) && ($cc<=122)) || ($cc<34)) { |
|
| 9676 | 9676 | // a-z or whitespace |
| 9677 | 9677 | continue; |
| 9678 | 9678 | } |
@@ -9688,7 +9688,7 @@ discard block |
||
| 9688 | 9688 | // ) |
| 9689 | 9689 | case 41: |
| 9690 | 9690 | $parenLevel--; |
| 9691 | - if( $parenLevel < 0 ){ |
|
| 9691 | + if ($parenLevel<0) { |
|
| 9692 | 9692 | return $this->fail("missing opening `(`"); |
| 9693 | 9693 | } |
| 9694 | 9694 | continue; |
@@ -9707,7 +9707,7 @@ discard block |
||
| 9707 | 9707 | // } |
| 9708 | 9708 | case 125: |
| 9709 | 9709 | $level--; |
| 9710 | - if( $level < 0 ){ |
|
| 9710 | + if ($level<0) { |
|
| 9711 | 9711 | return $this->fail("missing opening `{`"); |
| 9712 | 9712 | |
| 9713 | 9713 | } |
@@ -9715,7 +9715,7 @@ discard block |
||
| 9715 | 9715 | continue; |
| 9716 | 9716 | // \ |
| 9717 | 9717 | case 92: |
| 9718 | - if ($this->parserCurrentIndex < $this->input_len - 1) { $this->parserCurrentIndex++; continue; } |
|
| 9718 | + if ($this->parserCurrentIndex<$this->input_len-1) { $this->parserCurrentIndex++; continue; } |
|
| 9719 | 9719 | return $this->fail("unescaped `\\`"); |
| 9720 | 9720 | |
| 9721 | 9721 | // ", ' and ` |
@@ -9724,40 +9724,40 @@ discard block |
||
| 9724 | 9724 | case 96: |
| 9725 | 9725 | $matched = 0; |
| 9726 | 9726 | $currentChunkStartIndex = $this->parserCurrentIndex; |
| 9727 | - for ($this->parserCurrentIndex = $this->parserCurrentIndex + 1; $this->parserCurrentIndex < $this->input_len; $this->parserCurrentIndex++) { |
|
| 9727 | + for ($this->parserCurrentIndex = $this->parserCurrentIndex+1; $this->parserCurrentIndex<$this->input_len; $this->parserCurrentIndex++) { |
|
| 9728 | 9728 | $cc2 = $this->CharCode($this->parserCurrentIndex); |
| 9729 | - if ($cc2 > 96) { continue; } |
|
| 9730 | - if ($cc2 == $cc) { $matched = 1; break; } |
|
| 9731 | - if ($cc2 == 92) { // \ |
|
| 9732 | - if ($this->parserCurrentIndex == $this->input_len - 1) { |
|
| 9729 | + if ($cc2>96) { continue; } |
|
| 9730 | + if ($cc2==$cc) { $matched = 1; break; } |
|
| 9731 | + if ($cc2==92) { // \ |
|
| 9732 | + if ($this->parserCurrentIndex==$this->input_len-1) { |
|
| 9733 | 9733 | return $this->fail("unescaped `\\`"); |
| 9734 | 9734 | } |
| 9735 | 9735 | $this->parserCurrentIndex++; |
| 9736 | 9736 | } |
| 9737 | 9737 | } |
| 9738 | 9738 | if ($matched) { continue; } |
| 9739 | - return $this->fail("unmatched `" + chr($cc) + "`", $currentChunkStartIndex); |
|
| 9739 | + return $this->fail("unmatched `" +chr($cc)+"`", $currentChunkStartIndex); |
|
| 9740 | 9740 | |
| 9741 | 9741 | // /, check for comment |
| 9742 | 9742 | case 47: |
| 9743 | - if ($parenLevel || ($this->parserCurrentIndex == $this->input_len - 1)) { continue; } |
|
| 9743 | + if ($parenLevel || ($this->parserCurrentIndex==$this->input_len-1)) { continue; } |
|
| 9744 | 9744 | $cc2 = $this->CharCode($this->parserCurrentIndex+1); |
| 9745 | - if ($cc2 == 47) { |
|
| 9745 | + if ($cc2==47) { |
|
| 9746 | 9746 | // //, find lnfeed |
| 9747 | - for ($this->parserCurrentIndex = $this->parserCurrentIndex + 2; $this->parserCurrentIndex < $this->input_len; $this->parserCurrentIndex++) { |
|
| 9747 | + for ($this->parserCurrentIndex = $this->parserCurrentIndex+2; $this->parserCurrentIndex<$this->input_len; $this->parserCurrentIndex++) { |
|
| 9748 | 9748 | $cc2 = $this->CharCode($this->parserCurrentIndex); |
| 9749 | - if (($cc2 <= 13) && (($cc2 == 10) || ($cc2 == 13))) { break; } |
|
| 9749 | + if (($cc2<=13) && (($cc2==10) || ($cc2==13))) { break; } |
|
| 9750 | 9750 | } |
| 9751 | - } else if ($cc2 == 42) { |
|
| 9751 | + }else if ($cc2==42) { |
|
| 9752 | 9752 | // /*, find */ |
| 9753 | 9753 | $lastMultiComment = $currentChunkStartIndex = $this->parserCurrentIndex; |
| 9754 | - for ($this->parserCurrentIndex = $this->parserCurrentIndex + 2; $this->parserCurrentIndex < $this->input_len - 1; $this->parserCurrentIndex++) { |
|
| 9754 | + for ($this->parserCurrentIndex = $this->parserCurrentIndex+2; $this->parserCurrentIndex<$this->input_len-1; $this->parserCurrentIndex++) { |
|
| 9755 | 9755 | $cc2 = $this->CharCode($this->parserCurrentIndex); |
| 9756 | - if ($cc2 == 125) { $lastMultiCommentEndBrace = $this->parserCurrentIndex; } |
|
| 9757 | - if ($cc2 != 42) { continue; } |
|
| 9758 | - if ($this->CharCode($this->parserCurrentIndex+1) == 47) { break; } |
|
| 9756 | + if ($cc2==125) { $lastMultiCommentEndBrace = $this->parserCurrentIndex; } |
|
| 9757 | + if ($cc2!=42) { continue; } |
|
| 9758 | + if ($this->CharCode($this->parserCurrentIndex+1)==47) { break; } |
|
| 9759 | 9759 | } |
| 9760 | - if ($this->parserCurrentIndex == $this->input_len - 1) { |
|
| 9760 | + if ($this->parserCurrentIndex==$this->input_len-1) { |
|
| 9761 | 9761 | return $this->fail("missing closing `*/`", $currentChunkStartIndex); |
| 9762 | 9762 | } |
| 9763 | 9763 | } |
@@ -9765,20 +9765,20 @@ discard block |
||
| 9765 | 9765 | |
| 9766 | 9766 | // *, check for unmatched */ |
| 9767 | 9767 | case 42: |
| 9768 | - if (($this->parserCurrentIndex < $this->input_len - 1) && ($this->CharCode($this->parserCurrentIndex+1) == 47)) { |
|
| 9768 | + if (($this->parserCurrentIndex<$this->input_len-1) && ($this->CharCode($this->parserCurrentIndex+1)==47)) { |
|
| 9769 | 9769 | return $this->fail("unmatched `/*`"); |
| 9770 | 9770 | } |
| 9771 | 9771 | continue; |
| 9772 | 9772 | } |
| 9773 | 9773 | } |
| 9774 | 9774 | |
| 9775 | - if( $level !== 0 ){ |
|
| 9776 | - if( ($lastMultiComment > $lastOpening) && ($lastMultiCommentEndBrace > $lastMultiComment) ){ |
|
| 9775 | + if ($level!==0) { |
|
| 9776 | + if (($lastMultiComment>$lastOpening) && ($lastMultiCommentEndBrace>$lastMultiComment)) { |
|
| 9777 | 9777 | return $this->fail("missing closing `}` or `*/`", $lastOpening); |
| 9778 | - } else { |
|
| 9778 | + }else { |
|
| 9779 | 9779 | return $this->fail("missing closing `}`", $lastOpening); |
| 9780 | 9780 | } |
| 9781 | - } else if ( $parenLevel !== 0 ){ |
|
| 9781 | + }else if ($parenLevel!==0) { |
|
| 9782 | 9782 | return $this->fail("missing closing `)`", $lastParen); |
| 9783 | 9783 | } |
| 9784 | 9784 | |
@@ -9789,16 +9789,16 @@ discard block |
||
| 9789 | 9789 | //$this->emitChunk(true); |
| 9790 | 9790 | } |
| 9791 | 9791 | |
| 9792 | - public function CharCode($pos){ |
|
| 9792 | + public function CharCode($pos) { |
|
| 9793 | 9793 | return ord($this->input[$pos]); |
| 9794 | 9794 | } |
| 9795 | 9795 | |
| 9796 | 9796 | |
| 9797 | - public function fail( $msg, $index = null ){ |
|
| 9797 | + public function fail($msg, $index = null) { |
|
| 9798 | 9798 | |
| 9799 | - if( !$index ){ |
|
| 9799 | + if (!$index) { |
|
| 9800 | 9800 | $this->index = $this->parserCurrentIndex; |
| 9801 | - }else{ |
|
| 9801 | + }else { |
|
| 9802 | 9802 | $this->index = $index; |
| 9803 | 9803 | } |
| 9804 | 9804 | $this->message = 'ParseError: '.$msg; |
@@ -9825,7 +9825,7 @@ discard block |
||
| 9825 | 9825 | * @package Less |
| 9826 | 9826 | * @subpackage exception |
| 9827 | 9827 | */ |
| 9828 | -class Less_Exception_Compiler extends Less_Exception_Parser{ |
|
| 9828 | +class Less_Exception_Compiler extends Less_Exception_Parser { |
|
| 9829 | 9829 | |
| 9830 | 9830 | } |
| 9831 | 9831 | |
@@ -9871,7 +9871,7 @@ discard block |
||
| 9871 | 9871 | * @param array $contentsMap Array of filename to contents map |
| 9872 | 9872 | * @param Less_SourceMap_Generator $generator |
| 9873 | 9873 | */ |
| 9874 | - public function __construct(array $contentsMap, $generator){ |
|
| 9874 | + public function __construct(array $contentsMap, $generator) { |
|
| 9875 | 9875 | $this->contentsMap = $contentsMap; |
| 9876 | 9876 | $this->generator = $generator; |
| 9877 | 9877 | } |
@@ -9885,10 +9885,10 @@ discard block |
||
| 9885 | 9885 | * @param integer $index |
| 9886 | 9886 | * @param mixed $mapLines |
| 9887 | 9887 | */ |
| 9888 | - public function add($chunk, $fileInfo = null, $index = 0, $mapLines = null){ |
|
| 9888 | + public function add($chunk, $fileInfo = null, $index = 0, $mapLines = null) { |
|
| 9889 | 9889 | |
| 9890 | 9890 | //ignore adding empty strings |
| 9891 | - if( $chunk === '' ){ |
|
| 9891 | + if ($chunk==='') { |
|
| 9892 | 9892 | return; |
| 9893 | 9893 | } |
| 9894 | 9894 | |
@@ -9897,15 +9897,15 @@ discard block |
||
| 9897 | 9897 | $sourceColumns = ' '; |
| 9898 | 9898 | |
| 9899 | 9899 | |
| 9900 | - if( $fileInfo ){ |
|
| 9900 | + if ($fileInfo) { |
|
| 9901 | 9901 | |
| 9902 | 9902 | $url = $fileInfo['currentUri']; |
| 9903 | 9903 | |
| 9904 | - if( isset($this->contentsMap[$url]) ){ |
|
| 9904 | + if (isset($this->contentsMap[$url])) { |
|
| 9905 | 9905 | $inputSource = substr($this->contentsMap[$url], 0, $index); |
| 9906 | 9906 | $sourceLines = explode("\n", $inputSource); |
| 9907 | 9907 | $sourceColumns = end($sourceLines); |
| 9908 | - }else{ |
|
| 9908 | + }else { |
|
| 9909 | 9909 | throw new Exception('Filename '.$url.' not in contentsMap'); |
| 9910 | 9910 | } |
| 9911 | 9911 | |
@@ -9914,33 +9914,33 @@ discard block |
||
| 9914 | 9914 | $lines = explode("\n", $chunk); |
| 9915 | 9915 | $columns = end($lines); |
| 9916 | 9916 | |
| 9917 | - if($fileInfo){ |
|
| 9917 | + if ($fileInfo) { |
|
| 9918 | 9918 | |
| 9919 | - if(!$mapLines){ |
|
| 9919 | + if (!$mapLines) { |
|
| 9920 | 9920 | $this->generator->addMapping( |
| 9921 | - $this->lineNumber + 1, // generated_line |
|
| 9922 | - $this->column, // generated_column |
|
| 9923 | - count($sourceLines), // original_line |
|
| 9924 | - strlen($sourceColumns), // original_column |
|
| 9921 | + $this->lineNumber+1, // generated_line |
|
| 9922 | + $this->column, // generated_column |
|
| 9923 | + count($sourceLines), // original_line |
|
| 9924 | + strlen($sourceColumns), // original_column |
|
| 9925 | 9925 | $fileInfo |
| 9926 | 9926 | ); |
| 9927 | - }else{ |
|
| 9928 | - for($i = 0, $count = count($lines); $i < $count; $i++){ |
|
| 9927 | + }else { |
|
| 9928 | + for ($i = 0, $count = count($lines); $i<$count; $i++) { |
|
| 9929 | 9929 | $this->generator->addMapping( |
| 9930 | - $this->lineNumber + $i + 1, // generated_line |
|
| 9931 | - $i === 0 ? $this->column : 0, // generated_column |
|
| 9932 | - count($sourceLines) + $i, // original_line |
|
| 9933 | - $i === 0 ? strlen($sourceColumns) : 0, // original_column |
|
| 9930 | + $this->lineNumber+$i+1, // generated_line |
|
| 9931 | + $i===0 ? $this->column : 0, // generated_column |
|
| 9932 | + count($sourceLines)+$i, // original_line |
|
| 9933 | + $i===0 ? strlen($sourceColumns) : 0, // original_column |
|
| 9934 | 9934 | $fileInfo |
| 9935 | 9935 | ); |
| 9936 | 9936 | } |
| 9937 | 9937 | } |
| 9938 | 9938 | } |
| 9939 | 9939 | |
| 9940 | - if(count($lines) === 1){ |
|
| 9940 | + if (count($lines)===1) { |
|
| 9941 | 9941 | $this->column += strlen($columns); |
| 9942 | - }else{ |
|
| 9943 | - $this->lineNumber += count($lines) - 1; |
|
| 9942 | + }else { |
|
| 9943 | + $this->lineNumber += count($lines)-1; |
|
| 9944 | 9944 | $this->column = strlen($columns); |
| 9945 | 9945 | } |
| 9946 | 9946 | |
@@ -9986,14 +9986,14 @@ discard block |
||
| 9986 | 9986 | */ |
| 9987 | 9987 | private $charToIntMap = array( |
| 9988 | 9988 | 'A' => 0, 'B' => 1, 'C' => 2, 'D' => 3, 'E' => 4, 'F' => 5, 'G' => 6, |
| 9989 | - 'H' => 7,'I' => 8, 'J' => 9, 'K' => 10, 'L' => 11, 'M' => 12, 'N' => 13, |
|
| 9989 | + 'H' => 7, 'I' => 8, 'J' => 9, 'K' => 10, 'L' => 11, 'M' => 12, 'N' => 13, |
|
| 9990 | 9990 | 'O' => 14, 'P' => 15, 'Q' => 16, 'R' => 17, 'S' => 18, 'T' => 19, 'U' => 20, |
| 9991 | 9991 | 'V' => 21, 'W' => 22, 'X' => 23, 'Y' => 24, 'Z' => 25, 'a' => 26, 'b' => 27, |
| 9992 | 9992 | 'c' => 28, 'd' => 29, 'e' => 30, 'f' => 31, 'g' => 32, 'h' => 33, 'i' => 34, |
| 9993 | 9993 | 'j' => 35, 'k' => 36, 'l' => 37, 'm' => 38, 'n' => 39, 'o' => 40, 'p' => 41, |
| 9994 | 9994 | 'q' => 42, 'r' => 43, 's' => 44, 't' => 45, 'u' => 46, 'v' => 47, 'w' => 48, |
| 9995 | 9995 | 'x' => 49, 'y' => 50, 'z' => 51, 0 => 52, 1 => 53, 2 => 54, 3 => 55, 4 => 56, |
| 9996 | - 5 => 57, 6 => 58, 7 => 59, 8 => 60, 9 => 61, '+' => 62, '/' => 63, |
|
| 9996 | + 5 => 57, 6 => 58, 7 => 59, 8 => 60, 9 => 61, '+' => 62, '/' => 63, |
|
| 9997 | 9997 | ); |
| 9998 | 9998 | |
| 9999 | 9999 | /** |
@@ -10017,7 +10017,7 @@ discard block |
||
| 10017 | 10017 | /** |
| 10018 | 10018 | * Constructor |
| 10019 | 10019 | */ |
| 10020 | - public function __construct(){ |
|
| 10020 | + public function __construct() { |
|
| 10021 | 10021 | // I leave it here for future reference |
| 10022 | 10022 | // foreach(str_split('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/') as $i => $char) |
| 10023 | 10023 | // { |
@@ -10035,8 +10035,8 @@ discard block |
||
| 10035 | 10035 | * even on a 64 bit machine. |
| 10036 | 10036 | * @param string $aValue |
| 10037 | 10037 | */ |
| 10038 | - public function toVLQSigned($aValue){ |
|
| 10039 | - return 0xffffffff & ($aValue < 0 ? ((-$aValue) << 1) + 1 : ($aValue << 1) + 0); |
|
| 10038 | + public function toVLQSigned($aValue) { |
|
| 10039 | + return 0xffffffff&($aValue<0 ? ((-$aValue) << 1)+1 : ($aValue << 1)+0); |
|
| 10040 | 10040 | } |
| 10041 | 10041 | |
| 10042 | 10042 | /** |
@@ -10050,8 +10050,8 @@ discard block |
||
| 10050 | 10050 | * even on a 64 bit machine. |
| 10051 | 10051 | * @param integer $aValue |
| 10052 | 10052 | */ |
| 10053 | - public function fromVLQSigned($aValue){ |
|
| 10054 | - return $aValue & 1 ? $this->zeroFill(~$aValue + 2, 1) | (-1 - 0x7fffffff) : $this->zeroFill($aValue, 1); |
|
| 10053 | + public function fromVLQSigned($aValue) { |
|
| 10054 | + return $aValue&1 ? $this->zeroFill(~$aValue+2, 1)|(-1-0x7fffffff) : $this->zeroFill($aValue, 1); |
|
| 10055 | 10055 | } |
| 10056 | 10056 | |
| 10057 | 10057 | /** |
@@ -10060,18 +10060,18 @@ discard block |
||
| 10060 | 10060 | * @param string $aValue The value to encode |
| 10061 | 10061 | * @return string The encoded value |
| 10062 | 10062 | */ |
| 10063 | - public function encode($aValue){ |
|
| 10063 | + public function encode($aValue) { |
|
| 10064 | 10064 | $encoded = ''; |
| 10065 | 10065 | $vlq = $this->toVLQSigned($aValue); |
| 10066 | 10066 | do |
| 10067 | 10067 | { |
| 10068 | - $digit = $vlq & $this->mask; |
|
| 10068 | + $digit = $vlq&$this->mask; |
|
| 10069 | 10069 | $vlq = $this->zeroFill($vlq, $this->shift); |
| 10070 | - if($vlq > 0){ |
|
| 10070 | + if ($vlq>0) { |
|
| 10071 | 10071 | $digit |= $this->continuationBit; |
| 10072 | 10072 | } |
| 10073 | 10073 | $encoded .= $this->base64Encode($digit); |
| 10074 | - } while($vlq > 0); |
|
| 10074 | + } while ($vlq>0); |
|
| 10075 | 10075 | |
| 10076 | 10076 | return $encoded; |
| 10077 | 10077 | } |
@@ -10082,15 +10082,15 @@ discard block |
||
| 10082 | 10082 | * @param string $encoded The encoded value to decode |
| 10083 | 10083 | * @return integer The decoded value |
| 10084 | 10084 | */ |
| 10085 | - public function decode($encoded){ |
|
| 10085 | + public function decode($encoded) { |
|
| 10086 | 10086 | $vlq = 0; |
| 10087 | 10087 | $i = 0; |
| 10088 | 10088 | do |
| 10089 | 10089 | { |
| 10090 | 10090 | $digit = $this->base64Decode($encoded[$i]); |
| 10091 | - $vlq |= ($digit & $this->mask) << ($i * $this->shift); |
|
| 10091 | + $vlq |= ($digit&$this->mask) << ($i * $this->shift); |
|
| 10092 | 10092 | $i++; |
| 10093 | - } while($digit & $this->continuationBit); |
|
| 10093 | + } while ($digit&$this->continuationBit); |
|
| 10094 | 10094 | |
| 10095 | 10095 | return $this->fromVLQSigned($vlq); |
| 10096 | 10096 | } |
@@ -10102,8 +10102,8 @@ discard block |
||
| 10102 | 10102 | * @param integer $b number of bits to shift |
| 10103 | 10103 | * @return integer |
| 10104 | 10104 | */ |
| 10105 | - public function zeroFill($a, $b){ |
|
| 10106 | - return ($a >= 0) ? ($a >> $b) : ($a >> $b) & (PHP_INT_MAX >> ($b - 1)); |
|
| 10105 | + public function zeroFill($a, $b) { |
|
| 10106 | + return ($a>=0) ? ($a >> $b) : ($a >> $b)&(PHP_INT_MAX >> ($b-1)); |
|
| 10107 | 10107 | } |
| 10108 | 10108 | |
| 10109 | 10109 | /** |
@@ -10113,8 +10113,8 @@ discard block |
||
| 10113 | 10113 | * @return string |
| 10114 | 10114 | * @throws Exception If the number is invalid |
| 10115 | 10115 | */ |
| 10116 | - public function base64Encode($number){ |
|
| 10117 | - if($number < 0 || $number > 63){ |
|
| 10116 | + public function base64Encode($number) { |
|
| 10117 | + if ($number<0 || $number>63) { |
|
| 10118 | 10118 | throw new Exception(sprintf('Invalid number "%s" given. Must be between 0 and 63.', $number)); |
| 10119 | 10119 | } |
| 10120 | 10120 | return $this->intToCharMap[$number]; |
@@ -10127,8 +10127,8 @@ discard block |
||
| 10127 | 10127 | * @return number |
| 10128 | 10128 | * @throws Exception If the number is invalid |
| 10129 | 10129 | */ |
| 10130 | - public function base64Decode($char){ |
|
| 10131 | - if(!array_key_exists($char, $this->charToIntMap)){ |
|
| 10130 | + public function base64Decode($char) { |
|
| 10131 | + if (!array_key_exists($char, $this->charToIntMap)) { |
|
| 10132 | 10132 | throw new Exception(sprintf('Invalid base 64 digit "%s" given.', $char)); |
| 10133 | 10133 | } |
| 10134 | 10134 | return $this->charToIntMap[$char]; |
@@ -10222,7 +10222,7 @@ discard block |
||
| 10222 | 10222 | * @param Less_Tree_Ruleset $root The root node |
| 10223 | 10223 | * @param array $options Array of options |
| 10224 | 10224 | */ |
| 10225 | - public function __construct(Less_Tree_Ruleset $root, $contentsMap, $options = array()){ |
|
| 10225 | + public function __construct(Less_Tree_Ruleset $root, $contentsMap, $options = array()) { |
|
| 10226 | 10226 | $this->root = $root; |
| 10227 | 10227 | $this->contentsMap = $contentsMap; |
| 10228 | 10228 | $this->encoder = new Less_SourceMap_Base64VLQ(); |
@@ -10238,34 +10238,34 @@ discard block |
||
| 10238 | 10238 | * |
| 10239 | 10239 | * @return string |
| 10240 | 10240 | */ |
| 10241 | - public function generateCSS(){ |
|
| 10241 | + public function generateCSS() { |
|
| 10242 | 10242 | $output = new Less_Output_Mapped($this->contentsMap, $this); |
| 10243 | 10243 | |
| 10244 | 10244 | // catch the output |
| 10245 | 10245 | $this->root->genCSS($output); |
| 10246 | 10246 | |
| 10247 | 10247 | |
| 10248 | - $sourceMapUrl = $this->getOption('sourceMapURL'); |
|
| 10249 | - $sourceMapFilename = $this->getOption('sourceMapFilename'); |
|
| 10248 | + $sourceMapUrl = $this->getOption('sourceMapURL'); |
|
| 10249 | + $sourceMapFilename = $this->getOption('sourceMapFilename'); |
|
| 10250 | 10250 | $sourceMapContent = $this->generateJson(); |
| 10251 | 10251 | $sourceMapWriteTo = $this->getOption('sourceMapWriteTo'); |
| 10252 | 10252 | |
| 10253 | - if( !$sourceMapUrl && $sourceMapFilename ){ |
|
| 10253 | + if (!$sourceMapUrl && $sourceMapFilename) { |
|
| 10254 | 10254 | $sourceMapUrl = $this->normalizeFilename($sourceMapFilename); |
| 10255 | 10255 | } |
| 10256 | 10256 | |
| 10257 | 10257 | // write map to a file |
| 10258 | - if( $sourceMapWriteTo ){ |
|
| 10258 | + if ($sourceMapWriteTo) { |
|
| 10259 | 10259 | $this->saveMap($sourceMapWriteTo, $sourceMapContent); |
| 10260 | 10260 | } |
| 10261 | 10261 | |
| 10262 | 10262 | // inline the map |
| 10263 | - if( !$sourceMapUrl ){ |
|
| 10263 | + if (!$sourceMapUrl) { |
|
| 10264 | 10264 | $sourceMapUrl = sprintf('data:application/json,%s', Less_Functions::encodeURIComponent($sourceMapContent)); |
| 10265 | 10265 | } |
| 10266 | 10266 | |
| 10267 | - if( $sourceMapUrl ){ |
|
| 10268 | - $output->add( sprintf('/*# sourceMappingURL=%s */', $sourceMapUrl) ); |
|
| 10267 | + if ($sourceMapUrl) { |
|
| 10268 | + $output->add(sprintf('/*# sourceMappingURL=%s */', $sourceMapUrl)); |
|
| 10269 | 10269 | } |
| 10270 | 10270 | |
| 10271 | 10271 | return $output->toString(); |
@@ -10278,15 +10278,15 @@ discard block |
||
| 10278 | 10278 | * @param string $content The content to write |
| 10279 | 10279 | * @throws Exception If the file could not be saved |
| 10280 | 10280 | */ |
| 10281 | - protected function saveMap($file, $content){ |
|
| 10281 | + protected function saveMap($file, $content) { |
|
| 10282 | 10282 | $dir = dirname($file); |
| 10283 | 10283 | // directory does not exist |
| 10284 | - if( !is_dir($dir) ){ |
|
| 10284 | + if (!is_dir($dir)) { |
|
| 10285 | 10285 | // FIXME: create the dir automatically? |
| 10286 | 10286 | throw new Exception(sprintf('The directory "%s" does not exist. Cannot save the source map.', $dir)); |
| 10287 | 10287 | } |
| 10288 | 10288 | // FIXME: proper saving, with dir write check! |
| 10289 | - if(file_put_contents($file, $content) === false){ |
|
| 10289 | + if (file_put_contents($file, $content)===false) { |
|
| 10290 | 10290 | throw new Exception(sprintf('Cannot save the source map to "%s"', $file)); |
| 10291 | 10291 | } |
| 10292 | 10292 | return true; |
@@ -10298,7 +10298,7 @@ discard block |
||
| 10298 | 10298 | * @param string $filename |
| 10299 | 10299 | * @return string |
| 10300 | 10300 | */ |
| 10301 | - protected function normalizeFilename($filename){ |
|
| 10301 | + protected function normalizeFilename($filename) { |
|
| 10302 | 10302 | |
| 10303 | 10303 | $filename = $this->fixWindowsPath($filename); |
| 10304 | 10304 | |
@@ -10306,16 +10306,16 @@ discard block |
||
| 10306 | 10306 | $basePath = $this->getOption('sourceMapBasepath'); |
| 10307 | 10307 | |
| 10308 | 10308 | // "Trim" the 'sourceMapBasepath' from the output filename. |
| 10309 | - if (strpos($filename, $basePath) === 0) { |
|
| 10309 | + if (strpos($filename, $basePath)===0) { |
|
| 10310 | 10310 | $filename = substr($filename, strlen($basePath)); |
| 10311 | 10311 | } |
| 10312 | 10312 | |
| 10313 | 10313 | // Remove extra leading path separators. |
| 10314 | - if(strpos($filename, '\\') === 0 || strpos($filename, '/') === 0){ |
|
| 10314 | + if (strpos($filename, '\\')===0 || strpos($filename, '/')===0) { |
|
| 10315 | 10315 | $filename = substr($filename, 1); |
| 10316 | 10316 | } |
| 10317 | 10317 | |
| 10318 | - return $rootpath . $filename; |
|
| 10318 | + return $rootpath.$filename; |
|
| 10319 | 10319 | } |
| 10320 | 10320 | |
| 10321 | 10321 | /** |
@@ -10327,7 +10327,7 @@ discard block |
||
| 10327 | 10327 | * @param integer $originalColumn The column number in original file |
| 10328 | 10328 | * @param string $sourceFile The original source file |
| 10329 | 10329 | */ |
| 10330 | - public function addMapping($generatedLine, $generatedColumn, $originalLine, $originalColumn, $fileInfo ){ |
|
| 10330 | + public function addMapping($generatedLine, $generatedColumn, $originalLine, $originalColumn, $fileInfo) { |
|
| 10331 | 10331 | |
| 10332 | 10332 | $this->mappings[] = array( |
| 10333 | 10333 | 'generated_line' => $generatedLine, |
@@ -10347,7 +10347,7 @@ discard block |
||
| 10347 | 10347 | * @return string |
| 10348 | 10348 | * @see https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit# |
| 10349 | 10349 | */ |
| 10350 | - protected function generateJson(){ |
|
| 10350 | + protected function generateJson() { |
|
| 10351 | 10351 | |
| 10352 | 10352 | $sourceMap = array(); |
| 10353 | 10353 | $mappings = $this->generateMappings(); |
@@ -10358,21 +10358,21 @@ discard block |
||
| 10358 | 10358 | |
| 10359 | 10359 | // An optional name of the generated code that this source map is associated with. |
| 10360 | 10360 | $file = $this->getOption('sourceMapFilename'); |
| 10361 | - if( $file ){ |
|
| 10361 | + if ($file) { |
|
| 10362 | 10362 | $sourceMap['file'] = $file; |
| 10363 | 10363 | } |
| 10364 | 10364 | |
| 10365 | 10365 | |
| 10366 | 10366 | // 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. |
| 10367 | 10367 | $root = $this->getOption('sourceRoot'); |
| 10368 | - if( $root ){ |
|
| 10368 | + if ($root) { |
|
| 10369 | 10369 | $sourceMap['sourceRoot'] = $root; |
| 10370 | 10370 | } |
| 10371 | 10371 | |
| 10372 | 10372 | |
| 10373 | 10373 | // A list of original sources used by the 'mappings' entry. |
| 10374 | 10374 | $sourceMap['sources'] = array(); |
| 10375 | - foreach($this->sources as $source_uri => $source_filename){ |
|
| 10375 | + foreach ($this->sources as $source_uri => $source_filename) { |
|
| 10376 | 10376 | $sourceMap['sources'][] = $this->normalizeFilename($source_filename); |
| 10377 | 10377 | } |
| 10378 | 10378 | |
@@ -10383,7 +10383,7 @@ discard block |
||
| 10383 | 10383 | // A string with the encoded mapping data. |
| 10384 | 10384 | $sourceMap['mappings'] = $mappings; |
| 10385 | 10385 | |
| 10386 | - if( $this->getOption('outputSourceFiles') ){ |
|
| 10386 | + if ($this->getOption('outputSourceFiles')) { |
|
| 10387 | 10387 | // An optional list of source content, useful when the 'source' can't be hosted. |
| 10388 | 10388 | // The contents are listed in the same order as the sources above. |
| 10389 | 10389 | // 'null' may be used if some original sources should be retrieved by name. |
@@ -10391,7 +10391,7 @@ discard block |
||
| 10391 | 10391 | } |
| 10392 | 10392 | |
| 10393 | 10393 | // less.js compat fixes |
| 10394 | - if( count($sourceMap['sources']) && empty($sourceMap['sourceRoot']) ){ |
|
| 10394 | + if (count($sourceMap['sources']) && empty($sourceMap['sourceRoot'])) { |
|
| 10395 | 10395 | unset($sourceMap['sourceRoot']); |
| 10396 | 10396 | } |
| 10397 | 10397 | |
@@ -10403,12 +10403,12 @@ discard block |
||
| 10403 | 10403 | * |
| 10404 | 10404 | * @return array|null |
| 10405 | 10405 | */ |
| 10406 | - protected function getSourcesContent(){ |
|
| 10407 | - if(empty($this->sources)){ |
|
| 10406 | + protected function getSourcesContent() { |
|
| 10407 | + if (empty($this->sources)) { |
|
| 10408 | 10408 | return; |
| 10409 | 10409 | } |
| 10410 | 10410 | $content = array(); |
| 10411 | - foreach($this->sources as $sourceFile){ |
|
| 10411 | + foreach ($this->sources as $sourceFile) { |
|
| 10412 | 10412 | $content[] = file_get_contents($sourceFile); |
| 10413 | 10413 | } |
| 10414 | 10414 | return $content; |
@@ -10419,9 +10419,9 @@ discard block |
||
| 10419 | 10419 | * |
| 10420 | 10420 | * @return string |
| 10421 | 10421 | */ |
| 10422 | - public function generateMappings(){ |
|
| 10422 | + public function generateMappings() { |
|
| 10423 | 10423 | |
| 10424 | - if( !count($this->mappings) ){ |
|
| 10424 | + if (!count($this->mappings)) { |
|
| 10425 | 10425 | return ''; |
| 10426 | 10426 | } |
| 10427 | 10427 | |
@@ -10430,37 +10430,37 @@ discard block |
||
| 10430 | 10430 | |
| 10431 | 10431 | // group mappings by generated line number. |
| 10432 | 10432 | $groupedMap = $groupedMapEncoded = array(); |
| 10433 | - foreach($this->mappings as $m){ |
|
| 10433 | + foreach ($this->mappings as $m) { |
|
| 10434 | 10434 | $groupedMap[$m['generated_line']][] = $m; |
| 10435 | 10435 | } |
| 10436 | 10436 | ksort($groupedMap); |
| 10437 | 10437 | |
| 10438 | 10438 | $lastGeneratedLine = $lastOriginalIndex = $lastOriginalLine = $lastOriginalColumn = 0; |
| 10439 | 10439 | |
| 10440 | - foreach($groupedMap as $lineNumber => $line_map){ |
|
| 10441 | - while(++$lastGeneratedLine < $lineNumber){ |
|
| 10440 | + foreach ($groupedMap as $lineNumber => $line_map) { |
|
| 10441 | + while (++$lastGeneratedLine<$lineNumber) { |
|
| 10442 | 10442 | $groupedMapEncoded[] = ';'; |
| 10443 | 10443 | } |
| 10444 | 10444 | |
| 10445 | 10445 | $lineMapEncoded = array(); |
| 10446 | 10446 | $lastGeneratedColumn = 0; |
| 10447 | 10447 | |
| 10448 | - foreach($line_map as $m){ |
|
| 10449 | - $mapEncoded = $this->encoder->encode($m['generated_column'] - $lastGeneratedColumn); |
|
| 10448 | + foreach ($line_map as $m) { |
|
| 10449 | + $mapEncoded = $this->encoder->encode($m['generated_column']-$lastGeneratedColumn); |
|
| 10450 | 10450 | $lastGeneratedColumn = $m['generated_column']; |
| 10451 | 10451 | |
| 10452 | 10452 | // find the index |
| 10453 | - if( $m['source_file'] ){ |
|
| 10453 | + if ($m['source_file']) { |
|
| 10454 | 10454 | $index = $this->findFileIndex($m['source_file']); |
| 10455 | - if( $index !== false ){ |
|
| 10456 | - $mapEncoded .= $this->encoder->encode($index - $lastOriginalIndex); |
|
| 10455 | + if ($index!==false) { |
|
| 10456 | + $mapEncoded .= $this->encoder->encode($index-$lastOriginalIndex); |
|
| 10457 | 10457 | $lastOriginalIndex = $index; |
| 10458 | 10458 | |
| 10459 | 10459 | // lines are stored 0-based in SourceMap spec version 3 |
| 10460 | - $mapEncoded .= $this->encoder->encode($m['original_line'] - 1 - $lastOriginalLine); |
|
| 10461 | - $lastOriginalLine = $m['original_line'] - 1; |
|
| 10460 | + $mapEncoded .= $this->encoder->encode($m['original_line']-1-$lastOriginalLine); |
|
| 10461 | + $lastOriginalLine = $m['original_line']-1; |
|
| 10462 | 10462 | |
| 10463 | - $mapEncoded .= $this->encoder->encode($m['original_column'] - $lastOriginalColumn); |
|
| 10463 | + $mapEncoded .= $this->encoder->encode($m['original_column']-$lastOriginalColumn); |
|
| 10464 | 10464 | $lastOriginalColumn = $m['original_column']; |
| 10465 | 10465 | } |
| 10466 | 10466 | } |
@@ -10468,7 +10468,7 @@ discard block |
||
| 10468 | 10468 | $lineMapEncoded[] = $mapEncoded; |
| 10469 | 10469 | } |
| 10470 | 10470 | |
| 10471 | - $groupedMapEncoded[] = implode(',', $lineMapEncoded) . ';'; |
|
| 10471 | + $groupedMapEncoded[] = implode(',', $lineMapEncoded).';'; |
|
| 10472 | 10472 | } |
| 10473 | 10473 | |
| 10474 | 10474 | return rtrim(implode($groupedMapEncoded), ';'); |
@@ -10480,7 +10480,7 @@ discard block |
||
| 10480 | 10480 | * @param string $filename |
| 10481 | 10481 | * @return integer|false |
| 10482 | 10482 | */ |
| 10483 | - protected function findFileIndex($filename){ |
|
| 10483 | + protected function findFileIndex($filename) { |
|
| 10484 | 10484 | return $this->source_keys[$filename]; |
| 10485 | 10485 | } |
| 10486 | 10486 | |
@@ -10489,11 +10489,11 @@ discard block |
||
| 10489 | 10489 | * @param string $path |
| 10490 | 10490 | * @return string |
| 10491 | 10491 | */ |
| 10492 | - public function fixWindowsPath($path, $addEndSlash = false){ |
|
| 10492 | + public function fixWindowsPath($path, $addEndSlash = false) { |
|
| 10493 | 10493 | $slash = ($addEndSlash) ? '/' : ''; |
| 10494 | - if( !empty($path) ){ |
|
| 10494 | + if (!empty($path)) { |
|
| 10495 | 10495 | $path = str_replace('\\', '/', $path); |
| 10496 | - $path = rtrim($path,'/') . $slash; |
|
| 10496 | + $path = rtrim($path, '/').$slash; |
|
| 10497 | 10497 | } |
| 10498 | 10498 | |
| 10499 | 10499 | return $path; |
@@ -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 | |
@@ -195,7 +196,7 @@ discard block |
||
| 195 | 196 | // will also save file |
| 196 | 197 | // FIXME: should happen somewhere else? |
| 197 | 198 | $css = $generator->generateCSS(); |
| 198 | - }else{ |
|
| 199 | + } else{ |
|
| 199 | 200 | $css = $evaldRoot->toCSS(); |
| 200 | 201 | } |
| 201 | 202 | |
@@ -257,7 +258,7 @@ discard block |
||
| 257 | 258 | |
| 258 | 259 | if( property_exists($plugin,'isPreVisitor') && $plugin->isPreVisitor ){ |
| 259 | 260 | array_unshift( $visitors, $plugin); |
| 260 | - }else{ |
|
| 261 | + } else{ |
|
| 261 | 262 | $visitors[] = $plugin; |
| 262 | 263 | } |
| 263 | 264 | } |
@@ -283,7 +284,7 @@ discard block |
||
| 283 | 284 | if( !$file_uri ){ |
| 284 | 285 | $uri_root = ''; |
| 285 | 286 | $filename = 'anonymous-file-'.Less_Parser::$next_id++.'.less'; |
| 286 | - }else{ |
|
| 287 | + } else{ |
|
| 287 | 288 | $file_uri = self::WinPath($file_uri); |
| 288 | 289 | $filename = $file_uri; |
| 289 | 290 | $uri_root = dirname($file_uri); |
@@ -342,7 +343,7 @@ discard block |
||
| 342 | 343 | if( $returnRoot ){ |
| 343 | 344 | $rules = $this->GetRules( $filename ); |
| 344 | 345 | $return = new Less_Tree_Ruleset(array(), $rules ); |
| 345 | - }else{ |
|
| 346 | + } else{ |
|
| 346 | 347 | $this->_parse( $filename ); |
| 347 | 348 | $return = $this; |
| 348 | 349 | } |
@@ -389,7 +390,7 @@ discard block |
||
| 389 | 390 | $currentFileInfo['entryUri'] = $this->env->currentFileInfo['entryUri']; |
| 390 | 391 | $currentFileInfo['rootpath'] = $this->env->currentFileInfo['rootpath']; |
| 391 | 392 | |
| 392 | - }else{ |
|
| 393 | + } else{ |
|
| 393 | 394 | $currentFileInfo['entryPath'] = $dirname; |
| 394 | 395 | $currentFileInfo['entryUri'] = $uri_root; |
| 395 | 396 | $currentFileInfo['rootpath'] = $dirname; |
@@ -422,13 +423,13 @@ discard block |
||
| 422 | 423 | } |
| 423 | 424 | throw new Less_Exception_Parser('Less.php cache directory couldn\'t be created: '.$dir); |
| 424 | 425 | |
| 425 | - }elseif( !is_dir($dir) ){ |
|
| 426 | + } elseif( !is_dir($dir) ){ |
|
| 426 | 427 | throw new Less_Exception_Parser('Less.php cache directory doesn\'t exist: '.$dir); |
| 427 | 428 | |
| 428 | - }elseif( !is_writable($dir) ){ |
|
| 429 | + } elseif( !is_writable($dir) ){ |
|
| 429 | 430 | throw new Less_Exception_Parser('Less.php cache directory isn\'t writable: '.$dir); |
| 430 | 431 | |
| 431 | - }else{ |
|
| 432 | + } else{ |
|
| 432 | 433 | $dir = self::WinPath($dir); |
| 433 | 434 | Less_Cache::$cache_dir = rtrim($dir,'/').'/'; |
| 434 | 435 | return true; |
@@ -505,7 +506,7 @@ discard block |
||
| 505 | 506 | } |
| 506 | 507 | } |
| 507 | 508 | |
| 508 | - }elseif( file_exists($cache_file) ){ |
|
| 509 | + } elseif( file_exists($cache_file) ){ |
|
| 509 | 510 | switch(Less_Parser::$options['cache_method']){ |
| 510 | 511 | |
| 511 | 512 | // Using serialize |
@@ -548,7 +549,7 @@ discard block |
||
| 548 | 549 | ); |
| 549 | 550 | } |
| 550 | 551 | |
| 551 | - }else{ |
|
| 552 | + } else{ |
|
| 552 | 553 | //msg('write cache file'); |
| 553 | 554 | switch(Less_Parser::$options['cache_method']){ |
| 554 | 555 | case 'serialize': |
@@ -683,10 +684,10 @@ discard block |
||
| 683 | 684 | return count($match) === 1 ? $match[0] : $match; |
| 684 | 685 | } |
| 685 | 686 | |
| 686 | - }elseif( $char === '#' ){ |
|
| 687 | + } elseif( $char === '#' ){ |
|
| 687 | 688 | $match = $this->MatchChar($tok[1]); |
| 688 | 689 | |
| 689 | - }else{ |
|
| 690 | + } else{ |
|
| 690 | 691 | // Non-terminal, match using a function call |
| 691 | 692 | $match = $this->$tok(); |
| 692 | 693 | |
@@ -791,7 +792,7 @@ discard block |
||
| 791 | 792 | $result = $this->MatchChar($tok); |
| 792 | 793 | if( !$result ){ |
| 793 | 794 | $this->Error( $msg ? "Expected '" . $tok . "' got '" . $this->input[$this->pos] . "'" : $msg ); |
| 794 | - }else{ |
|
| 795 | + } else{ |
|
| 795 | 796 | return $result; |
| 796 | 797 | } |
| 797 | 798 | } |
@@ -861,7 +862,7 @@ discard block |
||
| 861 | 862 | |
| 862 | 863 | if( $node ){ |
| 863 | 864 | $root[] = $node; |
| 864 | - }elseif( !$this->MatchReg('/\\G[\s\n;]+/') ){ |
|
| 865 | + } elseif( !$this->MatchReg('/\\G[\s\n;]+/') ){ |
|
| 865 | 866 | break; |
| 866 | 867 | } |
| 867 | 868 | |
@@ -1300,7 +1301,7 @@ discard block |
||
| 1300 | 1301 | $returned = $this->parseMixinArgs(true); |
| 1301 | 1302 | $args = $returned['args']; |
| 1302 | 1303 | $this->expectChar(')'); |
| 1303 | - }else{ |
|
| 1304 | + } else{ |
|
| 1304 | 1305 | $args = array(); |
| 1305 | 1306 | } |
| 1306 | 1307 | |
@@ -1362,7 +1363,7 @@ discard block |
||
| 1362 | 1363 | |
| 1363 | 1364 | if( $isSemiColonSeperated ){ |
| 1364 | 1365 | $argsSemiColon[] = array('variadic'=>true); |
| 1365 | - }else{ |
|
| 1366 | + } else{ |
|
| 1366 | 1367 | $argsComma[] = array('variadic'=>true); |
| 1367 | 1368 | } |
| 1368 | 1369 | break; |
@@ -1424,18 +1425,18 @@ discard block |
||
| 1424 | 1425 | } |
| 1425 | 1426 | |
| 1426 | 1427 | $nameLoop = ($name = $val->name); |
| 1427 | - }elseif( !$isCall && $this->MatchReg('/\\G\.{3}/') ){ |
|
| 1428 | + } elseif( !$isCall && $this->MatchReg('/\\G\.{3}/') ){ |
|
| 1428 | 1429 | $returner['variadic'] = true; |
| 1429 | 1430 | if( $this->MatchChar(";") && !$isSemiColonSeperated ){ |
| 1430 | 1431 | $isSemiColonSeperated = true; |
| 1431 | 1432 | } |
| 1432 | 1433 | if( $isSemiColonSeperated ){ |
| 1433 | 1434 | $argsSemiColon[] = array('name'=> $arg->name, 'variadic' => true); |
| 1434 | - }else{ |
|
| 1435 | + } else{ |
|
| 1435 | 1436 | $argsComma[] = array('name'=> $arg->name, 'variadic' => true); |
| 1436 | 1437 | } |
| 1437 | 1438 | break; |
| 1438 | - }elseif( !$isCall ){ |
|
| 1439 | + } elseif( !$isCall ){ |
|
| 1439 | 1440 | $name = $nameLoop = $val->name; |
| 1440 | 1441 | $value = null; |
| 1441 | 1442 | } |
@@ -1541,7 +1542,7 @@ discard block |
||
| 1541 | 1542 | } |
| 1542 | 1543 | |
| 1543 | 1544 | $this->restore(); |
| 1544 | - }else{ |
|
| 1545 | + } else{ |
|
| 1545 | 1546 | $this->forget(); |
| 1546 | 1547 | } |
| 1547 | 1548 | } |
@@ -1578,7 +1579,7 @@ discard block |
||
| 1578 | 1579 | $value = $this->MatchReg('/\\G[0-9]+/'); |
| 1579 | 1580 | if( $value ){ |
| 1580 | 1581 | $value = $value[0]; |
| 1581 | - }else{ |
|
| 1582 | + } else{ |
|
| 1582 | 1583 | $value = $this->parseEntitiesVariable(); |
| 1583 | 1584 | if( !$value ){ |
| 1584 | 1585 | return; |
@@ -1615,10 +1616,10 @@ discard block |
||
| 1615 | 1616 | if( ($v = $this->parseSelector()) && $this->MatchChar(')') ){ |
| 1616 | 1617 | $e = $this->NewObj1('Less_Tree_Paren',$v); |
| 1617 | 1618 | $this->forget(); |
| 1618 | - }else{ |
|
| 1619 | + } else{ |
|
| 1619 | 1620 | $this->restore(); |
| 1620 | 1621 | } |
| 1621 | - }else{ |
|
| 1622 | + } else{ |
|
| 1622 | 1623 | $this->forget(); |
| 1623 | 1624 | } |
| 1624 | 1625 | } |
@@ -1687,11 +1688,11 @@ discard block |
||
| 1687 | 1688 | while( ($isLess && ($extend = $this->parseExtend())) || ($isLess && ($when = $this->MatchReg('/\\Gwhen/') )) || ($e = $this->parseElement()) ){ |
| 1688 | 1689 | if( $when ){ |
| 1689 | 1690 | $condition = $this->expect('parseConditions', 'expected condition'); |
| 1690 | - }elseif( $condition ){ |
|
| 1691 | + } elseif( $condition ){ |
|
| 1691 | 1692 | //error("CSS guard can only be used at the end of selector"); |
| 1692 | - }elseif( $extend ){ |
|
| 1693 | + } elseif( $extend ){ |
|
| 1693 | 1694 | $extendList = array_merge($extendList,$extend); |
| 1694 | - }else{ |
|
| 1695 | + } else{ |
|
| 1695 | 1696 | //if( count($extendList) ){ |
| 1696 | 1697 | //error("Extend can only be used at the end of selector"); |
| 1697 | 1698 | //} |
@@ -1873,7 +1874,7 @@ discard block |
||
| 1873 | 1874 | //if( !$tryAnonymous && is_string($name) && $name[0] === '@' ){ |
| 1874 | 1875 | if( !$tryAnonymous && (Less_Parser::$options['compress'] || $isVariable) ){ |
| 1875 | 1876 | $value = $this->MatchFuncs( array('parseValue','parseAnonymousValue')); |
| 1876 | - }else{ |
|
| 1877 | + } else{ |
|
| 1877 | 1878 | $value = $this->MatchFuncs( array('parseAnonymousValue','parseValue')); |
| 1878 | 1879 | } |
| 1879 | 1880 | |
@@ -1894,14 +1895,14 @@ discard block |
||
| 1894 | 1895 | if( $value && $this->parseEnd() ){ |
| 1895 | 1896 | $this->forget(); |
| 1896 | 1897 | return $this->NewObj6('Less_Tree_Rule',array( $name, $value, $important, $merge, $startOfRule, $this->env->currentFileInfo)); |
| 1897 | - }else{ |
|
| 1898 | + } else{ |
|
| 1898 | 1899 | $this->furthest = $this->pos; |
| 1899 | 1900 | $this->restore(); |
| 1900 | 1901 | if( $value && !$tryAnonymous ){ |
| 1901 | 1902 | return $this->parseRule(true); |
| 1902 | 1903 | } |
| 1903 | 1904 | } |
| 1904 | - }else{ |
|
| 1905 | + } else{ |
|
| 1905 | 1906 | $this->forget(); |
| 1906 | 1907 | } |
| 1907 | 1908 | } |
@@ -2006,8 +2007,9 @@ discard block |
||
| 2006 | 2007 | } else { |
| 2007 | 2008 | return null; |
| 2008 | 2009 | } |
| 2009 | - } else |
|
| 2010 | - return null; |
|
| 2010 | + } else { |
|
| 2011 | + return null; |
|
| 2012 | + } |
|
| 2011 | 2013 | } |
| 2012 | 2014 | } while ($e); |
| 2013 | 2015 | |
@@ -2023,12 +2025,16 @@ discard block |
||
| 2023 | 2025 | $e = $this->parseMediaFeature(); |
| 2024 | 2026 | if( $e ){ |
| 2025 | 2027 | $features[] = $e; |
| 2026 | - if (!$this->MatchChar(',')) break; |
|
| 2027 | - }else{ |
|
| 2028 | + if (!$this->MatchChar(',')) { |
|
| 2029 | + break; |
|
| 2030 | + } |
|
| 2031 | + } else{ |
|
| 2028 | 2032 | $e = $this->parseEntitiesVariable(); |
| 2029 | 2033 | if( $e ){ |
| 2030 | 2034 | $features[] = $e; |
| 2031 | - if (!$this->MatchChar(',')) break; |
|
| 2035 | + if (!$this->MatchChar(',')) { |
|
| 2036 | + break; |
|
| 2037 | + } |
|
| 2032 | 2038 | } |
| 2033 | 2039 | } |
| 2034 | 2040 | } while ($e); |
@@ -2076,7 +2082,9 @@ discard block |
||
| 2076 | 2082 | |
| 2077 | 2083 | $name = $this->MatchReg('/\\G@[a-z-]+/'); |
| 2078 | 2084 | |
| 2079 | - if( !$name ) return; |
|
| 2085 | + if( !$name ) { |
|
| 2086 | + return; |
|
| 2087 | + } |
|
| 2080 | 2088 | $name = $name[0]; |
| 2081 | 2089 | |
| 2082 | 2090 | |
@@ -2259,7 +2267,7 @@ discard block |
||
| 2259 | 2267 | $op = $this->MatchReg('/\\G[-+]\s+/'); |
| 2260 | 2268 | if( $op ){ |
| 2261 | 2269 | $op = $op[0]; |
| 2262 | - }else{ |
|
| 2270 | + } else{ |
|
| 2263 | 2271 | if( !$isSpaced ){ |
| 2264 | 2272 | $op = $this->match(array('#+','#-')); |
| 2265 | 2273 | } |
@@ -2312,7 +2320,9 @@ discard block |
||
| 2312 | 2320 | $negate = false; |
| 2313 | 2321 | $c = null; |
| 2314 | 2322 | |
| 2315 | - if ($this->MatchReg('/\\Gnot/')) $negate = true; |
|
| 2323 | + if ($this->MatchReg('/\\Gnot/')) { |
|
| 2324 | + $negate = true; |
|
| 2325 | + } |
|
| 2316 | 2326 | $this->expectChar('('); |
| 2317 | 2327 | $a = $this->MatchFuncs(array('parseAddition','parseEntitiesKeyword','parseEntitiesQuoted')); |
| 2318 | 2328 | |
@@ -2436,7 +2446,7 @@ discard block |
||
| 2436 | 2446 | foreach($name as $k => $s ){ |
| 2437 | 2447 | if( !$s || $s[0] !== '@' ){ |
| 2438 | 2448 | $name[$k] = $this->NewObj1('Less_Tree_Keyword',$s); |
| 2439 | - }else{ |
|
| 2449 | + } else{ |
|
| 2440 | 2450 | $name[$k] = $this->NewObj3('Less_Tree_Variable',array('@' . substr($s,2,-1), $index[$k], $this->env->currentFileInfo)); |
| 2441 | 2451 | } |
| 2442 | 2452 | } |
@@ -2492,7 +2502,7 @@ discard block |
||
| 2492 | 2502 | $floor = floor($i); |
| 2493 | 2503 | if( ($ceil - $i) <= ($i - $floor) ){ |
| 2494 | 2504 | return $ceil/$precision; |
| 2495 | - }else{ |
|
| 2505 | + } else{ |
|
| 2496 | 2506 | return $floor/$precision; |
| 2497 | 2507 | } |
| 2498 | 2508 | } |
@@ -2591,7 +2601,7 @@ discard block |
||
| 2591 | 2601 | unset($arg->cache_string); |
| 2592 | 2602 | return $string; |
| 2593 | 2603 | |
| 2594 | - }elseif( $type === 'array' ){ |
|
| 2604 | + } elseif( $type === 'array' ){ |
|
| 2595 | 2605 | $string = ' Array('; |
| 2596 | 2606 | foreach($arg as $k => $a){ |
| 2597 | 2607 | $string .= var_export($k,true).' => '.self::ArgString($a).','; |
@@ -2865,7 +2875,7 @@ discard block |
||
| 2865 | 2875 | '^^' => '^^' |
| 2866 | 2876 | ); |
| 2867 | 2877 | |
| 2868 | - }else{ |
|
| 2878 | + } else{ |
|
| 2869 | 2879 | |
| 2870 | 2880 | Less_Environment::$_outputMap = array( |
| 2871 | 2881 | ',' => ', ', |
@@ -2927,7 +2937,7 @@ discard block |
||
| 2927 | 2937 | if( !$path_len || ( $path[$path_len-1] === '..') ){ |
| 2928 | 2938 | $path[] = $segment; |
| 2929 | 2939 | $path_len++; |
| 2930 | - }else{ |
|
| 2940 | + } else{ |
|
| 2931 | 2941 | array_pop($path); |
| 2932 | 2942 | $path_len--; |
| 2933 | 2943 | } |
@@ -3061,10 +3071,15 @@ discard block |
||
| 3061 | 3071 | */ |
| 3062 | 3072 | public function hsla_hue($h, $m1, $m2){ |
| 3063 | 3073 | $h = $h < 0 ? $h + 1 : ($h > 1 ? $h - 1 : $h); |
| 3064 | - if ($h * 6 < 1) return $m1 + ($m2 - $m1) * $h * 6; |
|
| 3065 | - else if ($h * 2 < 1) return $m2; |
|
| 3066 | - else if ($h * 3 < 2) return $m1 + ($m2 - $m1) * (2/3 - $h) * 6; |
|
| 3067 | - else return $m1; |
|
| 3074 | + if ($h * 6 < 1) { |
|
| 3075 | + return $m1 + ($m2 - $m1) * $h * 6; |
|
| 3076 | + } else if ($h * 2 < 1) { |
|
| 3077 | + return $m2; |
|
| 3078 | + } else if ($h * 3 < 2) { |
|
| 3079 | + return $m1 + ($m2 - $m1) * (2/3 - $h) * 6; |
|
| 3080 | + } else { |
|
| 3081 | + return $m1; |
|
| 3082 | + } |
|
| 3068 | 3083 | } |
| 3069 | 3084 | |
| 3070 | 3085 | public function hsv($h, $s, $v) { |
@@ -3549,7 +3564,7 @@ discard block |
||
| 3549 | 3564 | if( is_numeric($x) && is_numeric($y) ){ |
| 3550 | 3565 | $x = new Less_Tree_Dimension($x); |
| 3551 | 3566 | $y = new Less_Tree_Dimension($y); |
| 3552 | - }elseif( !($x instanceof Less_Tree_Dimension) || !($y instanceof Less_Tree_Dimension) ){ |
|
| 3567 | + } elseif( !($x instanceof Less_Tree_Dimension) || !($y instanceof Less_Tree_Dimension) ){ |
|
| 3553 | 3568 | throw new Less_Exception_Compiler('Arguments must be numbers'); |
| 3554 | 3569 | } |
| 3555 | 3570 | |
@@ -3579,7 +3594,7 @@ discard block |
||
| 3579 | 3594 | |
| 3580 | 3595 | if( $unit === null ){ |
| 3581 | 3596 | $unit = $args[0]->unit; |
| 3582 | - }else{ |
|
| 3597 | + } else{ |
|
| 3583 | 3598 | $args[0] = $args[0]->unify(); |
| 3584 | 3599 | } |
| 3585 | 3600 | $args[0] = (float)$args[0]->value; |
@@ -3624,13 +3639,13 @@ discard block |
||
| 3624 | 3639 | if( $current->unit->toString() === '' && !$unitClone ){ |
| 3625 | 3640 | $temp = new Less_Tree_Dimension($current->value, $unitClone); |
| 3626 | 3641 | $currentUnified = $temp->unify(); |
| 3627 | - }else{ |
|
| 3642 | + } else{ |
|
| 3628 | 3643 | $currentUnified = $current->unify(); |
| 3629 | 3644 | } |
| 3630 | 3645 | |
| 3631 | 3646 | if( $currentUnified->unit->toString() === "" && !$unitStatic ){ |
| 3632 | 3647 | $unit = $unitStatic; |
| 3633 | - }else{ |
|
| 3648 | + } else{ |
|
| 3634 | 3649 | $unit = $currentUnified->unit->toString(); |
| 3635 | 3650 | } |
| 3636 | 3651 | |
@@ -3644,9 +3659,9 @@ discard block |
||
| 3644 | 3659 | |
| 3645 | 3660 | if( isset($values['']) && $unit !== '' && $unit === $unitStatic ){ |
| 3646 | 3661 | $j = $values['']; |
| 3647 | - }elseif( isset($values[$unit]) ){ |
|
| 3662 | + } elseif( isset($values[$unit]) ){ |
|
| 3648 | 3663 | $j = $values[$unit]; |
| 3649 | - }else{ |
|
| 3664 | + } else{ |
|
| 3650 | 3665 | |
| 3651 | 3666 | if( $unitStatic && $unit !== $unitStatic ){ |
| 3652 | 3667 | throw new Less_Exception_Compiler( 'incompatible types'); |
@@ -3660,7 +3675,7 @@ discard block |
||
| 3660 | 3675 | if( $order[$j]->unit->toString() === "" && $unitClone ){ |
| 3661 | 3676 | $temp = new Less_Tree_Dimension( $order[$j]->value, $unitClone); |
| 3662 | 3677 | $referenceUnified = $temp->unify(); |
| 3663 | - }else{ |
|
| 3678 | + } else{ |
|
| 3664 | 3679 | $referenceUnified = $order[$j]->unify(); |
| 3665 | 3680 | } |
| 3666 | 3681 | if( ($isMin && $currentUnified->value < $referenceUnified->value) || (!$isMin && $currentUnified->value > $referenceUnified->value) ){ |
@@ -3786,7 +3801,7 @@ discard block |
||
| 3786 | 3801 | } |
| 3787 | 3802 | return null; |
| 3788 | 3803 | |
| 3789 | - }elseif( (int)$index === 0 ){ |
|
| 3804 | + } elseif( (int)$index === 0 ){ |
|
| 3790 | 3805 | return $values; |
| 3791 | 3806 | } |
| 3792 | 3807 | |
@@ -3844,14 +3859,14 @@ discard block |
||
| 3844 | 3859 | $useBase64 = !in_array($charset,array('US-ASCII', 'UTF-8')); |
| 3845 | 3860 | if( $useBase64 ){ $mimetype .= ';base64'; } |
| 3846 | 3861 | |
| 3847 | - }else{ |
|
| 3862 | + } else{ |
|
| 3848 | 3863 | $useBase64 = preg_match('/;base64$/',$mimetype); |
| 3849 | 3864 | } |
| 3850 | 3865 | |
| 3851 | 3866 | |
| 3852 | 3867 | if( file_exists($filePath) ){ |
| 3853 | 3868 | $buf = @file_get_contents($filePath); |
| 3854 | - }else{ |
|
| 3869 | + } else{ |
|
| 3855 | 3870 | $buf = false; |
| 3856 | 3871 | } |
| 3857 | 3872 | |
@@ -3921,7 +3936,7 @@ discard block |
||
| 3921 | 3936 | if( is_object($stops[$i]) && property_exists($stops[$i],'value') ){ |
| 3922 | 3937 | $color = $stops[$i]->value[0]; |
| 3923 | 3938 | $position = $stops[$i]->value[1]; |
| 3924 | - }else{ |
|
| 3939 | + } else{ |
|
| 3925 | 3940 | $color = $stops[$i]; |
| 3926 | 3941 | $position = null; |
| 3927 | 3942 | } |
@@ -3931,9 +3946,9 @@ discard block |
||
| 3931 | 3946 | } |
| 3932 | 3947 | if( $position ){ |
| 3933 | 3948 | $positionValue = $position->toCSS(); |
| 3934 | - }elseif( $i === 0 ){ |
|
| 3949 | + } elseif( $i === 0 ){ |
|
| 3935 | 3950 | $positionValue = '0%'; |
| 3936 | - }else{ |
|
| 3951 | + } else{ |
|
| 3937 | 3952 | $positionValue = '100%'; |
| 3938 | 3953 | } |
| 3939 | 3954 | $alpha = $color->alpha; |
@@ -3945,7 +3960,7 @@ discard block |
||
| 3945 | 3960 | |
| 3946 | 3961 | if( $useBase64 ){ |
| 3947 | 3962 | $returner = "'data:image/svg+xml;base64,".base64_encode($returner)."'"; |
| 3948 | - }else{ |
|
| 3963 | + } else{ |
|
| 3949 | 3964 | $returner = "'data:image/svg+xml,".$returner."'"; |
| 3950 | 3965 | } |
| 3951 | 3966 | |
@@ -4349,7 +4364,7 @@ discard block |
||
| 4349 | 4364 | $this->$funcName( $node ); |
| 4350 | 4365 | } |
| 4351 | 4366 | |
| 4352 | - }else{ |
|
| 4367 | + } else{ |
|
| 4353 | 4368 | $node->accept($this); |
| 4354 | 4369 | } |
| 4355 | 4370 | |
@@ -4392,7 +4407,7 @@ discard block |
||
| 4392 | 4407 | } |
| 4393 | 4408 | } |
| 4394 | 4409 | |
| 4395 | - }else{ |
|
| 4410 | + } else{ |
|
| 4396 | 4411 | $node->accept($this); |
| 4397 | 4412 | } |
| 4398 | 4413 | |
@@ -4407,7 +4422,7 @@ discard block |
||
| 4407 | 4422 | if( $evald ){ |
| 4408 | 4423 | if( is_array($evald) ){ |
| 4409 | 4424 | self::flatten($evald,$newNodes); |
| 4410 | - }else{ |
|
| 4425 | + } else{ |
|
| 4411 | 4426 | $newNodes[] = $evald; |
| 4412 | 4427 | } |
| 4413 | 4428 | } |
@@ -4426,7 +4441,7 @@ discard block |
||
| 4426 | 4441 | foreach($item as $nestedItem){ |
| 4427 | 4442 | if( is_array($nestedItem) ){ |
| 4428 | 4443 | self::flatten( $nestedItem, $out); |
| 4429 | - }else{ |
|
| 4444 | + } else{ |
|
| 4430 | 4445 | $out[] = $nestedItem; |
| 4431 | 4446 | } |
| 4432 | 4447 | } |
@@ -4544,7 +4559,7 @@ discard block |
||
| 4544 | 4559 | |
| 4545 | 4560 | if( is_string($this->value) ){ |
| 4546 | 4561 | $output->add( $this->value ); |
| 4547 | - }else{ |
|
| 4562 | + } else{ |
|
| 4548 | 4563 | $this->value->genCSS( $output); |
| 4549 | 4564 | } |
| 4550 | 4565 | |
@@ -4776,7 +4791,7 @@ discard block |
||
| 4776 | 4791 | if( $nameLC === 'default' ){ |
| 4777 | 4792 | $result = Less_Tree_DefaultFunc::compile(); |
| 4778 | 4793 | |
| 4779 | - }else{ |
|
| 4794 | + } else{ |
|
| 4780 | 4795 | |
| 4781 | 4796 | if( method_exists('Less_Functions',$nameLC) ){ // 1. |
| 4782 | 4797 | try { |
@@ -4853,11 +4868,11 @@ discard block |
||
| 4853 | 4868 | $this->rgb = array(); |
| 4854 | 4869 | if( is_array($rgb) ){ |
| 4855 | 4870 | $this->rgb = $rgb; |
| 4856 | - }else if( strlen($rgb) == 6 ){ |
|
| 4871 | + } else if( strlen($rgb) == 6 ){ |
|
| 4857 | 4872 | foreach(str_split($rgb, 2) as $c){ |
| 4858 | 4873 | $this->rgb[] = hexdec($c); |
| 4859 | 4874 | } |
| 4860 | - }else{ |
|
| 4875 | + } else{ |
|
| 4861 | 4876 | foreach(str_split($rgb, 1) as $c){ |
| 4862 | 4877 | $this->rgb[] = hexdec($c.$c); |
| 4863 | 4878 | } |
@@ -4912,7 +4927,7 @@ discard block |
||
| 4912 | 4927 | |
| 4913 | 4928 | $glue = ($compress ? ',' : ', '); |
| 4914 | 4929 | return "rgba(" . implode($glue, $values) . ")"; |
| 4915 | - }else{ |
|
| 4930 | + } else{ |
|
| 4916 | 4931 | |
| 4917 | 4932 | $color = $this->toRGB(); |
| 4918 | 4933 | |
@@ -5154,9 +5169,9 @@ discard block |
||
| 5154 | 5169 | default: |
| 5155 | 5170 | if( Less_Parser::is_method($a, 'compare') ){ |
| 5156 | 5171 | $result = $a->compare($b); |
| 5157 | - }elseif( Less_Parser::is_method($b, 'compare') ){ |
|
| 5172 | + } elseif( Less_Parser::is_method($b, 'compare') ){ |
|
| 5158 | 5173 | $result = $b->compare($a); |
| 5159 | - }else{ |
|
| 5174 | + } else{ |
|
| 5160 | 5175 | throw new Less_Exception_Compiler('Unable to perform comparison', null, $this->index); |
| 5161 | 5176 | } |
| 5162 | 5177 | |
@@ -5239,7 +5254,7 @@ discard block |
||
| 5239 | 5254 | public function compile($env){ |
| 5240 | 5255 | if( $this->frames ){ |
| 5241 | 5256 | $frames = $this->frames; |
| 5242 | - }else{ |
|
| 5257 | + } else{ |
|
| 5243 | 5258 | $frames = $env->frames; |
| 5244 | 5259 | } |
| 5245 | 5260 | return new Less_Tree_DetachedRuleset($this->ruleset, $frames); |
@@ -5272,9 +5287,9 @@ discard block |
||
| 5272 | 5287 | |
| 5273 | 5288 | if( $unit && ($unit instanceof Less_Tree_Unit) ){ |
| 5274 | 5289 | $this->unit = $unit; |
| 5275 | - }elseif( $unit ){ |
|
| 5290 | + } elseif( $unit ){ |
|
| 5276 | 5291 | $this->unit = new Less_Tree_Unit( array($unit) ); |
| 5277 | - }else{ |
|
| 5292 | + } else{ |
|
| 5278 | 5293 | $this->unit = new Less_Tree_Unit( ); |
| 5279 | 5294 | } |
| 5280 | 5295 | } |
@@ -5347,9 +5362,9 @@ discard block |
||
| 5347 | 5362 | if( !$unit->numerator && !$unit->denominator ){ |
| 5348 | 5363 | $unit->numerator = $other->unit->numerator; |
| 5349 | 5364 | $unit->denominator = $other->unit->denominator; |
| 5350 | - }elseif( !$other->unit->numerator && !$other->unit->denominator ){ |
|
| 5365 | + } elseif( !$other->unit->numerator && !$other->unit->denominator ){ |
|
| 5351 | 5366 | // do nothing |
| 5352 | - }else{ |
|
| 5367 | + } else{ |
|
| 5353 | 5368 | $other = $other->convertTo( $this->unit->usedUnits()); |
| 5354 | 5369 | |
| 5355 | 5370 | if( Less_Parser::$options['strictUnits'] && $other->unit->toString() !== $unit->toCSS() ){ |
@@ -5358,13 +5373,13 @@ discard block |
||
| 5358 | 5373 | |
| 5359 | 5374 | $value = Less_Functions::operate( $op, $this->value, $other->value); |
| 5360 | 5375 | } |
| 5361 | - }elseif( $op === '*' ){ |
|
| 5376 | + } elseif( $op === '*' ){ |
|
| 5362 | 5377 | $unit->numerator = array_merge($unit->numerator, $other->unit->numerator); |
| 5363 | 5378 | $unit->denominator = array_merge($unit->denominator, $other->unit->denominator); |
| 5364 | 5379 | sort($unit->numerator); |
| 5365 | 5380 | sort($unit->denominator); |
| 5366 | 5381 | $unit->cancel(); |
| 5367 | - }elseif( $op === '/' ){ |
|
| 5382 | + } elseif( $op === '/' ){ |
|
| 5368 | 5383 | $unit->numerator = array_merge($unit->numerator, $other->unit->denominator); |
| 5369 | 5384 | $unit->denominator = array_merge($unit->denominator, $other->unit->numerator); |
| 5370 | 5385 | sort($unit->numerator); |
@@ -5615,7 +5630,7 @@ discard block |
||
| 5615 | 5630 | |
| 5616 | 5631 | if( $this->value_is_object ){ |
| 5617 | 5632 | $value = $this->value->toCSS(); |
| 5618 | - }else{ |
|
| 5633 | + } else{ |
|
| 5619 | 5634 | $value = $this->value; |
| 5620 | 5635 | } |
| 5621 | 5636 | |
@@ -5674,7 +5689,7 @@ discard block |
||
| 5674 | 5689 | } |
| 5675 | 5690 | $returnValue = new Less_Tree_Expression($ret); |
| 5676 | 5691 | |
| 5677 | - }else{ |
|
| 5692 | + } else{ |
|
| 5678 | 5693 | |
| 5679 | 5694 | if( ($this->value[0] instanceof Less_Tree_Expression) && $this->value[0]->parens && !$this->value[0]->parensInOp ){ |
| 5680 | 5695 | $doubleParen = true; |
@@ -5691,7 +5706,7 @@ discard block |
||
| 5691 | 5706 | if( !$this->parensInOp ){ |
| 5692 | 5707 | Less_Environment::$parensStack--; |
| 5693 | 5708 | |
| 5694 | - }elseif( !Less_Environment::isMathOn() && !$doubleParen ){ |
|
| 5709 | + } elseif( !Less_Environment::isMathOn() && !$doubleParen ){ |
|
| 5695 | 5710 | $returnValue = new Less_Tree_Paren($returnValue); |
| 5696 | 5711 | |
| 5697 | 5712 | } |
@@ -5910,7 +5925,7 @@ discard block |
||
| 5910 | 5925 | $path = ( isset($this->css) || preg_match('/(\.[a-z]*$)|([\?;].*)$/',$path)) ? $path : $path . '.less'; |
| 5911 | 5926 | } else if ($this->path instanceof Less_Tree_URL) { |
| 5912 | 5927 | $path = $this->path->value->value; |
| 5913 | - }else{ |
|
| 5928 | + } else{ |
|
| 5914 | 5929 | return null; |
| 5915 | 5930 | } |
| 5916 | 5931 | |
@@ -5962,7 +5977,7 @@ discard block |
||
| 5962 | 5977 | |
| 5963 | 5978 | if( $path_and_uri ){ |
| 5964 | 5979 | list($full_path, $uri) = $path_and_uri; |
| 5965 | - }else{ |
|
| 5980 | + } else{ |
|
| 5966 | 5981 | $full_path = $uri = $evald->getPath(); |
| 5967 | 5982 | } |
| 5968 | 5983 | |
@@ -6015,7 +6030,7 @@ discard block |
||
| 6015 | 6030 | //if the path is relative, the file should be in the current directory |
| 6016 | 6031 | $import_dirs[ $this->currentFileInfo['currentDirectory'] ] = $this->currentFileInfo['uri_root']; |
| 6017 | 6032 | |
| 6018 | - }else{ |
|
| 6033 | + } else{ |
|
| 6019 | 6034 | //otherwise, the file should be relative to the server root |
| 6020 | 6035 | $import_dirs[ $this->currentFileInfo['entryPath'] ] = $this->currentFileInfo['entryUri']; |
| 6021 | 6036 | |
@@ -6035,7 +6050,7 @@ discard block |
||
| 6035 | 6050 | $full_path = $path; |
| 6036 | 6051 | return array( $full_path, $uri ); |
| 6037 | 6052 | } |
| 6038 | - }elseif( !empty($rootpath) ){ |
|
| 6053 | + } elseif( !empty($rootpath) ){ |
|
| 6039 | 6054 | |
| 6040 | 6055 | |
| 6041 | 6056 | if( $rooturi ){ |
@@ -6334,11 +6349,13 @@ discard block |
||
| 6334 | 6349 | } |
| 6335 | 6350 | |
| 6336 | 6351 | public function permute($arr) { |
| 6337 | - if (!$arr) |
|
| 6338 | - return array(); |
|
| 6352 | + if (!$arr) { |
|
| 6353 | + return array(); |
|
| 6354 | + } |
|
| 6339 | 6355 | |
| 6340 | - if (count($arr) == 1) |
|
| 6341 | - return $arr[0]; |
|
| 6356 | + if (count($arr) == 1) { |
|
| 6357 | + return $arr[0]; |
|
| 6358 | + } |
|
| 6342 | 6359 | |
| 6343 | 6360 | $result = array(); |
| 6344 | 6361 | $rest = $this->permute(array_slice($arr, 1)); |
@@ -6356,7 +6373,9 @@ discard block |
||
| 6356 | 6373 | |
| 6357 | 6374 | public function bubbleSelectors($selectors) { |
| 6358 | 6375 | |
| 6359 | - if( !$selectors) return; |
|
| 6376 | + if( !$selectors) { |
|
| 6377 | + return; |
|
| 6378 | + } |
|
| 6360 | 6379 | |
| 6361 | 6380 | $this->rules = array(new Less_Tree_Ruleset( $selectors, array($this->rules[0]))); |
| 6362 | 6381 | } |
@@ -6477,7 +6496,7 @@ discard block |
||
| 6477 | 6496 | if( $a instanceof Less_Tree_Dimension && $b instanceof Less_Tree_Color ){ |
| 6478 | 6497 | $a = $a->toColor(); |
| 6479 | 6498 | |
| 6480 | - }elseif( $b instanceof Less_Tree_Dimension && $a instanceof Less_Tree_Color ){ |
|
| 6499 | + } elseif( $b instanceof Less_Tree_Dimension && $a instanceof Less_Tree_Color ){ |
|
| 6481 | 6500 | $b = $b->toColor(); |
| 6482 | 6501 | |
| 6483 | 6502 | } |
@@ -6672,7 +6691,7 @@ discard block |
||
| 6672 | 6691 | try{ |
| 6673 | 6692 | $this->value->genCSS( $output); |
| 6674 | 6693 | |
| 6675 | - }catch( Less_Exception_Parser $e ){ |
|
| 6694 | + } catch( Less_Exception_Parser $e ){ |
|
| 6676 | 6695 | $e->index = $this->index; |
| 6677 | 6696 | $e->currentFile = $this->currentFileInfo; |
| 6678 | 6697 | throw $e; |
@@ -6688,7 +6707,7 @@ discard block |
||
| 6688 | 6707 | // things faster (~10% for benchmark.less): |
| 6689 | 6708 | if( count($name) === 1 && $name[0] instanceof Less_Tree_Keyword ){ |
| 6690 | 6709 | $name = $name[0]->value; |
| 6691 | - }else{ |
|
| 6710 | + } else{ |
|
| 6692 | 6711 | $name = $this->CompileName($env,$name); |
| 6693 | 6712 | } |
| 6694 | 6713 | } |
@@ -6707,13 +6726,13 @@ discard block |
||
| 6707 | 6726 | |
| 6708 | 6727 | if( Less_Environment::$mixin_stack ){ |
| 6709 | 6728 | $return = new Less_Tree_Rule($name, $evaldValue, $this->important, $this->merge, $this->index, $this->currentFileInfo, $this->inline); |
| 6710 | - }else{ |
|
| 6729 | + } else{ |
|
| 6711 | 6730 | $this->name = $name; |
| 6712 | 6731 | $this->value = $evaldValue; |
| 6713 | 6732 | $return = $this; |
| 6714 | 6733 | } |
| 6715 | 6734 | |
| 6716 | - }catch( Less_Exception_Parser $e ){ |
|
| 6735 | + } catch( Less_Exception_Parser $e ){ |
|
| 6717 | 6736 | if( !is_numeric($e->index) ){ |
| 6718 | 6737 | $e->index = $this->index; |
| 6719 | 6738 | $e->currentFile = $this->currentFileInfo; |
@@ -6798,7 +6817,7 @@ discard block |
||
| 6798 | 6817 | for($i = 0,$paths_len; $i < $paths_len; $i++ ){ |
| 6799 | 6818 | $this->paths[$i] = $visitor->visitArray($this->paths[$i]); |
| 6800 | 6819 | } |
| 6801 | - }elseif( $this->selectors ){ |
|
| 6820 | + } elseif( $this->selectors ){ |
|
| 6802 | 6821 | $this->selectors = $visitor->visitArray($this->selectors); |
| 6803 | 6822 | } |
| 6804 | 6823 | |
@@ -6897,7 +6916,7 @@ discard block |
||
| 6897 | 6916 | if( !$ruleset->variable($r->name) ){ |
| 6898 | 6917 | $temp[] = $r; |
| 6899 | 6918 | } |
| 6900 | - }else{ |
|
| 6919 | + } else{ |
|
| 6901 | 6920 | $temp[] = $r; |
| 6902 | 6921 | } |
| 6903 | 6922 | } |
@@ -6907,7 +6926,7 @@ discard block |
||
| 6907 | 6926 | $i += $temp_count; |
| 6908 | 6927 | $ruleset->resetCache(); |
| 6909 | 6928 | |
| 6910 | - }elseif( $rule instanceof Less_Tree_RulesetCall ){ |
|
| 6929 | + } elseif( $rule instanceof Less_Tree_RulesetCall ){ |
|
| 6911 | 6930 | |
| 6912 | 6931 | $rule = $rule->compile($env); |
| 6913 | 6932 | $rules = array(); |
@@ -6955,7 +6974,7 @@ discard block |
||
| 6955 | 6974 | |
| 6956 | 6975 | if( $this->rules && $hasOnePassingSelector ){ |
| 6957 | 6976 | $rules = $this->rules; |
| 6958 | - }else{ |
|
| 6977 | + } else{ |
|
| 6959 | 6978 | $rules = array(); |
| 6960 | 6979 | } |
| 6961 | 6980 | |
@@ -6993,7 +7012,7 @@ discard block |
||
| 6993 | 7012 | $temp_count = count($rules)-1; |
| 6994 | 7013 | $i += $temp_count; |
| 6995 | 7014 | $rules_len += $temp_count; |
| 6996 | - }else{ |
|
| 7015 | + } else{ |
|
| 6997 | 7016 | array_splice($this->rules, $i, 1, array($rules)); |
| 6998 | 7017 | } |
| 6999 | 7018 | |
@@ -7008,7 +7027,7 @@ discard block |
||
| 7008 | 7027 | foreach($this->rules as $rule){ |
| 7009 | 7028 | if( $rule instanceof Less_Tree_Rule || $rule instanceof Less_Tree_Ruleset ){ |
| 7010 | 7029 | $important_rules[] = $rule->makeImportant(); |
| 7011 | - }else{ |
|
| 7030 | + } else{ |
|
| 7012 | 7031 | $important_rules[] = $rule; |
| 7013 | 7032 | } |
| 7014 | 7033 | } |
@@ -7109,7 +7128,7 @@ discard block |
||
| 7109 | 7128 | if( Less_Environment::$tabLevel ){ |
| 7110 | 7129 | $tabRuleStr = "\n".str_repeat( ' ' , Less_Environment::$tabLevel ); |
| 7111 | 7130 | $tabSetStr = "\n".str_repeat( ' ' , Less_Environment::$tabLevel-1 ); |
| 7112 | - }else{ |
|
| 7131 | + } else{ |
|
| 7113 | 7132 | $tabSetStr = $tabRuleStr = "\n"; |
| 7114 | 7133 | } |
| 7115 | 7134 | } |
@@ -7122,7 +7141,7 @@ discard block |
||
| 7122 | 7141 | $class = get_class($rule); |
| 7123 | 7142 | if( ($class === 'Less_Tree_Media') || ($class === 'Less_Tree_Directive') || ($this->root && $class === 'Less_Tree_Comment') || ($class === 'Less_Tree_Ruleset' && $rule->rules) ){ |
| 7124 | 7143 | $rulesetNodes[] = $rule; |
| 7125 | - }else{ |
|
| 7144 | + } else{ |
|
| 7126 | 7145 | $ruleNodes[] = $rule; |
| 7127 | 7146 | } |
| 7128 | 7147 | } |
@@ -7174,7 +7193,7 @@ discard block |
||
| 7174 | 7193 | |
| 7175 | 7194 | if( !Less_Environment::$lastRule ){ |
| 7176 | 7195 | $output->add( $tabRuleStr ); |
| 7177 | - }else{ |
|
| 7196 | + } else{ |
|
| 7178 | 7197 | Less_Environment::$lastRule = false; |
| 7179 | 7198 | } |
| 7180 | 7199 | } |
@@ -7190,7 +7209,7 @@ discard block |
||
| 7190 | 7209 | |
| 7191 | 7210 | if( $ruleNodes_len && $firstRuleset ){ |
| 7192 | 7211 | $output->add( $space ); |
| 7193 | - }elseif( !$firstRuleset ){ |
|
| 7212 | + } elseif( !$firstRuleset ){ |
|
| 7194 | 7213 | $output->add( $space ); |
| 7195 | 7214 | } |
| 7196 | 7215 | $firstRuleset = false; |
@@ -7238,7 +7257,7 @@ discard block |
||
| 7238 | 7257 | foreach($context as $context_el){ |
| 7239 | 7258 | $paths[] = array_merge($context_el, array($selector) ); |
| 7240 | 7259 | } |
| 7241 | - }else { |
|
| 7260 | + } else { |
|
| 7242 | 7261 | $paths[] = array($selector); |
| 7243 | 7262 | } |
| 7244 | 7263 | return; |
@@ -7292,7 +7311,7 @@ discard block |
||
| 7292 | 7311 | $sel[0]->elements[] = new Less_Tree_Element($el->combinator, '', $el->index, $el->currentFileInfo ); |
| 7293 | 7312 | } |
| 7294 | 7313 | $selectorsMultiplied[] = $sel; |
| 7295 | - }else { |
|
| 7314 | + } else { |
|
| 7296 | 7315 | |
| 7297 | 7316 | // and the parent selectors |
| 7298 | 7317 | foreach($context as $parentSel){ |
@@ -7312,8 +7331,7 @@ discard block |
||
| 7312 | 7331 | $lastSelector = array_pop($newSelectorPath); |
| 7313 | 7332 | $newJoinedSelector = $selector->createDerived( array_slice($lastSelector->elements,0) ); |
| 7314 | 7333 | $newJoinedSelectorEmpty = false; |
| 7315 | - } |
|
| 7316 | - else { |
|
| 7334 | + } else { |
|
| 7317 | 7335 | $newJoinedSelector = $selector->createDerived(array()); |
| 7318 | 7336 | } |
| 7319 | 7337 | |
@@ -7377,7 +7395,7 @@ discard block |
||
| 7377 | 7395 | if( $sel ){ |
| 7378 | 7396 | $last = count($sel)-1; |
| 7379 | 7397 | $sel[$last] = $sel[$last]->createDerived( array_merge($sel[$last]->elements, $elements) ); |
| 7380 | - }else{ |
|
| 7398 | + } else{ |
|
| 7381 | 7399 | $sel[] = new Less_Tree_Selector( $elements ); |
| 7382 | 7400 | } |
| 7383 | 7401 | } |
@@ -7637,9 +7655,9 @@ discard block |
||
| 7637 | 7655 | |
| 7638 | 7656 | if( $this->numerator ){ |
| 7639 | 7657 | $output->add( $this->numerator[0] ); |
| 7640 | - }elseif( $this->denominator ){ |
|
| 7658 | + } elseif( $this->denominator ){ |
|
| 7641 | 7659 | $output->add( $this->denominator[0] ); |
| 7642 | - }elseif( !Less_Parser::$options['strictUnits'] && $this->backupUnit ){ |
|
| 7660 | + } elseif( !Less_Parser::$options['strictUnits'] && $this->backupUnit ){ |
|
| 7643 | 7661 | $output->add( $this->backupUnit ); |
| 7644 | 7662 | return ; |
| 7645 | 7663 | } |
@@ -7735,7 +7753,7 @@ discard block |
||
| 7735 | 7753 | for( $i = 0; $i < $count; $i++ ){ |
| 7736 | 7754 | $this->numerator[] = $atomicUnit; |
| 7737 | 7755 | } |
| 7738 | - }elseif( $count < 0 ){ |
|
| 7756 | + } elseif( $count < 0 ){ |
|
| 7739 | 7757 | for( $i = 0; $i < -$count; $i++ ){ |
| 7740 | 7758 | $this->denominator[] = $atomicUnit; |
| 7741 | 7759 | } |
@@ -7941,7 +7959,7 @@ discard block |
||
| 7941 | 7959 | if( $this->name[1] === '@' ){ |
| 7942 | 7960 | $v = new Less_Tree_Variable(substr($this->name, 1), $this->index + 1, $this->currentFileInfo); |
| 7943 | 7961 | $name = '@' . $v->compile($env)->value; |
| 7944 | - }else{ |
|
| 7962 | + } else{ |
|
| 7945 | 7963 | $name = $this->name; |
| 7946 | 7964 | } |
| 7947 | 7965 | |
@@ -8051,7 +8069,7 @@ discard block |
||
| 8051 | 8069 | |
| 8052 | 8070 | $candidates[] = $candidate; |
| 8053 | 8071 | } |
| 8054 | - }else{ |
|
| 8072 | + } else{ |
|
| 8055 | 8073 | $candidates[] = $candidate; |
| 8056 | 8074 | } |
| 8057 | 8075 | |
@@ -8109,7 +8127,7 @@ discard block |
||
| 8109 | 8127 | if( $isOneFound ){ |
| 8110 | 8128 | throw new Less_Exception_Compiler('No matching definition was found for `'.$this->Format( $args ).'`', null, $this->index, $this->currentFileInfo); |
| 8111 | 8129 | |
| 8112 | - }else{ |
|
| 8130 | + } else{ |
|
| 8113 | 8131 | throw new Less_Exception_Compiler(trim($this->selector->toCSS()) . " is undefined in ".$this->currentFileInfo['filename'], null, $this->index); |
| 8114 | 8132 | } |
| 8115 | 8133 | |
@@ -8129,7 +8147,7 @@ discard block |
||
| 8129 | 8147 | } |
| 8130 | 8148 | if( is_object($a['value']) ){ |
| 8131 | 8149 | $argValue += $a['value']->toCSS(); |
| 8132 | - }else{ |
|
| 8150 | + } else{ |
|
| 8133 | 8151 | $argValue += '???'; |
| 8134 | 8152 | } |
| 8135 | 8153 | $message[] = $argValue; |
@@ -8271,7 +8289,7 @@ discard block |
||
| 8271 | 8289 | } |
| 8272 | 8290 | $expression = new Less_Tree_Expression($varargs); |
| 8273 | 8291 | array_unshift($frame->rules, new Less_Tree_Rule($param['name'], $expression->compile($env))); |
| 8274 | - }else{ |
|
| 8292 | + } else{ |
|
| 8275 | 8293 | $val = ($arg && $arg['value']) ? $arg['value'] : false; |
| 8276 | 8294 | |
| 8277 | 8295 | if ($val) { |
@@ -8323,7 +8341,7 @@ discard block |
||
| 8323 | 8341 | |
| 8324 | 8342 | if( $this->frames ){ |
| 8325 | 8343 | $mixinFrames = array_merge($this->frames, $env->frames); |
| 8326 | - }else{ |
|
| 8344 | + } else{ |
|
| 8327 | 8345 | $mixinFrames = $env->frames; |
| 8328 | 8346 | } |
| 8329 | 8347 | |
@@ -8386,7 +8404,7 @@ discard block |
||
| 8386 | 8404 | if( $argsLength > count($this->params) ){ |
| 8387 | 8405 | return false; |
| 8388 | 8406 | } |
| 8389 | - }else{ |
|
| 8407 | + } else{ |
|
| 8390 | 8408 | if( $argsLength < ($this->required - 1)){ |
| 8391 | 8409 | return false; |
| 8392 | 8410 | } |
@@ -8704,7 +8722,7 @@ discard block |
||
| 8704 | 8722 | if( !$selectors ){ |
| 8705 | 8723 | $rulesetNode->selectors = null; |
| 8706 | 8724 | $rulesetNode->rules = null; |
| 8707 | - }else{ |
|
| 8725 | + } else{ |
|
| 8708 | 8726 | $context = end($this->contexts); //$context = $this->contexts[ count($this->contexts) - 1]; |
| 8709 | 8727 | $paths = $rulesetNode->joinSelectors( $context, $selectors); |
| 8710 | 8728 | } |
@@ -8838,7 +8856,7 @@ discard block |
||
| 8838 | 8856 | try{ |
| 8839 | 8857 | $selectorOne = $extendsToAdd[0]->selfSelectors[0]->toCSS(); |
| 8840 | 8858 | $selectorTwo = $extendsToAdd[0]->selector->toCSS(); |
| 8841 | - }catch(Exception $e){ |
|
| 8859 | + } catch(Exception $e){ |
|
| 8842 | 8860 | $selectorOne = "{unable to calculate}"; |
| 8843 | 8861 | $selectorTwo = "{unable to calculate}"; |
| 8844 | 8862 | } |
@@ -9153,7 +9171,7 @@ discard block |
||
| 9153 | 9171 | if( $currentSelectorPathIndex === $match['pathIndex'] && $matchIndex > 0 ){ |
| 9154 | 9172 | $last_key = count($path)-1; |
| 9155 | 9173 | $path[$last_key]->elements = array_merge($path[$last_key]->elements,$newElements); |
| 9156 | - }else{ |
|
| 9174 | + } else{ |
|
| 9157 | 9175 | $path = array_merge( $path, array_slice( $selectorPath, $currentSelectorPathIndex, $match['pathIndex'] )); |
| 9158 | 9176 | $path[] = new Less_Tree_Selector( $newElements ); |
| 9159 | 9177 | } |
@@ -9400,7 +9418,7 @@ discard block |
||
| 9400 | 9418 | |
| 9401 | 9419 | if( !isset($ruleCache[$rule->name]) ){ |
| 9402 | 9420 | $ruleCache[$rule->name] = $rule; |
| 9403 | - }else{ |
|
| 9421 | + } else{ |
|
| 9404 | 9422 | $ruleList =& $ruleCache[$rule->name]; |
| 9405 | 9423 | |
| 9406 | 9424 | if( $ruleList instanceof Less_Tree_Rule || $ruleList instanceof Less_Tree_NameValue ){ |
@@ -9410,7 +9428,7 @@ discard block |
||
| 9410 | 9428 | $ruleCSS = $rule->toCSS(); |
| 9411 | 9429 | if( array_search($ruleCSS,$ruleList) !== false ){ |
| 9412 | 9430 | array_splice($rules,$i,1); |
| 9413 | - }else{ |
|
| 9431 | + } else{ |
|
| 9414 | 9432 | $ruleList[] = $ruleCSS; |
| 9415 | 9433 | } |
| 9416 | 9434 | } |
@@ -9436,7 +9454,7 @@ discard block |
||
| 9436 | 9454 | |
| 9437 | 9455 | if( !isset($groups[$key]) ){ |
| 9438 | 9456 | $groups[$key] = array(); |
| 9439 | - }else{ |
|
| 9457 | + } else{ |
|
| 9440 | 9458 | array_splice($rules, $i--, 1); |
| 9441 | 9459 | $rules_len--; |
| 9442 | 9460 | } |
@@ -9798,7 +9816,7 @@ discard block |
||
| 9798 | 9816 | |
| 9799 | 9817 | if( !$index ){ |
| 9800 | 9818 | $this->index = $this->parserCurrentIndex; |
| 9801 | - }else{ |
|
| 9819 | + } else{ |
|
| 9802 | 9820 | $this->index = $index; |
| 9803 | 9821 | } |
| 9804 | 9822 | $this->message = 'ParseError: '.$msg; |
@@ -9905,7 +9923,7 @@ discard block |
||
| 9905 | 9923 | $inputSource = substr($this->contentsMap[$url], 0, $index); |
| 9906 | 9924 | $sourceLines = explode("\n", $inputSource); |
| 9907 | 9925 | $sourceColumns = end($sourceLines); |
| 9908 | - }else{ |
|
| 9926 | + } else{ |
|
| 9909 | 9927 | throw new Exception('Filename '.$url.' not in contentsMap'); |
| 9910 | 9928 | } |
| 9911 | 9929 | |
@@ -9924,7 +9942,7 @@ discard block |
||
| 9924 | 9942 | strlen($sourceColumns), // original_column |
| 9925 | 9943 | $fileInfo |
| 9926 | 9944 | ); |
| 9927 | - }else{ |
|
| 9945 | + } else{ |
|
| 9928 | 9946 | for($i = 0, $count = count($lines); $i < $count; $i++){ |
| 9929 | 9947 | $this->generator->addMapping( |
| 9930 | 9948 | $this->lineNumber + $i + 1, // generated_line |
@@ -9939,7 +9957,7 @@ discard block |
||
| 9939 | 9957 | |
| 9940 | 9958 | if(count($lines) === 1){ |
| 9941 | 9959 | $this->column += strlen($columns); |
| 9942 | - }else{ |
|
| 9960 | + } else{ |
|
| 9943 | 9961 | $this->lineNumber += count($lines) - 1; |
| 9944 | 9962 | $this->column = strlen($columns); |
| 9945 | 9963 | } |
@@ -27,21 +27,21 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | if (TYPO3_MODE === 'BE' && !(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_INSTALL)) { |
| 29 | 29 | |
| 30 | - /*************** |
|
| 30 | + /*************** |
|
| 31 | 31 | * Register Main Module |
| 32 | 32 | */ |
| 33 | 33 | $mainModuleName = "moox"; |
| 34 | 34 | if (!isset($TBE_MODULES[$mainModuleName])) { |
| 35 | - $temp_TBE_MODULES = array(); |
|
| 36 | - foreach ($TBE_MODULES as $key => $val) { |
|
| 37 | - if ($key == 'web') { |
|
| 38 | - $temp_TBE_MODULES[$key] = $val; |
|
| 39 | - $temp_TBE_MODULES[$mainModuleName] = ''; |
|
| 40 | - } else { |
|
| 41 | - $temp_TBE_MODULES[$key] = $val; |
|
| 42 | - } |
|
| 43 | - } |
|
| 44 | - $TBE_MODULES = $temp_TBE_MODULES; |
|
| 35 | + $temp_TBE_MODULES = array(); |
|
| 36 | + foreach ($TBE_MODULES as $key => $val) { |
|
| 37 | + if ($key == 'web') { |
|
| 38 | + $temp_TBE_MODULES[$key] = $val; |
|
| 39 | + $temp_TBE_MODULES[$mainModuleName] = ''; |
|
| 40 | + } else { |
|
| 41 | + $temp_TBE_MODULES[$key] = $val; |
|
| 42 | + } |
|
| 43 | + } |
|
| 44 | + $TBE_MODULES = $temp_TBE_MODULES; |
|
| 45 | 45 | \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule( |
| 46 | 46 | 'DCNGmbH.'.$_EXTKEY, |
| 47 | 47 | $mainModuleName, |
@@ -54,13 +54,13 @@ discard block |
||
| 54 | 54 | 'labels' => 'LLL:EXT:'.$_EXTKEY.'/Resources/Private/Language/MainModule.xlf', |
| 55 | 55 | ) |
| 56 | 56 | ); |
| 57 | - } |
|
| 58 | - \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule( |
|
| 59 | - 'DCNGmbH.'.$_EXTKEY, |
|
| 60 | - $mainModuleName, |
|
| 61 | - 'dashboard', |
|
| 62 | - 'top', |
|
| 63 | - array( |
|
| 57 | + } |
|
| 58 | + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule( |
|
| 59 | + 'DCNGmbH.'.$_EXTKEY, |
|
| 60 | + $mainModuleName, |
|
| 61 | + 'dashboard', |
|
| 62 | + 'top', |
|
| 63 | + array( |
|
| 64 | 64 | 'Administration' => 'dashboard', |
| 65 | 65 | ), |
| 66 | 66 | array( |
@@ -68,5 +68,5 @@ discard block |
||
| 68 | 68 | 'icon' => 'EXT:' . $_EXTKEY . '/Resources/Public/Icons/module-mooxcore.svg', |
| 69 | 69 | 'labels' => 'LLL:EXT:' . $_EXTKEY . '/Resources/Private/Language/DashboardModule.xlf', |
| 70 | 70 | ) |
| 71 | - ); |
|
| 71 | + ); |
|
| 72 | 72 | } |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile($_EXTKEY, 'Configuration/TypoScript', 'MOOX Core'); |
| 7 | -if ('BE' === TYPO3_MODE) { |
|
| 7 | +if ('BE'===TYPO3_MODE) { |
|
| 8 | 8 | \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScript($_EXTKEY, 'constants', '<INCLUDE_TYPOSCRIPT: source="FILE:EXT:moox_core/Configuration/TypoScript/constants.txt">'); |
| 9 | 9 | \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScript($_EXTKEY, 'setup', '<INCLUDE_TYPOSCRIPT: source="FILE:EXT:moox_core/Configuration/TypoScript/setup.txt">'); |
| 10 | 10 | } |
@@ -13,10 +13,10 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['moox_core']['setup'] = unserialize($_EXTCONF); |
| 15 | 15 | |
| 16 | -if (FALSE === (boolean) $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['moox_core']['setup']['disablePageTemplates']) { |
|
| 16 | +if (FALSE===(boolean)$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['moox_core']['setup']['disablePageTemplates']) { |
|
| 17 | 17 | \FluidTYPO3\Flux\Core::registerProviderExtensionKey('DCNGmbH.MooxCore', 'Page'); |
| 18 | 18 | } |
| 19 | -if (FALSE === (boolean) $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['moox_core']['setup']['disableContentTemplates']) { |
|
| 19 | +if (FALSE===(boolean)$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['moox_core']['setup']['disableContentTemplates']) { |
|
| 20 | 20 | \FluidTYPO3\Flux\Core::registerProviderExtensionKey('DCNGmbH.MooxCore', 'Content'); |
| 21 | 21 | } |
| 22 | 22 | |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | Register BE-Module for Administration |
| 26 | 26 | =========================================================================== */ |
| 27 | 27 | |
| 28 | -if (TYPO3_MODE === 'BE' && !(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_INSTALL)) { |
|
| 28 | +if (TYPO3_MODE==='BE' && !(TYPO3_REQUESTTYPE&TYPO3_REQUESTTYPE_INSTALL)) { |
|
| 29 | 29 | |
| 30 | 30 | /*************** |
| 31 | 31 | * Register Main Module |
@@ -34,10 +34,10 @@ discard block |
||
| 34 | 34 | if (!isset($TBE_MODULES[$mainModuleName])) { |
| 35 | 35 | $temp_TBE_MODULES = array(); |
| 36 | 36 | foreach ($TBE_MODULES as $key => $val) { |
| 37 | - if ($key == 'web') { |
|
| 37 | + if ($key=='web') { |
|
| 38 | 38 | $temp_TBE_MODULES[$key] = $val; |
| 39 | 39 | $temp_TBE_MODULES[$mainModuleName] = ''; |
| 40 | - } else { |
|
| 40 | + }else { |
|
| 41 | 41 | $temp_TBE_MODULES[$key] = $val; |
| 42 | 42 | } |
| 43 | 43 | } |
@@ -65,8 +65,8 @@ discard block |
||
| 65 | 65 | ), |
| 66 | 66 | array( |
| 67 | 67 | 'access' => 'user,group', |
| 68 | - 'icon' => 'EXT:' . $_EXTKEY . '/Resources/Public/Icons/module-mooxcore.svg', |
|
| 69 | - 'labels' => 'LLL:EXT:' . $_EXTKEY . '/Resources/Private/Language/Module.xlf:moox_dashboard_module_tab', |
|
| 68 | + 'icon' => 'EXT:'.$_EXTKEY.'/Resources/Public/Icons/module-mooxcore.svg', |
|
| 69 | + 'labels' => 'LLL:EXT:'.$_EXTKEY.'/Resources/Private/Language/Module.xlf:moox_dashboard_module_tab', |
|
| 70 | 70 | ) |
| 71 | 71 | ); |
| 72 | 72 | } |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | * writing. "version" and "dependencies" must not be touched! |
| 11 | 11 | ***************************************************************/ |
| 12 | 12 | |
| 13 | -$EM_CONF[$_EXTKEY] = array ( |
|
| 13 | +$EM_CONF[$_EXTKEY] = array( |
|
| 14 | 14 | 'title' => 'MOOX Bootstrap Core', |
| 15 | 15 | 'description' => 'TYPO3 Responsive using Less, Bootstrap, HTML5 Boilerplate and jQuery. Extended by MOOX Design Templates, MOOX News and other MOOX Extensions.', |
| 16 | 16 | 'category' => 'fe', |
@@ -28,8 +28,8 @@ discard block |
||
| 28 | 28 | 'author' => 'MOOX Team', |
| 29 | 29 | 'author_email' => '[email protected]', |
| 30 | 30 | 'author_company' => 'DCN GmbH', |
| 31 | - 'constraints' => array ( |
|
| 32 | - 'depends' => array ( |
|
| 31 | + 'constraints' => array( |
|
| 32 | + 'depends' => array( |
|
| 33 | 33 | 'typo3' => '7.6.0-7.6.99', |
| 34 | 34 | 'cms' => '', |
| 35 | 35 | 'flux' => '7.2.0-7.3.99', |
@@ -38,11 +38,11 @@ discard block |
||
| 38 | 38 | 'fluidpages' => '', |
| 39 | 39 | 'realurl' => '', |
| 40 | 40 | ), |
| 41 | - 'conflicts' => array ( |
|
| 41 | + 'conflicts' => array( |
|
| 42 | 42 | 'css_styled_content' => '', |
| 43 | 43 | 'fluid_styled_content' => '' |
| 44 | 44 | ), |
| 45 | - 'suggests' => array ( |
|
| 45 | + 'suggests' => array( |
|
| 46 | 46 | ), |
| 47 | 47 | ), |
| 48 | 48 | '_md5_values_when_last_written' => 'a:0:{}', |