From e34f59a66f11d9d9b056adf2557f7fcf21e45c20 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Tue, 22 Mar 2016 10:45:27 +0900 Subject: [PATCH 01/10] Change minimum PHP version to 5.5.9 --- README.md | 13 +++++++++---- common/constants.php | 2 +- modules/install/install.controller.php | 11 +++++------ modules/install/tpl/check_env.html | 13 ++++++------- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 7c3975e43..83fc1d487 100644 --- a/README.md +++ b/README.md @@ -32,18 +32,23 @@ Rhymix는 개발자와 사용자가 서로의 권리와 책임을 존중하는 ### 설치 환경 -- PHP 5.3.3 이상 (PHP 5.5.9 이상 권장, PHP 7 지원) -- MySQL 4.1.13 이상 (MySQL 5.0.7 이상 또는 MariaDB 권장) -- CUBRID 또는 MS SQL을 DB로 사용할 수도 있으나, 권장하지는 않습니다. +Rhymix를 사용하려면 아래의 조건을 충족하는 웹호스팅이나 서버를 마련하셔야 합니다. + + +- PHP 5.5.9 이상 (PHP 7 권장) +- MySQL 5.0.7 이상 (MariaDB 권장) - 필수 PHP 모듈 - curl - gd - iconv 또는 mbstring - json - mcrypt 또는 openssl - - xml 및 simplexml + - simplexml - php.ini에서 session.auto_start = Off로 설정되어 있어야 합니다. - 설치 폴더 또는 files 폴더에 쓰기 권한이 주어져야 합니다. +- MySQL/MariaDB 외에도 아래의 DB를 사용할 수 있습니다. + - CUBRID 9.0 이상 + - Microsoft SQL Server 2008 이상 ### 개발 참여 diff --git a/common/constants.php b/common/constants.php index 16ff4dc38..c201bff5a 100644 --- a/common/constants.php +++ b/common/constants.php @@ -124,7 +124,7 @@ define('__XE_VERSION_ALPHA__', false); define('__XE_VERSION_BETA__', false); define('__XE_VERSION_RC__', false); define('__XE_VERSION_STABLE__', true); -define('__XE_MIN_PHP_VERSION__', '5.3.3'); +define('__XE_MIN_PHP_VERSION__', '5.5.9'); define('__XE_RECOMMEND_PHP_VERSION__', '5.5.9'); define('__ZBXE__', true); define('__ZBXE_VERSION__', RX_VERSION); diff --git a/modules/install/install.controller.php b/modules/install/install.controller.php index 6b33b4229..2f6f373a0 100644 --- a/modules/install/install.controller.php +++ b/modules/install/install.controller.php @@ -364,15 +364,14 @@ class installController extends install $checklist = array(); // Check PHP version - $checklist['php_version'] = true; - if(version_compare(PHP_VERSION, __XE_MIN_PHP_VERSION__, '<')) + if(version_compare(PHP_VERSION, __XE_MIN_PHP_VERSION__, '>=')) + { + $checklist['php_version'] = true; + } + else { $checklist['php_version'] = false; } - if(version_compare(PHP_VERSION, __XE_RECOMMEND_PHP_VERSION__, '<')) - { - Context::set('phpversion_warning', true); - } // Check DB if(DB::getEnableList()) diff --git a/modules/install/tpl/check_env.html b/modules/install/tpl/check_env.html index 8bb498790..e2cc54949 100644 --- a/modules/install/tpl/check_env.html +++ b/modules/install/tpl/check_env.html @@ -16,14 +16,13 @@ ERROR - + - {sprintf($lang->install_checklist_desc['php_version_warning'], __XE_RECOMMEND_PHP_VERSION__)} [{$lang->more}] - - - - - {$lang->install_checklist_desc[$key]} + + {sprintf($lang->install_checklist_desc[$key], __XE_MIN_PHP_VERSION__)} + + {$lang->install_checklist_desc[$key]} + From 1873270a595af4ae2830d4f50c13141a1895c082 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Tue, 22 Mar 2016 10:53:49 +0900 Subject: [PATCH 02/10] Change minimum MySQL version to 5.0.7 --- classes/db/DBMysql.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/classes/db/DBMysql.class.php b/classes/db/DBMysql.class.php index a8f321c64..27e16b315 100644 --- a/classes/db/DBMysql.class.php +++ b/classes/db/DBMysql.class.php @@ -77,10 +77,10 @@ class DBMysql extends DB return; } - // Error appears if the version is lower than 4.1.13 - if(version_compare(mysql_get_server_info($result), '4.1.13', '<')) + // Error appears if the version is lower than 5.0.7 + if(version_compare(mysql_get_server_info($result), '5.0.7', '<')) { - $this->setError(-1, 'Rhymix requires MySQL 4.1.13 or later. Current MySQL version is ' . mysql_get_server_info()); + $this->setError(-1, 'Rhymix requires MySQL 5.0.7 or later. Current MySQL version is ' . mysql_get_server_info()); return; } From df3837ae6f144de135f8ca2f97dfd8443bf035ee Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Tue, 22 Mar 2016 10:56:44 +0900 Subject: [PATCH 03/10] Change minimum CUBRID version to 9.0 --- classes/db/DBCubrid.class.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/classes/db/DBCubrid.class.php b/classes/db/DBCubrid.class.php index 9059b99ce..1491eb73b 100644 --- a/classes/db/DBCubrid.class.php +++ b/classes/db/DBCubrid.class.php @@ -81,9 +81,14 @@ class DBCubrid extends DB define('__CUBRID_VERSION__', $cubrid_version); } - if(__CUBRID_VERSION__ >= '8.4.0') - cubrid_set_autocommit($result, CUBRID_AUTOCOMMIT_TRUE); - + if(version_compare(__CUBRID_VERSION__, '9.0', '<')) + { + $this->setError(-1, 'Rhymix requires CUBRID 9.0 or later. Current CUBRID version is ' . __CUBRID_VERSION__); + return; + } + + cubrid_set_autocommit($result, CUBRID_AUTOCOMMIT_TRUE); + return $result; } From 52627de4a344ed53e0e9e2dab1936f710d9a2819 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Tue, 22 Mar 2016 11:01:53 +0900 Subject: [PATCH 04/10] Change minimum MS SQL version to 10 (2008) --- classes/db/DBMssql.class.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/classes/db/DBMssql.class.php b/classes/db/DBMssql.class.php index c6d150b8c..a1473ac73 100644 --- a/classes/db/DBMssql.class.php +++ b/classes/db/DBMssql.class.php @@ -71,6 +71,16 @@ class DBMssql extends DB $this->setError(-1, 'database connect fail' . PHP_EOL . $errors); return; } + + $server_info = sqlsrv_server_info($result); + $server_version = $server_info['SQLServerVersion']; + if ($server_version && version_compare($server_version, '10', '<')) + { + $this->setError(-1, 'Rhymix requires Microsoft SQL Server 2008 or later. Current version is ' . $server_version); + return; + } + + return $result; } From 3f4f5299cbb8076d25f208c72e7f5fdb93ea96c6 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Tue, 22 Mar 2016 11:08:17 +0900 Subject: [PATCH 05/10] Disable mysql DB driver and only use mysqli --- classes/db/DB.class.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/classes/db/DB.class.php b/classes/db/DB.class.php index fbc205adc..e9f75a05f 100644 --- a/classes/db/DB.class.php +++ b/classes/db/DB.class.php @@ -24,7 +24,6 @@ class DB */ protected static $priority_dbms = array( 'mysqli' => 6, - 'mysql' => 4, 'cubrid' => 2, 'mssql' => 1 ); @@ -271,9 +270,13 @@ class DB // after creating instance of class, check is supported foreach ($supported_list as $db_type) { + if (strncasecmp($db_type, 'mysql', 5) === 0 && strtolower($db_type) !== 'mysqli') + { + continue; + } $class_name = sprintf("DB%s%s", strtoupper(substr($db_type, 0, 1)), strtolower(substr($db_type, 1))); $class_file = sprintf(_XE_PATH_ . "classes/db/%s.class.php", $class_name); - if(!file_exists($class_file) || stripos($class_file, '_innodb') !== false) + if (!file_exists($class_file)) { continue; } From 39262bf2413098fbcd7137368fa6ae6c958e9c2c Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Tue, 22 Mar 2016 11:11:02 +0900 Subject: [PATCH 06/10] Remove unit tests for PHP 5.3 and acceptance tests for PHP 5.4 --- .travis.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 04ec79659..eb62f813c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ language: php php: -- 5.3 - 5.4 - 5.5 - 5.6 @@ -11,14 +10,14 @@ before_script: - npm install grunt grunt-cli grunt-contrib-jshint grunt-contrib-csslint grunt-phplint --save-dev - mysql -u root -e "CREATE DATABASE rhymix" - mysql -u root -e "SET PASSWORD FOR 'travis'@'localhost' = PASSWORD('travis')" -- if [[ $TRAVIS_PHP_VERSION != "hhvm" ]]; then php -S localhost:8000 & fi -- if [[ $TRAVIS_PHP_VERSION == "5.3" ]]; then touch codecept.phar; fi +- if [[ $TRAVIS_PHP_VERSION != "5.4" && $TRAVIS_PHP_VERSION != "hhvm" ]]; then php -S localhost:8000 & fi - if [[ $TRAVIS_PHP_VERSION == "5.4" ]]; then wget http://codeception.com/releases/2.0.16/codecept.phar; fi - if [[ ! -f codecept.phar ]]; then wget http://codeception.com/releases/2.1.6/codecept.phar; fi script: - if [[ -s codecept.phar ]]; then php codecept.phar build; fi - if [[ -s codecept.phar && $TRAVIS_PHP_VERSION == "hhvm" ]]; then php codecept.phar run -d --fail-fast --env travis --skip install; fi -- if [[ -s codecept.phar && $TRAVIS_PHP_VERSION != "hhvm" ]]; then php codecept.phar run -d --fail-fast --env travis; fi +- if [[ -s codecept.phar && $TRAVIS_PHP_VERSION == "5.4" ]]; then php codecept.phar run -d --fail-fast --env travis --skip install; fi +- if [[ -s codecept.phar && $TRAVIS_PHP_VERSION != "5.4" && $TRAVIS_PHP_VERSION != "hhvm" ]]; then php codecept.phar run -d --fail-fast --env travis; fi - grunt lint notifications: email: false From 06f5151f8f3912c504aacc1a2ec61fbcf2f6bb9a Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Tue, 22 Mar 2016 11:17:35 +0900 Subject: [PATCH 07/10] Update contributor guide --- CONTRIBUTING.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7e482d998..fd98ea028 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -58,6 +58,8 @@ PHP, HTML, XML, CSS, JS 등 모든 텍스트 파일의 문자셋은 BOM이 없 들여쓰기는 1개의 탭으로 합니다. 단, 탭 대신 공백을 사용하는 파일에서는 일관성 유지를 위해 4칸의 공백을 사용할 수 있습니다. +들여쓴 줄들 사이의 빈 줄도 들여씁니다. (에디터에서 후행 공백을 제거하지 않도록 설정하십시오.) + PHP 코드만으로 이루어진 파일은 맨 끝에 `?>` 태그를 사용하지 않습니다. ### 공백 및 줄바꿈 규칙 @@ -155,5 +157,8 @@ Rhymix에서 정한 `error_reporting` 설정 하에서 어떤 에러도 발생 문자열과 문자열, 정수와 정수를 비교할 때는 가능하면 `==` 대신 `===`을 사용합니다. 실제 자료형이 다를 가능성이 있는 경우 `intval()`, `strval()` 등의 함수와 함께 사용합니다. +PHP 5.4 이상에서 지원하는 간단한 배열 문법(`[1, 2, 3]`)을 사용할 수 있으나, +복잡한 구조의 배열을 선언할 때는 이 문법이 오히려 가독성을 해칠 수 있으니 주의하시기 바랍니다. + 여기에서 규정하지 않은 내용은 [PSR-1](http://www.php-fig.org/psr/psr-1/)과 [PSR-2](http://www.php-fig.org/psr/psr-2/)를 따릅니다. From 365d7cdba9ffc1e8b33a6025dea583225b0f5fe8 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Tue, 22 Mar 2016 11:26:00 +0900 Subject: [PATCH 08/10] Update composer dependencies --- composer.json | 7 +- composer.lock | 59 +- vendor/composer/autoload_classmap.php | 12 +- vendor/composer/installed.json | 151 +- vendor/firephp/firephp-core/.gitignore | 1 - vendor/firephp/firephp-core/CHANGELOG.md | 171 -- vendor/firephp/firephp-core/README.md | 75 - vendor/firephp/firephp-core/composer.json | 26 - vendor/firephp/firephp-core/examples/oo.php | 82 - vendor/firephp/firephp-core/examples/oo.php4 | 72 - .../firephp-core/examples/procedural.php | 79 - .../firephp-core/examples/procedural.php4 | 69 - .../lib/FirePHPCore/FirePHP.class.php | 1828 ----------------- .../lib/FirePHPCore/FirePHP.class.php4 | 1327 ------------ .../firephp-core/lib/FirePHPCore/fb.php | 275 --- .../firephp-core/lib/FirePHPCore/fb.php4 | 245 --- vendor/firephp/firephp-core/package.json | 43 - vendor/firephp/firephp-core/program.json | 5 - .../firephp-core/tests/API/newlines.php | 12 - .../tests/FirePHPCore/FirePHPTest.php | 181 -- .../firephp/firephp-core/tests/TestHelper.php | 55 - vendor/firephp/firephp-core/tests/phpunit.xml | 2 - .../firephp/firephp-core/workspace/README.md | 19 - .../firephp-core/workspace/lib/project.js | 5 - .../firephp-core/workspace/package.json | 28 - .../firephp-core/workspace/program.json | 78 - .../firephp-core/workspace/scripts/build.js | 164 -- .../firephp-core/workspace/scripts/publish.js | 65 - .../firephp-core/workspace/tpl/license.tpl.md | 21 - .../workspace/tpl/pear.package.tpl.xml | 61 - .../firephp-core/workspace/tpl/readme.tpl.md | 17 - vendor/leafo/scssphp/bin/pscss | 42 +- vendor/leafo/scssphp/classmap.php | 63 - vendor/leafo/scssphp/composer.json | 5 +- vendor/leafo/scssphp/scss.inc.php | 8 +- vendor/leafo/scssphp/src/Base/Range.php | 2 +- vendor/leafo/scssphp/src/Block.php | 11 +- vendor/leafo/scssphp/src/Colors.php | 7 +- vendor/leafo/scssphp/src/Compiler.php | 933 +++++---- .../scssphp/src/Compiler/Environment.php | 4 +- .../src/Exception/CompilerException.php | 21 + .../scssphp/src/Exception/ParserException.php | 21 + .../scssphp/src/Exception/ServerException.php | 21 + vendor/leafo/scssphp/src/Formatter.php | 16 +- .../leafo/scssphp/src/Formatter/Compact.php | 3 +- .../scssphp/src/Formatter/Compressed.php | 26 +- .../leafo/scssphp/src/Formatter/Crunched.php | 15 +- vendor/leafo/scssphp/src/Formatter/Debug.php | 3 +- .../leafo/scssphp/src/Formatter/Expanded.php | 3 +- vendor/leafo/scssphp/src/Formatter/Nested.php | 5 +- .../scssphp/src/Formatter/OutputBlock.php | 2 +- vendor/leafo/scssphp/src/Node.php | 11 +- vendor/leafo/scssphp/src/Node/Number.php | 189 +- vendor/leafo/scssphp/src/Parser.php | 537 +++-- vendor/leafo/scssphp/src/Server.php | 42 +- vendor/leafo/scssphp/src/Type.php | 3 +- vendor/leafo/scssphp/src/Util.php | 2 +- vendor/leafo/scssphp/src/Version.php | 2 +- 58 files changed, 1245 insertions(+), 5987 deletions(-) delete mode 100644 vendor/firephp/firephp-core/.gitignore delete mode 100644 vendor/firephp/firephp-core/CHANGELOG.md delete mode 100644 vendor/firephp/firephp-core/README.md delete mode 100644 vendor/firephp/firephp-core/composer.json delete mode 100644 vendor/firephp/firephp-core/examples/oo.php delete mode 100644 vendor/firephp/firephp-core/examples/oo.php4 delete mode 100644 vendor/firephp/firephp-core/examples/procedural.php delete mode 100644 vendor/firephp/firephp-core/examples/procedural.php4 delete mode 100644 vendor/firephp/firephp-core/lib/FirePHPCore/FirePHP.class.php delete mode 100644 vendor/firephp/firephp-core/lib/FirePHPCore/FirePHP.class.php4 delete mode 100644 vendor/firephp/firephp-core/lib/FirePHPCore/fb.php delete mode 100644 vendor/firephp/firephp-core/lib/FirePHPCore/fb.php4 delete mode 100644 vendor/firephp/firephp-core/package.json delete mode 100644 vendor/firephp/firephp-core/program.json delete mode 100644 vendor/firephp/firephp-core/tests/API/newlines.php delete mode 100644 vendor/firephp/firephp-core/tests/FirePHPCore/FirePHPTest.php delete mode 100644 vendor/firephp/firephp-core/tests/TestHelper.php delete mode 100644 vendor/firephp/firephp-core/tests/phpunit.xml delete mode 100644 vendor/firephp/firephp-core/workspace/README.md delete mode 100644 vendor/firephp/firephp-core/workspace/lib/project.js delete mode 100644 vendor/firephp/firephp-core/workspace/package.json delete mode 100644 vendor/firephp/firephp-core/workspace/program.json delete mode 100644 vendor/firephp/firephp-core/workspace/scripts/build.js delete mode 100644 vendor/firephp/firephp-core/workspace/scripts/publish.js delete mode 100644 vendor/firephp/firephp-core/workspace/tpl/license.tpl.md delete mode 100644 vendor/firephp/firephp-core/workspace/tpl/pear.package.tpl.xml delete mode 100644 vendor/firephp/firephp-core/workspace/tpl/readme.tpl.md delete mode 100644 vendor/leafo/scssphp/classmap.php create mode 100644 vendor/leafo/scssphp/src/Exception/CompilerException.php create mode 100644 vendor/leafo/scssphp/src/Exception/ParserException.php create mode 100644 vendor/leafo/scssphp/src/Exception/ServerException.php diff --git a/composer.json b/composer.json index f73391383..93d8d662d 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ { "name": "NAVER", "email": "developers@xpressengine.com" } ], "require": { - "php": ">=5.3.3", + "php": ">=5.5.9", "ext-curl": "*", "ext-gd": "*", "ext-iconv": "*", @@ -21,13 +21,13 @@ "ext-xml": "*", "defuse/php-encryption": "1.2.1", "ezyang/htmlpurifier": "4.7.*", - "firephp/firephp-core": "0.4.0", "hautelook/phpass": "0.3.*", "jbbcode/jbbcode": "1.3.*", "leafo/lessphp": "0.5.*", - "leafo/scssphp": "0.4.*", + "leafo/scssphp": "0.6.*", "league/html-to-markdown": "4.2.*", "matthiasmullie/minify": "1.3.*", + "matthiasmullie/path-converter": "1.*", "michelf/php-markdown": "1.6.*", "michelf/php-smartypants": "1.6.0-beta1", "rmccue/requests": "1.6.*", @@ -36,7 +36,6 @@ "true/punycode": "2.*" }, "require-dev": { - "php": ">=5.4.0", "codeception/codeception": "2.1.*", "codeception/verify": "0.3.*", "codeception/specify": "0.4.*" diff --git a/composer.lock b/composer.lock index faa67f0d3..94887961c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "61ea4cb999dbb61cd01ba1a4ede5ead6", - "content-hash": "ec214228f19d828ce0ea5feeb0a72aba", + "hash": "ff1a5bab9497b1e5f25dd3069ffbbf13", + "content-hash": "9478a148fd56f1f50543063e3971a777", "packages": [ { "name": "defuse/php-encryption", @@ -96,42 +96,6 @@ ], "time": "2015-08-05 01:03:42" }, - { - "name": "firephp/firephp-core", - "version": "v0.4.0", - "source": { - "type": "git", - "url": "https://github.com/firephp/firephp-core.git", - "reference": "fabad0f2503f9577fe8dd2cb1d1c7cd73ed2aacf" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/firephp/firephp-core/zipball/fabad0f2503f9577fe8dd2cb1d1c7cd73ed2aacf", - "reference": "fabad0f2503f9577fe8dd2cb1d1c7cd73ed2aacf", - "shasum": "" - }, - "type": "library", - "autoload": { - "classmap": [ - "lib/FirePHPCore/FirePHP.class.php", - "lib/FirePHPCore/fb.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Christoph Dorn", - "email": "christoph@christophdorn.com", - "homepage": "http://christophdorn.com" - } - ], - "description": "Traditional FirePHPCore library for sending PHP variables to the browser.", - "homepage": "https://github.com/firephp/firephp-core", - "time": "2013-04-23 15:28:20" - }, { "name": "hautelook/phpass", "version": "0.3.4", @@ -265,34 +229,31 @@ }, { "name": "leafo/scssphp", - "version": "v0.4.0", + "version": "v0.6.3", "source": { "type": "git", "url": "https://github.com/leafo/scssphp.git", - "reference": "78a6f27aa4eaf70bb3ff4d13b639bab71fdaf47a" + "reference": "a27edad3d16635a222d7204706572e24c338aa17" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/leafo/scssphp/zipball/78a6f27aa4eaf70bb3ff4d13b639bab71fdaf47a", - "reference": "78a6f27aa4eaf70bb3ff4d13b639bab71fdaf47a", + "url": "https://api.github.com/repos/leafo/scssphp/zipball/a27edad3d16635a222d7204706572e24c338aa17", + "reference": "a27edad3d16635a222d7204706572e24c338aa17", "shasum": "" }, "require": { - "php": ">=5.3.0" + "php": ">=5.4.0" }, "require-dev": { "kherge/box": "~2.5", "phpunit/phpunit": "~3.7", - "squizlabs/php_codesniffer": "~2.3" + "squizlabs/php_codesniffer": "~2.5" }, "bin": [ "bin/pscss" ], "type": "library", "autoload": { - "classmap": [ - "classmap.php" - ], "psr-4": { "Leafo\\ScssPhp\\": "src/" } @@ -317,7 +278,7 @@ "scss", "stylesheet" ], - "time": "2015-11-09 14:44:09" + "time": "2016-01-15 02:50:06" }, { "name": "league/html-to-markdown", @@ -796,7 +757,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=5.3.3", + "php": ">=5.5.9", "ext-curl": "*", "ext-gd": "*", "ext-iconv": "*", diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index 3308cbc96..677abfb02 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -6,8 +6,6 @@ $vendorDir = dirname(dirname(__FILE__)); $baseDir = dirname($vendorDir); return array( - 'FB' => $vendorDir . '/firephp/firephp-core/lib/FirePHPCore/fb.php', - 'FirePHP' => $vendorDir . '/firephp/firephp-core/lib/FirePHPCore/FirePHP.class.php', 'HTMLPurifier' => $vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier.php', 'HTMLPurifier_Arborize' => $vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier/Arborize.php', 'HTMLPurifier_AttrCollections' => $vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier/AttrCollections.php', @@ -262,6 +260,9 @@ return array( 'Leafo\\ScssPhp\\Colors' => $vendorDir . '/leafo/scssphp/src/Colors.php', 'Leafo\\ScssPhp\\Compiler' => $vendorDir . '/leafo/scssphp/src/Compiler.php', 'Leafo\\ScssPhp\\Compiler\\Environment' => $vendorDir . '/leafo/scssphp/src/Compiler/Environment.php', + 'Leafo\\ScssPhp\\Exception\\CompilerException' => $vendorDir . '/leafo/scssphp/src/Exception/CompilerException.php', + 'Leafo\\ScssPhp\\Exception\\ParserException' => $vendorDir . '/leafo/scssphp/src/Exception/ParserException.php', + 'Leafo\\ScssPhp\\Exception\\ServerException' => $vendorDir . '/leafo/scssphp/src/Exception/ServerException.php', 'Leafo\\ScssPhp\\Formatter' => $vendorDir . '/leafo/scssphp/src/Formatter.php', 'Leafo\\ScssPhp\\Formatter\\Compact' => $vendorDir . '/leafo/scssphp/src/Formatter/Compact.php', 'Leafo\\ScssPhp\\Formatter\\Compressed' => $vendorDir . '/leafo/scssphp/src/Formatter/Compressed.php', @@ -370,11 +371,4 @@ return array( 'lessc_formatter_compressed' => $vendorDir . '/leafo/lessphp/lessc.inc.php', 'lessc_formatter_lessjs' => $vendorDir . '/leafo/lessphp/lessc.inc.php', 'lessc_parser' => $vendorDir . '/leafo/lessphp/lessc.inc.php', - 'scss_formatter' => $vendorDir . '/leafo/scssphp/classmap.php', - 'scss_formatter_compressed' => $vendorDir . '/leafo/scssphp/classmap.php', - 'scss_formatter_crunched' => $vendorDir . '/leafo/scssphp/classmap.php', - 'scss_formatter_nested' => $vendorDir . '/leafo/scssphp/classmap.php', - 'scss_parser' => $vendorDir . '/leafo/scssphp/classmap.php', - 'scss_server' => $vendorDir . '/leafo/scssphp/classmap.php', - 'scssc' => $vendorDir . '/leafo/scssphp/classmap.php', ); diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 77f6e6a65..a9a2cc050 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -343,44 +343,6 @@ "punycode" ] }, - { - "name": "firephp/firephp-core", - "version": "v0.4.0", - "version_normalized": "0.4.0.0", - "source": { - "type": "git", - "url": "https://github.com/firephp/firephp-core.git", - "reference": "fabad0f2503f9577fe8dd2cb1d1c7cd73ed2aacf" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/firephp/firephp-core/zipball/fabad0f2503f9577fe8dd2cb1d1c7cd73ed2aacf", - "reference": "fabad0f2503f9577fe8dd2cb1d1c7cd73ed2aacf", - "shasum": "" - }, - "time": "2013-04-23 15:28:20", - "type": "library", - "installation-source": "dist", - "autoload": { - "classmap": [ - "lib/FirePHPCore/FirePHP.class.php", - "lib/FirePHPCore/fb.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Christoph Dorn", - "email": "christoph@christophdorn.com", - "homepage": "http://christophdorn.com" - } - ], - "description": "Traditional FirePHPCore library for sending PHP variables to the browser.", - "homepage": "https://github.com/firephp/firephp-core" - }, { "name": "matthiasmullie/minify", "version": "1.3.34", @@ -629,64 +591,6 @@ "description": "lessphp is a compiler for LESS written in PHP.", "homepage": "http://leafo.net/lessphp/" }, - { - "name": "leafo/scssphp", - "version": "v0.4.0", - "version_normalized": "0.4.0.0", - "source": { - "type": "git", - "url": "https://github.com/leafo/scssphp.git", - "reference": "78a6f27aa4eaf70bb3ff4d13b639bab71fdaf47a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/leafo/scssphp/zipball/78a6f27aa4eaf70bb3ff4d13b639bab71fdaf47a", - "reference": "78a6f27aa4eaf70bb3ff4d13b639bab71fdaf47a", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "require-dev": { - "kherge/box": "~2.5", - "phpunit/phpunit": "~3.7", - "squizlabs/php_codesniffer": "~2.3" - }, - "time": "2015-11-09 14:44:09", - "bin": [ - "bin/pscss" - ], - "type": "library", - "installation-source": "dist", - "autoload": { - "classmap": [ - "classmap.php" - ], - "psr-4": { - "Leafo\\ScssPhp\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Leaf Corcoran", - "email": "leafot@gmail.com", - "homepage": "http://leafo.net" - } - ], - "description": "scssphp is a compiler for SCSS written in PHP.", - "homepage": "http://leafo.github.io/scssphp/", - "keywords": [ - "css", - "less", - "sass", - "scss", - "stylesheet" - ] - }, { "name": "league/html-to-markdown", "version": "4.2.0", @@ -809,5 +713,60 @@ "typographer", "typography" ] + }, + { + "name": "leafo/scssphp", + "version": "v0.6.3", + "version_normalized": "0.6.3.0", + "source": { + "type": "git", + "url": "https://github.com/leafo/scssphp.git", + "reference": "a27edad3d16635a222d7204706572e24c338aa17" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/leafo/scssphp/zipball/a27edad3d16635a222d7204706572e24c338aa17", + "reference": "a27edad3d16635a222d7204706572e24c338aa17", + "shasum": "" + }, + "require": { + "php": ">=5.4.0" + }, + "require-dev": { + "kherge/box": "~2.5", + "phpunit/phpunit": "~3.7", + "squizlabs/php_codesniffer": "~2.5" + }, + "time": "2016-01-15 02:50:06", + "bin": [ + "bin/pscss" + ], + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Leafo\\ScssPhp\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Leaf Corcoran", + "email": "leafot@gmail.com", + "homepage": "http://leafo.net" + } + ], + "description": "scssphp is a compiler for SCSS written in PHP.", + "homepage": "http://leafo.github.io/scssphp/", + "keywords": [ + "css", + "less", + "sass", + "scss", + "stylesheet" + ] } ] diff --git a/vendor/firephp/firephp-core/.gitignore b/vendor/firephp/firephp-core/.gitignore deleted file mode 100644 index d16386367..000000000 --- a/vendor/firephp/firephp-core/.gitignore +++ /dev/null @@ -1 +0,0 @@ -build/ \ No newline at end of file diff --git a/vendor/firephp/firephp-core/CHANGELOG.md b/vendor/firephp/firephp-core/CHANGELOG.md deleted file mode 100644 index d8b0f86df..000000000 --- a/vendor/firephp/firephp-core/CHANGELOG.md +++ /dev/null @@ -1,171 +0,0 @@ - -TODO: - - * Fix code indenting in PHP 4 code - * Port maxDepth option to PHP 4 code - -2013-04-23 - Release Version: 0.4.0 - - * No changes - -2011-06-22 - Release Version: 0.4.0rc3 - - * Build fixes - -2011-06-20 - Release Version: 0.4.0rc1 - - * (Issue 163) PHP5 class_exists() throws Exception without second parameter - * (Issue 166) Non-utf8 array values replaced with null - * Cleaned up code formatting [sokolov.innokenty@gmail.com] - * Ensure JSON keys are never NULL (due to NULL key in some arrays) - * Better UTF-8 encoding detection - * Code style cleanup (qbbr) - * Changed license to MIT - * Refactored project - -2010-10-26 - Release Version: 0.3.2 - -2010-10-12 - Release Version: 0.3.2rc6 - - * (Issue 154) getRequestHeader uses "getallheaders" even though it doesn't always exist. [25m] - -2010-10-09 - Release Version: 0.3.2rc5 - - * (Issue 153) FirePHP incorrectly double-encodes UTF8 when mbstring.func_overload is enabled - -2010-10-08 - Release Version: 0.3.2rc4 - - * Trigger upgrade message if part of FirePHP 1.0 - * Removed FirePHP/Init.php inclusion logic and only load FirePHP.class.php if not already loaded - -2010-07-19 - Release Version: 0.3.2rc3 - - * Fixed FirePHP/Init.php inclusion logic - -2010-07-19 - Release Version: 0.3.2rc2 - - * (Issue 145) maxDepth option - * Changed maxObjectDepth and maxArrayDepth option defaults to 5 - * Fixed code indentation - -2010-03-05 - Release Version: 0.3.2rc1 - - * (Issue 114) Allow options to be passed on to basic logging wrappers - * (Issue 122) Filter objectStack property of FirePHP class - * (Issue 123) registerErrorHandler(false) by default - * Added setOption() and getOption() methods - * (Issue 117) dump() method argument validation - * Started adding PHPUnit tests - * Some refactoring to support unit testing - * Deprecated setProcessorUrl() and setRendererUrl() - * Check User-Agent and X-FirePHP-Version header to detect FirePHP on client - * (Issue 135) FirePHP 0.4.3 with Firebug 1.5 changes user agent on the fly - * (Issue 112) Error Predefined Constants Not available for PHP 5.x versions - -2008-06-14 - Release Version: 0.3.1 - - * (Issue 108) ignore class name case in object filter - -2009-05-11 - Release Version: 0.3 -2009-05-01 - Release Version: 0.3.rc.1 - - * (Issue 90) PHP4 compatible version of FirePHPCore - * (Issue 98) Thrown exceptions don't send an HTTP 500 if the FirePHP exception handler is enabled - * (Issue 85) Support associative arrays in encodeTable method in FirePHP.class.php - * (Issue 66) Add a new getOptions() public method in API - * (Issue 82) Define $this->options outside of __construct - * (Issue 72) Message error if group name is null - * (Issue 68) registerErrorHandler() and registerExceptionHandler() should returns previous handlers defined - * (Issue 69) Add the missing register handler in the triumvirate (error, exception, assert) - * (Issue 75) [Error & Exception Handling] Option to not exit script execution - * (Issue 83) Exception handler can't throw exceptions - * (Issue 80) Auto/Pre collapsing groups AND Custom group row colors - -2008-11-09 - Release Version: 0.2.1 - - * (Issue 70) Problem when logging resources - -2008-10-21 - Release Version: 0.2.0 - - * Updated version to 0.2.0 - * Switched to using __sleep instead of __wakeup - * Added support to exclude object members when encoding - * Add support to enable/disable logging - -2008-10-17 - Release Version: 0.2.b.8 - - * New implementation for is_utf8() - * (Issue 55) maxObjectDepth Option not working correctly when using TABLE and EXCEPTION Type - * Bugfix for max[Object|Array]Depth when encoding nested array/object graphs - * Bugfix for FB::setOptions() - -2008-10-16 - Release Version: 0.2.b.7 - - * (Issue 45) Truncate dump when string have non utf8 cars - * (Issue 52) logging will not work when firephp object gets stored in the session. - -2008-10-16 - Release Version: 0.2.b.6 - - * (Issue 37) Display file and line information for each log message - * (Issue 51) Limit output of object graphs - * Bugfix for encoding object members set to NULL|false|'' - -2008-10-14 - Release Version: 0.2.b.5 - - * Updated JsonStream wildfire protocol to be more robust - * (Issue 33) PHP error notices running demos - * (Issue 48) Warning: ReflectionProperty::getValue() expects exactly 1 parameter, 0 given - -2008-10-08 - Release Version: 0.2.b.4 - - * Bugfix for logging objects with recursion - -2008-10-08 - Release Version: 0.2.b.3 - - * (Issue 43) Notice message in 0.2b2 - * Added support for PHP's native json_encode() if available - * Revised object encoder to detect object recursion - -2008-10-07 - Release Version: 0.2.b.2 - - * (Issue 28) Need solution for logging private and protected object variables - * Added trace() and table() aliases in FirePHP class - * (Issue 41) Use PHP doc in FirePHP - * (Issue 39) Static logging method for object oriented API - -2008-10-01 - Release Version: 0.2.b.1 - - * Added support for error and exception handling - * Updated min PHP version for PEAR package to 5.2 - * Added version constant for library - * Gave server library it's own wildfire plugin namespace - * Migrated communication protocol to Wildfire JsonStream - * Added support for console groups using "group" and "groupEnd" - * Added support for log, info, warn and error logging aliases - * (Issue 29) problem with TRACE when using with error_handler - * (Issue 33) PHP error notices running demos - * (Issue 12) undefined index php notice - * Removed closing ?> php tags - * (Issue 13) the code in the fb() function has a second return statement that will never be reached - -2008-07-30 - Release Version: 0.1.1.3 - - * Include __className property in JSON string if variable was an object - * Bugfix - Mis-spelt "Exception" in JSON encoding code - -2008-06-13 - Release Version: 0.1.1.1 - - * Bugfix - Standardize windows paths in stack traces - * Bugfix - Display correct stack trace info in windows environments - * Bugfix - Check $_SERVER['HTTP_USER_AGENT'] before returning - -2008-06-13 - Release Version: 0.1.1 - - * Added support for FirePHP::TRACE log style - * Changed license to New BSD License - -2008-06-06 - Release Version: 0.0.2 - - * Bugfix - Added usleep() to header writing loop to ensure unique index - * Bugfix - Ensure chunk_split does not generate trailing "\n" with empty data header - * Added support for FirePHP::TABLE log style diff --git a/vendor/firephp/firephp-core/README.md b/vendor/firephp/firephp-core/README.md deleted file mode 100644 index b1b32f842..000000000 --- a/vendor/firephp/firephp-core/README.md +++ /dev/null @@ -1,75 +0,0 @@ -FirePHPCore -=========== - -**Status: stable** - -> **FirePHP is an advanced logging system that can display PHP variables in the browser as an application is navigated.** -> All communication is out of band to the application meaning that the logging data will not interfere with the normal functioning of the application. - -This project contains the *FirePHPCore* PHP server library and provides a development environment (see `./workspace/`) for working on *FirePHPCore*. - - -Usage -===== - -See [Install/Traditional: FirePHPCore](http://docs.sourcemint.org/firephp.org/firephp/1/-docs/Configuration/Traditional) in the -[FirePHP 1.0 Documentation](http://docs.sourcemint.org/firephp.org/firephp/1/-docs/). - - -Testing -======= - - cd tests - phpunit . - - -Support & Feedback -================== - -See [Support](http://docs.sourcemint.org/firephp.org/firephp/1/-docs/OpenSource#support) in the [FirePHP 1.0 Documentation](http://docs.sourcemint.org/firephp.org/firephp/1/-docs/). - - -Contribute -========== - -See [Contribute](http://docs.sourcemint.org/firephp.org/firephp/1/-docs/OpenSource#contribute) in the [FirePHP 1.0 Documentation](http://docs.sourcemint.org/firephp.org/firephp/1/-docs/). - - -Author -====== - -This project is authored and maintained by [Christoph Dorn](http://www.christophdorn.com/). - - -Documentation License -===================== - -[Creative Commons Attribution-NonCommercial-ShareAlike 3.0](http://creativecommons.org/licenses/by-nc-sa/3.0/) - -Copyright (c) 2007+ [Christoph Dorn](http://www.christophdorn.com/) - - -Code License -============ - -[MIT License](http://www.opensource.org/licenses/mit-license.php) - -Copyright (c) 2007+ [Christoph Dorn](http://www.christophdorn.com/) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/vendor/firephp/firephp-core/composer.json b/vendor/firephp/firephp-core/composer.json deleted file mode 100644 index 7cab85a9f..000000000 --- a/vendor/firephp/firephp-core/composer.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "firephp/firephp-core", - "description": "Traditional FirePHPCore library for sending PHP variables to the browser.", - "type": "library", - "homepage": "https://github.com/firephp/firephp-core", - "license": "MIT", - "authors": [ - { - "name": "Christoph Dorn", - "email": "christoph@christophdorn.com", - "homepage": "http://christophdorn.com" - } - ], - "support": { - "forum": "http://groups.google.com/group/firephp-dev", - "issues": "https://github.com/firephp/firephp-core/issues", - "source": "https://github.com/firephp/firephp-core" - }, - "autoload": { - "classmap": [ - "lib/FirePHPCore/FirePHP.class.php", - "lib/FirePHPCore/fb.php" - ] - } -} - diff --git a/vendor/firephp/firephp-core/examples/oo.php b/vendor/firephp/firephp-core/examples/oo.php deleted file mode 100644 index f5f39875c..000000000 --- a/vendor/firephp/firephp-core/examples/oo.php +++ /dev/null @@ -1,82 +0,0 @@ -, Copyright 2007, New BSD License -// - cadorn, Christoph Dorn , Copyright 2011, MIT License - -/* *** BEGIN LICENSE BLOCK ***** - * - * [MIT License](http://www.opensource.org/licenses/mit-license.php) - * - * Copyright (c) 2007+ [Christoph Dorn](http://www.christophdorn.com/) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * ***** END LICENSE BLOCK ***** */ - - -/* NOTE: You must have the FirePHPCore library in your include path */ - -set_include_path(dirname(dirname(__FILE__)).'/lib'.PATH_SEPARATOR.get_include_path()); - - -require('FirePHPCore/FirePHP.class.php'); - -/* NOTE: You must have Output Buffering enabled via - ob_start() or output_buffering ini directive. */ - - -$firephp = FirePHP::getInstance(true); - - -$firephp->fb('Hello World'); /* Defaults to FirePHP::LOG */ - -$firephp->fb('Log message' ,FirePHP::LOG); -$firephp->fb('Info message' ,FirePHP::INFO); -$firephp->fb('Warn message' ,FirePHP::WARN); -$firephp->fb('Error message',FirePHP::ERROR); - -$firephp->fb('Message with label','Label',FirePHP::LOG); - -$firephp->fb(array('key1'=>'val1', - 'key2'=>array(array('v1','v2'),'v3')), - 'TestArray',FirePHP::LOG); - -function test($Arg1) { - throw new Exception('Test Exception'); -} -try { - test(array('Hello'=>'World')); -} catch(Exception $e) { - /* Log exception including stack trace & variables */ - $firephp->fb($e); -} - -$firephp->fb('Backtrace to here',FirePHP::TRACE); - -$firephp->fb(array('2 SQL queries took 0.06 seconds',array( - array('SQL Statement','Time','Result'), - array('SELECT * FROM Foo','0.02',array('row1','row2')), - array('SELECT * FROM Bar','0.04',array('row1','row2')) - )),FirePHP::TABLE); - -/* Will show only in "Server" tab for the request */ -$firephp->fb(apache_request_headers(),'RequestHeaders',FirePHP::DUMP); - - -print 'Hello World'; diff --git a/vendor/firephp/firephp-core/examples/oo.php4 b/vendor/firephp/firephp-core/examples/oo.php4 deleted file mode 100644 index 75ec1ee3f..000000000 --- a/vendor/firephp/firephp-core/examples/oo.php4 +++ /dev/null @@ -1,72 +0,0 @@ -, Copyright 2007, New BSD License -// - cadorn, Christoph Dorn , Copyright 2011, MIT License - -/* *** BEGIN LICENSE BLOCK ***** - * - * [MIT License](http://www.opensource.org/licenses/mit-license.php) - * - * Copyright (c) 2007+ [Christoph Dorn](http://www.christophdorn.com/) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * ***** END LICENSE BLOCK ***** */ - - -/* NOTE: You must have the FirePHPCore library in your include path */ - -set_include_path(dirname(dirname(__FILE__)).'/lib'.PATH_SEPARATOR.get_include_path()); - - -require('FirePHPCore/FirePHP.class.php4'); - -/* NOTE: You must have Output Buffering enabled via - ob_start() or output_buffering ini directive. */ - - -$firephp =& FirePHP::getInstance(true); - - -$firephp->fb('Hello World'); /* Defaults to FirePHP::LOG */ - -$firephp->fb('Log message' ,FirePHP_LOG); -$firephp->fb('Info message' ,FirePHP_INFO); -$firephp->fb('Warn message' ,FirePHP_WARN); -$firephp->fb('Error message',FirePHP_ERROR); - -$firephp->fb('Message with label','Label',FirePHP_LOG); - -$firephp->fb(array('key1'=>'val1', - 'key2'=>array(array('v1','v2'),'v3')), - 'TestArray',FirePHP_LOG); - -$firephp->fb('Backtrace to here',FirePHP_TRACE); - -$firephp->fb(array('2 SQL queries took 0.06 seconds',array( - array('SQL Statement','Time','Result'), - array('SELECT * FROM Foo','0.02',array('row1','row2')), - array('SELECT * FROM Bar','0.04',array('row1','row2')) - )),FirePHP_TABLE); - -/* Will show only in "Server" tab for the request */ -$firephp->fb(apache_request_headers(),'RequestHeaders',FirePHP_DUMP); - - -print 'Hello World'; diff --git a/vendor/firephp/firephp-core/examples/procedural.php b/vendor/firephp/firephp-core/examples/procedural.php deleted file mode 100644 index d1d3920bf..000000000 --- a/vendor/firephp/firephp-core/examples/procedural.php +++ /dev/null @@ -1,79 +0,0 @@ -, Copyright 2007, New BSD License -// - cadorn, Christoph Dorn , Copyright 2011, MIT License - -/* *** BEGIN LICENSE BLOCK ***** - * - * [MIT License](http://www.opensource.org/licenses/mit-license.php) - * - * Copyright (c) 2007+ [Christoph Dorn](http://www.christophdorn.com/) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * ***** END LICENSE BLOCK ***** */ - - -/* NOTE: You must have the FirePHPCore library in your include path */ - -set_include_path(dirname(dirname(__FILE__)).'/lib'.PATH_SEPARATOR.get_include_path()); - - -require('FirePHPCore/fb.php'); - -/* NOTE: You must have Output Buffering enabled via - ob_start() or output_buffering ini directive. */ - -fb('Hello World'); /* Defaults to FirePHP::LOG */ - -fb('Log message' ,FirePHP::LOG); -fb('Info message' ,FirePHP::INFO); -fb('Warn message' ,FirePHP::WARN); -fb('Error message',FirePHP::ERROR); - -fb('Message with label','Label',FirePHP::LOG); - -fb(array('key1'=>'val1', - 'key2'=>array(array('v1','v2'),'v3')), - 'TestArray',FirePHP::LOG); - -function test($Arg1) { - throw new Exception('Test Exception'); -} -try { - test(array('Hello'=>'World')); -} catch(Exception $e) { - /* Log exception including stack trace & variables */ - fb($e); -} - -fb('Backtrace to here',FirePHP::TRACE); - -fb(array('2 SQL queries took 0.06 seconds',array( - array('SQL Statement','Time','Result'), - array('SELECT * FROM Foo','0.02',array('row1','row2')), - array('SELECT * FROM Bar','0.04',array('row1','row2')) - )),FirePHP::TABLE); - -/* Will show only in "Server" tab for the request */ -fb(apache_request_headers(),'RequestHeaders',FirePHP::DUMP); - - -print 'Hello World'; - diff --git a/vendor/firephp/firephp-core/examples/procedural.php4 b/vendor/firephp/firephp-core/examples/procedural.php4 deleted file mode 100644 index 28eb7dc17..000000000 --- a/vendor/firephp/firephp-core/examples/procedural.php4 +++ /dev/null @@ -1,69 +0,0 @@ -, Copyright 2007, New BSD License -// - cadorn, Christoph Dorn , Copyright 2011, MIT License - -/* *** BEGIN LICENSE BLOCK ***** - * - * [MIT License](http://www.opensource.org/licenses/mit-license.php) - * - * Copyright (c) 2007+ [Christoph Dorn](http://www.christophdorn.com/) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * ***** END LICENSE BLOCK ***** */ - - -/* NOTE: You must have the FirePHPCore library in your include path */ - -set_include_path(dirname(dirname(__FILE__)).'/lib'.PATH_SEPARATOR.get_include_path()); - - -require('FirePHPCore/fb.php'); - -/* NOTE: You must have Output Buffering enabled via - ob_start() or output_buffering ini directive. */ - -fb('Hello World'); /* Defaults to FirePHP::LOG */ - -fb('Log message' ,FirePHP_LOG); -fb('Info message' ,FirePHP_INFO); -fb('Warn message' ,FirePHP_WARN); -fb('Error message',FirePHP_ERROR); - -fb('Message with label','Label',FirePHP_LOG); - -fb(array('key1'=>'val1', - 'key2'=>array(array('v1','v2'),'v3')), - 'TestArray',FirePHP_LOG); - -fb('Backtrace to here',FirePHP_TRACE); - -fb(array('2 SQL queries took 0.06 seconds',array( - array('SQL Statement','Time','Result'), - array('SELECT * FROM Foo','0.02',array('row1','row2')), - array('SELECT * FROM Bar','0.04',array('row1','row2')) - )),FirePHP_TABLE); - -/* Will show only in "Server" tab for the request */ -fb(apache_request_headers(),'RequestHeaders',FirePHP_DUMP); - - -print 'Hello World'; - diff --git a/vendor/firephp/firephp-core/lib/FirePHPCore/FirePHP.class.php b/vendor/firephp/firephp-core/lib/FirePHPCore/FirePHP.class.php deleted file mode 100644 index 65d83b56d..000000000 --- a/vendor/firephp/firephp-core/lib/FirePHPCore/FirePHP.class.php +++ /dev/null @@ -1,1828 +0,0 @@ -, Copyright 2007, New BSD License -// - qbbr, Sokolov Innokenty , Copyright 2011, New BSD License -// - cadorn, Christoph Dorn , Copyright 2011, MIT License - -/** - * *** BEGIN LICENSE BLOCK ***** - * - * [MIT License](http://www.opensource.org/licenses/mit-license.php) - * - * Copyright (c) 2007+ [Christoph Dorn](http://www.christophdorn.com/) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * ***** END LICENSE BLOCK ***** - * - * @copyright Copyright (C) 2007+ Christoph Dorn - * @author Christoph Dorn - * @license [MIT License](http://www.opensource.org/licenses/mit-license.php) - * @package FirePHPCore - */ - -/** - * @see http://code.google.com/p/firephp/issues/detail?id=112 - */ -if (!defined('E_STRICT')) { - define('E_STRICT', 2048); -} -if (!defined('E_RECOVERABLE_ERROR')) { - define('E_RECOVERABLE_ERROR', 4096); -} -if (!defined('E_DEPRECATED')) { - define('E_DEPRECATED', 8192); -} -if (!defined('E_USER_DEPRECATED')) { - define('E_USER_DEPRECATED', 16384); -} - -/** - * Sends the given data to the FirePHP Firefox Extension. - * The data can be displayed in the Firebug Console or in the - * "Server" request tab. - * - * For more information see: http://www.firephp.org/ - * - * @copyright Copyright (C) 2007+ Christoph Dorn - * @author Christoph Dorn - * @license [MIT License](http://www.opensource.org/licenses/mit-license.php) - * @package FirePHPCore - */ -class FirePHP { - - /** - * FirePHP version - * - * @var string - */ - const VERSION = '0.3'; // @pinf replace '0.3' with '%%VERSION%%' - - /** - * Firebug LOG level - * - * Logs a message to firebug console. - * - * @var string - */ - const LOG = 'LOG'; - - /** - * Firebug INFO level - * - * Logs a message to firebug console and displays an info icon before the message. - * - * @var string - */ - const INFO = 'INFO'; - - /** - * Firebug WARN level - * - * Logs a message to firebug console, displays an warning icon before the message and colors the line turquoise. - * - * @var string - */ - const WARN = 'WARN'; - - /** - * Firebug ERROR level - * - * Logs a message to firebug console, displays an error icon before the message and colors the line yellow. Also increments the firebug error count. - * - * @var string - */ - const ERROR = 'ERROR'; - - /** - * Dumps a variable to firebug's server panel - * - * @var string - */ - const DUMP = 'DUMP'; - - /** - * Displays a stack trace in firebug console - * - * @var string - */ - const TRACE = 'TRACE'; - - /** - * Displays an exception in firebug console - * - * Increments the firebug error count. - * - * @var string - */ - const EXCEPTION = 'EXCEPTION'; - - /** - * Displays an table in firebug console - * - * @var string - */ - const TABLE = 'TABLE'; - - /** - * Starts a group in firebug console - * - * @var string - */ - const GROUP_START = 'GROUP_START'; - - /** - * Ends a group in firebug console - * - * @var string - */ - const GROUP_END = 'GROUP_END'; - - /** - * Singleton instance of FirePHP - * - * @var FirePHP - */ - protected static $instance = null; - - /** - * Flag whether we are logging from within the exception handler - * - * @var boolean - */ - protected $inExceptionHandler = false; - - /** - * Flag whether to throw PHP errors that have been converted to ErrorExceptions - * - * @var boolean - */ - protected $throwErrorExceptions = true; - - /** - * Flag whether to convert PHP assertion errors to Exceptions - * - * @var boolean - */ - protected $convertAssertionErrorsToExceptions = true; - - /** - * Flag whether to throw PHP assertion errors that have been converted to Exceptions - * - * @var boolean - */ - protected $throwAssertionExceptions = false; - - /** - * Wildfire protocol message index - * - * @var integer - */ - protected $messageIndex = 1; - - /** - * Options for the library - * - * @var array - */ - protected $options = array('maxDepth' => 10, - 'maxObjectDepth' => 5, - 'maxArrayDepth' => 5, - 'useNativeJsonEncode' => true, - 'includeLineNumbers' => true); - - /** - * Filters used to exclude object members when encoding - * - * @var array - */ - protected $objectFilters = array( - 'firephp' => array('objectStack', 'instance', 'json_objectStack'), - 'firephp_test_class' => array('objectStack', 'instance', 'json_objectStack') - ); - - /** - * A stack of objects used to detect recursion during object encoding - * - * @var object - */ - protected $objectStack = array(); - - /** - * Flag to enable/disable logging - * - * @var boolean - */ - protected $enabled = true; - - /** - * The insight console to log to if applicable - * - * @var object - */ - protected $logToInsightConsole = null; - - /** - * When the object gets serialized only include specific object members. - * - * @return array - */ - public function __sleep() - { - return array('options', 'objectFilters', 'enabled'); - } - - /** - * Gets singleton instance of FirePHP - * - * @param boolean $autoCreate - * @return FirePHP - */ - public static function getInstance($autoCreate = false) - { - if ($autoCreate === true && !self::$instance) { - self::init(); - } - return self::$instance; - } - - /** - * Creates FirePHP object and stores it for singleton access - * - * @return FirePHP - */ - public static function init() - { - return self::setInstance(new self()); - } - - /** - * Set the instance of the FirePHP singleton - * - * @param FirePHP $instance The FirePHP object instance - * @return FirePHP - */ - public static function setInstance($instance) - { - return self::$instance = $instance; - } - - /** - * Set an Insight console to direct all logging calls to - * - * @param object $console The console object to log to - * @return void - */ - public function setLogToInsightConsole($console) - { - if (is_string($console)) { - if (get_class($this) != 'FirePHP_Insight' && !is_subclass_of($this, 'FirePHP_Insight')) { - throw new Exception('FirePHP instance not an instance or subclass of FirePHP_Insight!'); - } - $this->logToInsightConsole = $this->to('request')->console($console); - } else { - $this->logToInsightConsole = $console; - } - } - - /** - * Enable and disable logging to Firebug - * - * @param boolean $enabled TRUE to enable, FALSE to disable - * @return void - */ - public function setEnabled($enabled) - { - $this->enabled = $enabled; - } - - /** - * Check if logging is enabled - * - * @return boolean TRUE if enabled - */ - public function getEnabled() - { - return $this->enabled; - } - - /** - * Specify a filter to be used when encoding an object - * - * Filters are used to exclude object members. - * - * @param string $class The class name of the object - * @param array $filter An array of members to exclude - * @return void - */ - public function setObjectFilter($class, $filter) - { - $this->objectFilters[strtolower($class)] = $filter; - } - - /** - * Set some options for the library - * - * Options: - * - maxDepth: The maximum depth to traverse (default: 10) - * - maxObjectDepth: The maximum depth to traverse objects (default: 5) - * - maxArrayDepth: The maximum depth to traverse arrays (default: 5) - * - useNativeJsonEncode: If true will use json_encode() (default: true) - * - includeLineNumbers: If true will include line numbers and filenames (default: true) - * - * @param array $options The options to be set - * @return void - */ - public function setOptions($options) - { - $this->options = array_merge($this->options, $options); - } - - /** - * Get options from the library - * - * @return array The currently set options - */ - public function getOptions() - { - return $this->options; - } - - /** - * Set an option for the library - * - * @param string $name - * @param mixed $value - * @return void - * @throws Exception - */ - public function setOption($name, $value) - { - if (!isset($this->options[$name])) { - throw $this->newException('Unknown option: ' . $name); - } - $this->options[$name] = $value; - } - - /** - * Get an option from the library - * - * @param string $name - * @return mixed - * @throws Exception - */ - public function getOption($name) - { - if (!isset($this->options[$name])) { - throw $this->newException('Unknown option: ' . $name); - } - return $this->options[$name]; - } - - /** - * Register FirePHP as your error handler - * - * Will throw exceptions for each php error. - * - * @return mixed Returns a string containing the previously defined error handler (if any) - */ - public function registerErrorHandler($throwErrorExceptions = false) - { - //NOTE: The following errors will not be caught by this error handler: - // E_ERROR, E_PARSE, E_CORE_ERROR, - // E_CORE_WARNING, E_COMPILE_ERROR, - // E_COMPILE_WARNING, E_STRICT - - $this->throwErrorExceptions = $throwErrorExceptions; - - return set_error_handler(array($this, 'errorHandler')); - } - - /** - * FirePHP's error handler - * - * Throws exception for each php error that will occur. - * - * @param integer $errno - * @param string $errstr - * @param string $errfile - * @param integer $errline - * @param array $errcontext - */ - public function errorHandler($errno, $errstr, $errfile, $errline, $errcontext) - { - // Don't throw exception if error reporting is switched off - if (error_reporting() == 0) { - return; - } - // Only throw exceptions for errors we are asking for - if (error_reporting() & $errno) { - - $exception = new ErrorException($errstr, 0, $errno, $errfile, $errline); - if ($this->throwErrorExceptions) { - throw $exception; - } else { - $this->fb($exception); - } - } - } - - /** - * Register FirePHP as your exception handler - * - * @return mixed Returns the name of the previously defined exception handler, - * or NULL on error. - * If no previous handler was defined, NULL is also returned. - */ - public function registerExceptionHandler() - { - return set_exception_handler(array($this, 'exceptionHandler')); - } - - /** - * FirePHP's exception handler - * - * Logs all exceptions to your firebug console and then stops the script. - * - * @param Exception $exception - * @throws Exception - */ - function exceptionHandler($exception) - { - $this->inExceptionHandler = true; - - header('HTTP/1.1 500 Internal Server Error'); - - try { - $this->fb($exception); - } catch (Exception $e) { - echo 'We had an exception: ' . $e; - } - - $this->inExceptionHandler = false; - } - - /** - * Register FirePHP driver as your assert callback - * - * @param boolean $convertAssertionErrorsToExceptions - * @param boolean $throwAssertionExceptions - * @return mixed Returns the original setting or FALSE on errors - */ - public function registerAssertionHandler($convertAssertionErrorsToExceptions = true, $throwAssertionExceptions = false) - { - $this->convertAssertionErrorsToExceptions = $convertAssertionErrorsToExceptions; - $this->throwAssertionExceptions = $throwAssertionExceptions; - - if ($throwAssertionExceptions && !$convertAssertionErrorsToExceptions) { - throw $this->newException('Cannot throw assertion exceptions as assertion errors are not being converted to exceptions!'); - } - - return assert_options(ASSERT_CALLBACK, array($this, 'assertionHandler')); - } - - /** - * FirePHP's assertion handler - * - * Logs all assertions to your firebug console and then stops the script. - * - * @param string $file File source of assertion - * @param integer $line Line source of assertion - * @param mixed $code Assertion code - */ - public function assertionHandler($file, $line, $code) - { - if ($this->convertAssertionErrorsToExceptions) { - - $exception = new ErrorException('Assertion Failed - Code[ ' . $code . ' ]', 0, null, $file, $line); - - if ($this->throwAssertionExceptions) { - throw $exception; - } else { - $this->fb($exception); - } - - } else { - $this->fb($code, 'Assertion Failed', FirePHP::ERROR, array('File' => $file, 'Line' => $line)); - } - } - - /** - * Start a group for following messages. - * - * Options: - * Collapsed: [true|false] - * Color: [#RRGGBB|ColorName] - * - * @param string $name - * @param array $options OPTIONAL Instructions on how to log the group - * @return true - * @throws Exception - */ - public function group($name, $options = null) - { - - if (!$name) { - throw $this->newException('You must specify a label for the group!'); - } - - if ($options) { - if (!is_array($options)) { - throw $this->newException('Options must be defined as an array!'); - } - if (array_key_exists('Collapsed', $options)) { - $options['Collapsed'] = ($options['Collapsed']) ? 'true' : 'false'; - } - } - - return $this->fb(null, $name, FirePHP::GROUP_START, $options); - } - - /** - * Ends a group you have started before - * - * @return true - * @throws Exception - */ - public function groupEnd() - { - return $this->fb(null, null, FirePHP::GROUP_END); - } - - /** - * Log object with label to firebug console - * - * @see FirePHP::LOG - * @param mixes $object - * @param string $label - * @return true - * @throws Exception - */ - public function log($object, $label = null, $options = array()) - { - return $this->fb($object, $label, FirePHP::LOG, $options); - } - - /** - * Log object with label to firebug console - * - * @see FirePHP::INFO - * @param mixes $object - * @param string $label - * @return true - * @throws Exception - */ - public function info($object, $label = null, $options = array()) - { - return $this->fb($object, $label, FirePHP::INFO, $options); - } - - /** - * Log object with label to firebug console - * - * @see FirePHP::WARN - * @param mixes $object - * @param string $label - * @return true - * @throws Exception - */ - public function warn($object, $label = null, $options = array()) - { - return $this->fb($object, $label, FirePHP::WARN, $options); - } - - /** - * Log object with label to firebug console - * - * @see FirePHP::ERROR - * @param mixes $object - * @param string $label - * @return true - * @throws Exception - */ - public function error($object, $label = null, $options = array()) - { - return $this->fb($object, $label, FirePHP::ERROR, $options); - } - - /** - * Dumps key and variable to firebug server panel - * - * @see FirePHP::DUMP - * @param string $key - * @param mixed $variable - * @return true - * @throws Exception - */ - public function dump($key, $variable, $options = array()) - { - if (!is_string($key)) { - throw $this->newException('Key passed to dump() is not a string'); - } - if (strlen($key) > 100) { - throw $this->newException('Key passed to dump() is longer than 100 characters'); - } - if (!preg_match_all('/^[a-zA-Z0-9-_\.:]*$/', $key, $m)) { - throw $this->newException('Key passed to dump() contains invalid characters [a-zA-Z0-9-_\.:]'); - } - return $this->fb($variable, $key, FirePHP::DUMP, $options); - } - - /** - * Log a trace in the firebug console - * - * @see FirePHP::TRACE - * @param string $label - * @return true - * @throws Exception - */ - public function trace($label) - { - return $this->fb($label, FirePHP::TRACE); - } - - /** - * Log a table in the firebug console - * - * @see FirePHP::TABLE - * @param string $label - * @param string $table - * @return true - * @throws Exception - */ - public function table($label, $table, $options = array()) - { - return $this->fb($table, $label, FirePHP::TABLE, $options); - } - - /** - * Insight API wrapper - * - * @see Insight_Helper::to() - */ - public static function to() - { - $instance = self::getInstance(); - if (!method_exists($instance, '_to')) { - throw new Exception('FirePHP::to() implementation not loaded'); - } - $args = func_get_args(); - return call_user_func_array(array($instance, '_to'), $args); - } - - /** - * Insight API wrapper - * - * @see Insight_Helper::plugin() - */ - public static function plugin() - { - $instance = self::getInstance(); - if (!method_exists($instance, '_plugin')) { - throw new Exception('FirePHP::plugin() implementation not loaded'); - } - $args = func_get_args(); - return call_user_func_array(array($instance, '_plugin'), $args); - } - - /** - * Check if FirePHP is installed on client - * - * @return boolean - */ - public function detectClientExtension() - { - // Check if FirePHP is installed on client via User-Agent header - if (@preg_match_all('/\sFirePHP\/([\.\d]*)\s?/si', $this->getUserAgent(), $m) && - version_compare($m[1][0], '0.0.6', '>=')) { - return true; - } else - // Check if FirePHP is installed on client via X-FirePHP-Version header - if (@preg_match_all('/^([\.\d]*)$/si', $this->getRequestHeader('X-FirePHP-Version'), $m) && - version_compare($m[1][0], '0.0.6', '>=')) { - return true; - } - return false; - } - - /** - * Log varible to Firebug - * - * @see http://www.firephp.org/Wiki/Reference/Fb - * @param mixed $object The variable to be logged - * @return boolean Return TRUE if message was added to headers, FALSE otherwise - * @throws Exception - */ - public function fb($object) - { - if ($this instanceof FirePHP_Insight && method_exists($this, '_logUpgradeClientMessage')) { - if (!FirePHP_Insight::$upgradeClientMessageLogged) { // avoid infinite recursion as _logUpgradeClientMessage() logs a message - $this->_logUpgradeClientMessage(); - } - } - - static $insightGroupStack = array(); - - if (!$this->getEnabled()) { - return false; - } - - if ($this->headersSent($filename, $linenum)) { - // If we are logging from within the exception handler we cannot throw another exception - if ($this->inExceptionHandler) { - // Simply echo the error out to the page - echo '
FirePHP ERROR: Headers already sent in ' . $filename . ' on line ' . $linenum . '. Cannot send log data to FirePHP. You must have Output Buffering enabled via ob_start() or output_buffering ini directive.
'; - } else { - throw $this->newException('Headers already sent in ' . $filename . ' on line ' . $linenum . '. Cannot send log data to FirePHP. You must have Output Buffering enabled via ob_start() or output_buffering ini directive.'); - } - } - - $type = null; - $label = null; - $options = array(); - - if (func_num_args() == 1) { - } else if (func_num_args() == 2) { - switch (func_get_arg(1)) { - case self::LOG: - case self::INFO: - case self::WARN: - case self::ERROR: - case self::DUMP: - case self::TRACE: - case self::EXCEPTION: - case self::TABLE: - case self::GROUP_START: - case self::GROUP_END: - $type = func_get_arg(1); - break; - default: - $label = func_get_arg(1); - break; - } - } else if (func_num_args() == 3) { - $type = func_get_arg(2); - $label = func_get_arg(1); - } else if (func_num_args() == 4) { - $type = func_get_arg(2); - $label = func_get_arg(1); - $options = func_get_arg(3); - } else { - throw $this->newException('Wrong number of arguments to fb() function!'); - } - - if ($this->logToInsightConsole !== null && (get_class($this) == 'FirePHP_Insight' || is_subclass_of($this, 'FirePHP_Insight'))) { - $trace = debug_backtrace(); - if (!$trace) return false; - for ($i = 0; $i < sizeof($trace); $i++) { - if (isset($trace[$i]['class'])) { - if ($trace[$i]['class'] == 'FirePHP' || $trace[$i]['class'] == 'FB') { - continue; - } - } - if (isset($trace[$i]['file'])) { - $path = $this->_standardizePath($trace[$i]['file']); - if (substr($path, -18, 18) == 'FirePHPCore/fb.php' || substr($path, -29, 29) == 'FirePHPCore/FirePHP.class.php') { - continue; - } - } - if (isset($trace[$i]['function']) && $trace[$i]['function'] == 'fb' && - isset($trace[$i - 1]['file']) && substr($this->_standardizePath($trace[$i - 1]['file']), -18, 18) == 'FirePHPCore/fb.php') { - continue; - } - if (isset($trace[$i]['class']) && $trace[$i]['class'] == 'FB' && - isset($trace[$i - 1]['file']) && substr($this->_standardizePath($trace[$i - 1]['file']), -18, 18) == 'FirePHPCore/fb.php') { - continue; - } - break; - } - // adjust trace offset - $msg = $this->logToInsightConsole->option('encoder.trace.offsetAdjustment', $i); - - if ($object instanceof Exception) { - $type = self::EXCEPTION; - } - if ($label && $type != self::TABLE && $type != self::GROUP_START) { - $msg = $msg->label($label); - } - switch ($type) { - case self::DUMP: - case self::LOG: - return $msg->log($object); - case self::INFO: - return $msg->info($object); - case self::WARN: - return $msg->warn($object); - case self::ERROR: - return $msg->error($object); - case self::TRACE: - return $msg->trace($object); - case self::EXCEPTION: - return $this->plugin('error')->handleException($object, $msg); - case self::TABLE: - if (isset($object[0]) && !is_string($object[0]) && $label) { - $object = array($label, $object); - } - return $msg->table($object[0], array_slice($object[1], 1), $object[1][0]); - case self::GROUP_START: - $insightGroupStack[] = $msg->group(md5($label))->open(); - return $msg->log($label); - case self::GROUP_END: - if (count($insightGroupStack) == 0) { - throw new Error('Too many groupEnd() as opposed to group() calls!'); - } - $group = array_pop($insightGroupStack); - return $group->close(); - default: - return $msg->log($object); - } - } - - if (!$this->detectClientExtension()) { - return false; - } - - $meta = array(); - $skipFinalObjectEncode = false; - - if ($object instanceof Exception) { - - $meta['file'] = $this->_escapeTraceFile($object->getFile()); - $meta['line'] = $object->getLine(); - - $trace = $object->getTrace(); - if ($object instanceof ErrorException - && isset($trace[0]['function']) - && $trace[0]['function'] == 'errorHandler' - && isset($trace[0]['class']) - && $trace[0]['class'] == 'FirePHP') { - - $severity = false; - switch ($object->getSeverity()) { - case E_WARNING: - $severity = 'E_WARNING'; - break; - - case E_NOTICE: - $severity = 'E_NOTICE'; - break; - - case E_USER_ERROR: - $severity = 'E_USER_ERROR'; - break; - - case E_USER_WARNING: - $severity = 'E_USER_WARNING'; - break; - - case E_USER_NOTICE: - $severity = 'E_USER_NOTICE'; - break; - - case E_STRICT: - $severity = 'E_STRICT'; - break; - - case E_RECOVERABLE_ERROR: - $severity = 'E_RECOVERABLE_ERROR'; - break; - - case E_DEPRECATED: - $severity = 'E_DEPRECATED'; - break; - - case E_USER_DEPRECATED: - $severity = 'E_USER_DEPRECATED'; - break; - } - - $object = array('Class' => get_class($object), - 'Message' => $severity . ': ' . $object->getMessage(), - 'File' => $this->_escapeTraceFile($object->getFile()), - 'Line' => $object->getLine(), - 'Type' => 'trigger', - 'Trace' => $this->_escapeTrace(array_splice($trace, 2))); - $skipFinalObjectEncode = true; - } else { - $object = array('Class' => get_class($object), - 'Message' => $object->getMessage(), - 'File' => $this->_escapeTraceFile($object->getFile()), - 'Line' => $object->getLine(), - 'Type' => 'throw', - 'Trace' => $this->_escapeTrace($trace)); - $skipFinalObjectEncode = true; - } - $type = self::EXCEPTION; - - } else if ($type == self::TRACE) { - - $trace = debug_backtrace(); - if (!$trace) return false; - for ($i = 0; $i < sizeof($trace); $i++) { - - if (isset($trace[$i]['class']) - && isset($trace[$i]['file']) - && ($trace[$i]['class'] == 'FirePHP' - || $trace[$i]['class'] == 'FB') - && (substr($this->_standardizePath($trace[$i]['file']), -18, 18) == 'FirePHPCore/fb.php' - || substr($this->_standardizePath($trace[$i]['file']), -29, 29) == 'FirePHPCore/FirePHP.class.php')) { - /* Skip - FB::trace(), FB::send(), $firephp->trace(), $firephp->fb() */ - } else - if (isset($trace[$i]['class']) - && isset($trace[$i+1]['file']) - && $trace[$i]['class'] == 'FirePHP' - && substr($this->_standardizePath($trace[$i + 1]['file']), -18, 18) == 'FirePHPCore/fb.php') { - /* Skip fb() */ - } else - if ($trace[$i]['function'] == 'fb' - || $trace[$i]['function'] == 'trace' - || $trace[$i]['function'] == 'send') { - - $object = array('Class' => isset($trace[$i]['class']) ? $trace[$i]['class'] : '', - 'Type' => isset($trace[$i]['type']) ? $trace[$i]['type'] : '', - 'Function' => isset($trace[$i]['function']) ? $trace[$i]['function'] : '', - 'Message' => $trace[$i]['args'][0], - 'File' => isset($trace[$i]['file']) ? $this->_escapeTraceFile($trace[$i]['file']) : '', - 'Line' => isset($trace[$i]['line']) ? $trace[$i]['line'] : '', - 'Args' => isset($trace[$i]['args']) ? $this->encodeObject($trace[$i]['args']) : '', - 'Trace' => $this->_escapeTrace(array_splice($trace, $i + 1))); - - $skipFinalObjectEncode = true; - $meta['file'] = isset($trace[$i]['file']) ? $this->_escapeTraceFile($trace[$i]['file']) : ''; - $meta['line'] = isset($trace[$i]['line']) ? $trace[$i]['line'] : ''; - break; - } - } - - } else - if ($type == self::TABLE) { - - if (isset($object[0]) && is_string($object[0])) { - $object[1] = $this->encodeTable($object[1]); - } else { - $object = $this->encodeTable($object); - } - - $skipFinalObjectEncode = true; - - } else if ($type == self::GROUP_START) { - - if (!$label) { - throw $this->newException('You must specify a label for the group!'); - } - - } else { - if ($type === null) { - $type = self::LOG; - } - } - - if ($this->options['includeLineNumbers']) { - if (!isset($meta['file']) || !isset($meta['line'])) { - - $trace = debug_backtrace(); - for ($i = 0; $trace && $i < sizeof($trace); $i++) { - - if (isset($trace[$i]['class']) - && isset($trace[$i]['file']) - && ($trace[$i]['class'] == 'FirePHP' - || $trace[$i]['class'] == 'FB') - && (substr($this->_standardizePath($trace[$i]['file']), -18, 18) == 'FirePHPCore/fb.php' - || substr($this->_standardizePath($trace[$i]['file']), -29, 29) == 'FirePHPCore/FirePHP.class.php')) { - /* Skip - FB::trace(), FB::send(), $firephp->trace(), $firephp->fb() */ - } else - if (isset($trace[$i]['class']) - && isset($trace[$i + 1]['file']) - && $trace[$i]['class'] == 'FirePHP' - && substr($this->_standardizePath($trace[$i + 1]['file']), -18, 18) == 'FirePHPCore/fb.php') { - /* Skip fb() */ - } else - if (isset($trace[$i]['file']) - && substr($this->_standardizePath($trace[$i]['file']), -18, 18) == 'FirePHPCore/fb.php') { - /* Skip FB::fb() */ - } else { - $meta['file'] = isset($trace[$i]['file']) ? $this->_escapeTraceFile($trace[$i]['file']) : ''; - $meta['line'] = isset($trace[$i]['line']) ? $trace[$i]['line'] : ''; - break; - } - } - } - } else { - unset($meta['file']); - unset($meta['line']); - } - - $this->setHeader('X-Wf-Protocol-1', 'http://meta.wildfirehq.org/Protocol/JsonStream/0.2'); - $this->setHeader('X-Wf-1-Plugin-1', 'http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/' . self::VERSION); - - $structureIndex = 1; - if ($type == self::DUMP) { - $structureIndex = 2; - $this->setHeader('X-Wf-1-Structure-2', 'http://meta.firephp.org/Wildfire/Structure/FirePHP/Dump/0.1'); - } else { - $this->setHeader('X-Wf-1-Structure-1', 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1'); - } - - if ($type == self::DUMP) { - $msg = '{"' . $label . '":' . $this->jsonEncode($object, $skipFinalObjectEncode) . '}'; - } else { - $msgMeta = $options; - $msgMeta['Type'] = $type; - if ($label !== null) { - $msgMeta['Label'] = $label; - } - if (isset($meta['file']) && !isset($msgMeta['File'])) { - $msgMeta['File'] = $meta['file']; - } - if (isset($meta['line']) && !isset($msgMeta['Line'])) { - $msgMeta['Line'] = $meta['line']; - } - $msg = '[' . $this->jsonEncode($msgMeta) . ',' . $this->jsonEncode($object, $skipFinalObjectEncode) . ']'; - } - - $parts = explode("\n", chunk_split($msg, 5000, "\n")); - - for ($i = 0; $i < count($parts); $i++) { - - $part = $parts[$i]; - if ($part) { - - if (count($parts) > 2) { - // Message needs to be split into multiple parts - $this->setHeader('X-Wf-1-' . $structureIndex . '-' . '1-' . $this->messageIndex, - (($i == 0) ? strlen($msg) : '') - . '|' . $part . '|' - . (($i < count($parts) - 2) ? '\\' : '')); - } else { - $this->setHeader('X-Wf-1-' . $structureIndex . '-' . '1-' . $this->messageIndex, - strlen($part) . '|' . $part . '|'); - } - - $this->messageIndex++; - - if ($this->messageIndex > 99999) { - throw $this->newException('Maximum number (99,999) of messages reached!'); - } - } - } - - $this->setHeader('X-Wf-1-Index', $this->messageIndex - 1); - - return true; - } - - /** - * Standardizes path for windows systems. - * - * @param string $path - * @return string - */ - protected function _standardizePath($path) - { - return preg_replace('/\\\\+/', '/', $path); - } - - /** - * Escape trace path for windows systems - * - * @param array $trace - * @return array - */ - protected function _escapeTrace($trace) - { - if (!$trace) return $trace; - for ($i = 0; $i < sizeof($trace); $i++) { - if (isset($trace[$i]['file'])) { - $trace[$i]['file'] = $this->_escapeTraceFile($trace[$i]['file']); - } - if (isset($trace[$i]['args'])) { - $trace[$i]['args'] = $this->encodeObject($trace[$i]['args']); - } - } - return $trace; - } - - /** - * Escape file information of trace for windows systems - * - * @param string $file - * @return string - */ - protected function _escapeTraceFile($file) - { - /* Check if we have a windows filepath */ - if (strpos($file, '\\')) { - /* First strip down to single \ */ - - $file = preg_replace('/\\\\+/', '\\', $file); - - return $file; - } - return $file; - } - - /** - * Check if headers have already been sent - * - * @param string $filename - * @param integer $linenum - */ - protected function headersSent(&$filename, &$linenum) - { - return headers_sent($filename, $linenum); - } - - /** - * Send header - * - * @param string $name - * @param string $value - */ - protected function setHeader($name, $value) - { - return header($name . ': ' . $value); - } - - /** - * Get user agent - * - * @return string|false - */ - protected function getUserAgent() - { - if (!isset($_SERVER['HTTP_USER_AGENT'])) return false; - return $_SERVER['HTTP_USER_AGENT']; - } - - /** - * Get all request headers - * - * @return array - */ - public static function getAllRequestHeaders() - { - static $_cachedHeaders = false; - if ($_cachedHeaders !== false) { - return $_cachedHeaders; - } - $headers = array(); - if (function_exists('getallheaders')) { - foreach (getallheaders() as $name => $value) { - $headers[strtolower($name)] = $value; - } - } else { - foreach ($_SERVER as $name => $value) { - if (substr($name, 0, 5) == 'HTTP_') { - $headers[strtolower(str_replace(' ', '-', str_replace('_', ' ', substr($name, 5))))] = $value; - } - } - } - return $_cachedHeaders = $headers; - } - - /** - * Get a request header - * - * @return string|false - */ - protected function getRequestHeader($name) - { - $headers = self::getAllRequestHeaders(); - if (isset($headers[strtolower($name)])) { - return $headers[strtolower($name)]; - } - return false; - } - - /** - * Returns a new exception - * - * @param string $message - * @return Exception - */ - protected function newException($message) - { - return new Exception($message); - } - - /** - * Encode an object into a JSON string - * - * Uses PHP's jeson_encode() if available - * - * @param object $object The object to be encoded - * @param boolean $skipObjectEncode - * @return string The JSON string - */ - public function jsonEncode($object, $skipObjectEncode = false) - { - if (!$skipObjectEncode) { - $object = $this->encodeObject($object); - } - - if (function_exists('json_encode') - && $this->options['useNativeJsonEncode'] != false) { - - return json_encode($object); - } else { - return $this->json_encode($object); - } - } - - /** - * Encodes a table by encoding each row and column with encodeObject() - * - * @param array $table The table to be encoded - * @return array - */ - protected function encodeTable($table) - { - if (!$table) return $table; - - $newTable = array(); - foreach ($table as $row) { - - if (is_array($row)) { - $newRow = array(); - - foreach ($row as $item) { - $newRow[] = $this->encodeObject($item); - } - - $newTable[] = $newRow; - } - } - - return $newTable; - } - - /** - * Encodes an object including members with - * protected and private visibility - * - * @param object $object The object to be encoded - * @param integer $Depth The current traversal depth - * @return array All members of the object - */ - protected function encodeObject($object, $objectDepth = 1, $arrayDepth = 1, $maxDepth = 1) - { - if ($maxDepth > $this->options['maxDepth']) { - return '** Max Depth (' . $this->options['maxDepth'] . ') **'; - } - - $return = array(); - - if (is_resource($object)) { - - return '** ' . (string) $object . ' **'; - - } else if (is_object($object)) { - - if ($objectDepth > $this->options['maxObjectDepth']) { - return '** Max Object Depth (' . $this->options['maxObjectDepth'] . ') **'; - } - - foreach ($this->objectStack as $refVal) { - if ($refVal === $object) { - return '** Recursion (' . get_class($object) . ') **'; - } - } - array_push($this->objectStack, $object); - - $return['__className'] = $class = get_class($object); - $classLower = strtolower($class); - - $reflectionClass = new ReflectionClass($class); - $properties = array(); - foreach ($reflectionClass->getProperties() as $property) { - $properties[$property->getName()] = $property; - } - - $members = (array)$object; - - foreach ($properties as $plainName => $property) { - - $name = $rawName = $plainName; - if ($property->isStatic()) { - $name = 'static:' . $name; - } - if ($property->isPublic()) { - $name = 'public:' . $name; - } else if ($property->isPrivate()) { - $name = 'private:' . $name; - $rawName = "\0" . $class . "\0" . $rawName; - } else if ($property->isProtected()) { - $name = 'protected:' . $name; - $rawName = "\0" . '*' . "\0" . $rawName; - } - - if (!(isset($this->objectFilters[$classLower]) - && is_array($this->objectFilters[$classLower]) - && in_array($plainName, $this->objectFilters[$classLower]))) { - - if (array_key_exists($rawName, $members) && !$property->isStatic()) { - $return[$name] = $this->encodeObject($members[$rawName], $objectDepth + 1, 1, $maxDepth + 1); - } else { - if (method_exists($property, 'setAccessible')) { - $property->setAccessible(true); - $return[$name] = $this->encodeObject($property->getValue($object), $objectDepth + 1, 1, $maxDepth + 1); - } else - if ($property->isPublic()) { - $return[$name] = $this->encodeObject($property->getValue($object), $objectDepth + 1, 1, $maxDepth + 1); - } else { - $return[$name] = '** Need PHP 5.3 to get value **'; - } - } - } else { - $return[$name] = '** Excluded by Filter **'; - } - } - - // Include all members that are not defined in the class - // but exist in the object - foreach ($members as $rawName => $value) { - - $name = $rawName; - - if ($name{0} == "\0") { - $parts = explode("\0", $name); - $name = $parts[2]; - } - - $plainName = $name; - - if (!isset($properties[$name])) { - $name = 'undeclared:' . $name; - - if (!(isset($this->objectFilters[$classLower]) - && is_array($this->objectFilters[$classLower]) - && in_array($plainName, $this->objectFilters[$classLower]))) { - - $return[$name] = $this->encodeObject($value, $objectDepth + 1, 1, $maxDepth + 1); - } else { - $return[$name] = '** Excluded by Filter **'; - } - } - } - - array_pop($this->objectStack); - - } elseif (is_array($object)) { - - if ($arrayDepth > $this->options['maxArrayDepth']) { - return '** Max Array Depth (' . $this->options['maxArrayDepth'] . ') **'; - } - - foreach ($object as $key => $val) { - - // Encoding the $GLOBALS PHP array causes an infinite loop - // if the recursion is not reset here as it contains - // a reference to itself. This is the only way I have come up - // with to stop infinite recursion in this case. - if ($key == 'GLOBALS' - && is_array($val) - && array_key_exists('GLOBALS', $val)) { - $val['GLOBALS'] = '** Recursion (GLOBALS) **'; - } - - if (!$this->is_utf8($key)) { - $key = utf8_encode($key); - } - - $return[$key] = $this->encodeObject($val, 1, $arrayDepth + 1, $maxDepth + 1); - } - } else { - if ($this->is_utf8($object)) { - return $object; - } else { - return utf8_encode($object); - } - } - return $return; - } - - /** - * Returns true if $string is valid UTF-8 and false otherwise. - * - * @param mixed $str String to be tested - * @return boolean - */ - protected function is_utf8($str) - { - if (function_exists('mb_detect_encoding')) { - return ( - mb_detect_encoding($str, 'UTF-8', true) == 'UTF-8' && - ($str === null || $this->jsonEncode($str, true) !== 'null') - ); - } - $c = 0; - $b = 0; - $bits = 0; - $len = strlen($str); - for ($i = 0; $i < $len; $i++) { - $c = ord($str[$i]); - if ($c > 128) { - if (($c >= 254)) return false; - elseif ($c >= 252) $bits = 6; - elseif ($c >= 248) $bits = 5; - elseif ($c >= 240) $bits = 4; - elseif ($c >= 224) $bits = 3; - elseif ($c >= 192) $bits = 2; - else return false; - if (($i + $bits) > $len) return false; - while($bits > 1) { - $i++; - $b = ord($str[$i]); - if ($b < 128 || $b > 191) return false; - $bits--; - } - } - } - return ($str === null || $this->jsonEncode($str, true) !== 'null'); - } - - /** - * Converts to and from JSON format. - * - * JSON (JavaScript Object Notation) is a lightweight data-interchange - * format. It is easy for humans to read and write. It is easy for machines - * to parse and generate. It is based on a subset of the JavaScript - * Programming Language, Standard ECMA-262 3rd Edition - December 1999. - * This feature can also be found in Python. JSON is a text format that is - * completely language independent but uses conventions that are familiar - * to programmers of the C-family of languages, including C, C++, C#, Java, - * JavaScript, Perl, TCL, and many others. These properties make JSON an - * ideal data-interchange language. - * - * This package provides a simple encoder and decoder for JSON notation. It - * is intended for use with client-side Javascript applications that make - * use of HTTPRequest to perform server communication functions - data can - * be encoded into JSON notation for use in a client-side javascript, or - * decoded from incoming Javascript requests. JSON format is native to - * Javascript, and can be directly eval()'ed with no further parsing - * overhead - * - * All strings should be in ASCII or UTF-8 format! - * - * LICENSE: Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: Redistributions of source code must retain the - * above copyright notice, this list of conditions and the following - * disclaimer. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR - * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * @category - * @package Services_JSON - * @author Michal Migurski - * @author Matt Knapp - * @author Brett Stimmerman - * @author Christoph Dorn - * @copyright 2005 Michal Migurski - * @version CVS: $Id: JSON.php,v 1.31 2006/06/28 05:54:17 migurski Exp $ - * @license http://www.opensource.org/licenses/bsd-license.php - * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198 - */ - - - /** - * Keep a list of objects as we descend into the array so we can detect recursion. - */ - private $json_objectStack = array(); - - - /** - * convert a string from one UTF-8 char to one UTF-16 char - * - * Normally should be handled by mb_convert_encoding, but - * provides a slower PHP-only method for installations - * that lack the multibye string extension. - * - * @param string $utf8 UTF-8 character - * @return string UTF-16 character - * @access private - */ - private function json_utf82utf16($utf8) - { - // oh please oh please oh please oh please oh please - if (function_exists('mb_convert_encoding')) { - return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8'); - } - - switch (strlen($utf8)) { - case 1: - // this case should never be reached, because we are in ASCII range - // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - return $utf8; - - case 2: - // return a UTF-16 character from a 2-byte UTF-8 char - // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - return chr(0x07 & (ord($utf8{0}) >> 2)) - . chr((0xC0 & (ord($utf8{0}) << 6)) - | (0x3F & ord($utf8{1}))); - - case 3: - // return a UTF-16 character from a 3-byte UTF-8 char - // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - return chr((0xF0 & (ord($utf8{0}) << 4)) - | (0x0F & (ord($utf8{1}) >> 2))) - . chr((0xC0 & (ord($utf8{1}) << 6)) - | (0x7F & ord($utf8{2}))); - } - - // ignoring UTF-32 for now, sorry - return ''; - } - - /** - * encodes an arbitrary variable into JSON format - * - * @param mixed $var any number, boolean, string, array, or object to be encoded. - * see argument 1 to Services_JSON() above for array-parsing behavior. - * if var is a strng, note that encode() always expects it - * to be in ASCII or UTF-8 format! - * - * @return mixed JSON string representation of input var or an error if a problem occurs - * @access public - */ - private function json_encode($var) - { - if (is_object($var)) { - if (in_array($var, $this->json_objectStack)) { - return '"** Recursion **"'; - } - } - - switch (gettype($var)) { - case 'boolean': - return $var ? 'true' : 'false'; - - case 'NULL': - return 'null'; - - case 'integer': - return (int) $var; - - case 'double': - case 'float': - return (float) $var; - - case 'string': - // STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT - $ascii = ''; - $strlen_var = strlen($var); - - /* - * Iterate over every character in the string, - * escaping with a slash or encoding to UTF-8 where necessary - */ - for ($c = 0; $c < $strlen_var; ++$c) { - - $ord_var_c = ord($var{$c}); - - switch (true) { - case $ord_var_c == 0x08: - $ascii .= '\b'; - break; - case $ord_var_c == 0x09: - $ascii .= '\t'; - break; - case $ord_var_c == 0x0A: - $ascii .= '\n'; - break; - case $ord_var_c == 0x0C: - $ascii .= '\f'; - break; - case $ord_var_c == 0x0D: - $ascii .= '\r'; - break; - - case $ord_var_c == 0x22: - case $ord_var_c == 0x2F: - case $ord_var_c == 0x5C: - // double quote, slash, slosh - $ascii .= '\\' . $var{$c}; - break; - - case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)): - // characters U-00000000 - U-0000007F (same as ASCII) - $ascii .= $var{$c}; - break; - - case (($ord_var_c & 0xE0) == 0xC0): - // characters U-00000080 - U-000007FF, mask 110XXXXX - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $char = pack('C*', $ord_var_c, ord($var{$c + 1})); - $c += 1; - $utf16 = $this->json_utf82utf16($char); - $ascii .= sprintf('\u%04s', bin2hex($utf16)); - break; - - case (($ord_var_c & 0xF0) == 0xE0): - // characters U-00000800 - U-0000FFFF, mask 1110XXXX - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $char = pack('C*', $ord_var_c, - ord($var{$c + 1}), - ord($var{$c + 2})); - $c += 2; - $utf16 = $this->json_utf82utf16($char); - $ascii .= sprintf('\u%04s', bin2hex($utf16)); - break; - - case (($ord_var_c & 0xF8) == 0xF0): - // characters U-00010000 - U-001FFFFF, mask 11110XXX - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $char = pack('C*', $ord_var_c, - ord($var{$c + 1}), - ord($var{$c + 2}), - ord($var{$c + 3})); - $c += 3; - $utf16 = $this->json_utf82utf16($char); - $ascii .= sprintf('\u%04s', bin2hex($utf16)); - break; - - case (($ord_var_c & 0xFC) == 0xF8): - // characters U-00200000 - U-03FFFFFF, mask 111110XX - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $char = pack('C*', $ord_var_c, - ord($var{$c + 1}), - ord($var{$c + 2}), - ord($var{$c + 3}), - ord($var{$c + 4})); - $c += 4; - $utf16 = $this->json_utf82utf16($char); - $ascii .= sprintf('\u%04s', bin2hex($utf16)); - break; - - case (($ord_var_c & 0xFE) == 0xFC): - // characters U-04000000 - U-7FFFFFFF, mask 1111110X - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $char = pack('C*', $ord_var_c, - ord($var{$c + 1}), - ord($var{$c + 2}), - ord($var{$c + 3}), - ord($var{$c + 4}), - ord($var{$c + 5})); - $c += 5; - $utf16 = $this->json_utf82utf16($char); - $ascii .= sprintf('\u%04s', bin2hex($utf16)); - break; - } - } - - return '"' . $ascii . '"'; - - case 'array': - /* - * As per JSON spec if any array key is not an integer - * we must treat the the whole array as an object. We - * also try to catch a sparsely populated associative - * array with numeric keys here because some JS engines - * will create an array with empty indexes up to - * max_index which can cause memory issues and because - * the keys, which may be relevant, will be remapped - * otherwise. - * - * As per the ECMA and JSON specification an object may - * have any string as a property. Unfortunately due to - * a hole in the ECMA specification if the key is a - * ECMA reserved word or starts with a digit the - * parameter is only accessible using ECMAScript's - * bracket notation. - */ - - // treat as a JSON object - if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) { - - $this->json_objectStack[] = $var; - - $properties = array_map(array($this, 'json_name_value'), - array_keys($var), - array_values($var)); - - array_pop($this->json_objectStack); - - foreach ($properties as $property) { - if ($property instanceof Exception) { - return $property; - } - } - - return '{' . join(',', $properties) . '}'; - } - - $this->json_objectStack[] = $var; - - // treat it like a regular array - $elements = array_map(array($this, 'json_encode'), $var); - - array_pop($this->json_objectStack); - - foreach ($elements as $element) { - if ($element instanceof Exception) { - return $element; - } - } - - return '[' . join(',', $elements) . ']'; - - case 'object': - $vars = self::encodeObject($var); - - $this->json_objectStack[] = $var; - - $properties = array_map(array($this, 'json_name_value'), - array_keys($vars), - array_values($vars)); - - array_pop($this->json_objectStack); - - foreach ($properties as $property) { - if ($property instanceof Exception) { - return $property; - } - } - - return '{' . join(',', $properties) . '}'; - - default: - return null; - } - } - - /** - * array-walking function for use in generating JSON-formatted name-value pairs - * - * @param string $name name of key to use - * @param mixed $value reference to an array element to be encoded - * - * @return string JSON-formatted name-value pair, like '"name":value' - * @access private - */ - private function json_name_value($name, $value) - { - // Encoding the $GLOBALS PHP array causes an infinite loop - // if the recursion is not reset here as it contains - // a reference to itself. This is the only way I have come up - // with to stop infinite recursion in this case. - if ($name == 'GLOBALS' - && is_array($value) - && array_key_exists('GLOBALS', $value)) { - $value['GLOBALS'] = '** Recursion **'; - } - - $encodedValue = $this->json_encode($value); - - if ($encodedValue instanceof Exception) { - return $encodedValue; - } - - return $this->json_encode(strval($name)) . ':' . $encodedValue; - } - - /** - * @deprecated - */ - public function setProcessorUrl($URL) - { - trigger_error('The FirePHP::setProcessorUrl() method is no longer supported', E_USER_DEPRECATED); - } - - /** - * @deprecated - */ - public function setRendererUrl($URL) - { - trigger_error('The FirePHP::setRendererUrl() method is no longer supported', E_USER_DEPRECATED); - } -} \ No newline at end of file diff --git a/vendor/firephp/firephp-core/lib/FirePHPCore/FirePHP.class.php4 b/vendor/firephp/firephp-core/lib/FirePHPCore/FirePHP.class.php4 deleted file mode 100644 index d702cea4a..000000000 --- a/vendor/firephp/firephp-core/lib/FirePHPCore/FirePHP.class.php4 +++ /dev/null @@ -1,1327 +0,0 @@ -, Copyright 2007, New BSD License -// - qbbr, Michael Day , Copyright 2008, New BSD License -// - cadorn, Christoph Dorn , Copyright 2011, MIT License - -/** - * *** BEGIN LICENSE BLOCK ***** - * - * [MIT License](http://www.opensource.org/licenses/mit-license.php) - * - * Copyright (c) 2007+ [Christoph Dorn](http://www.christophdorn.com/) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * ***** END LICENSE BLOCK ***** - * - * This verion of FirePHPCore is for use with PHP4. If you do not require PHP4 - * compatibility, it is suggested you use FirePHPCore.class.php instead. - * - * @copyright Copyright (C) 2007+ Christoph Dorn - * @author Christoph Dorn - * @author Michael Day - * @license [MIT License](http://www.opensource.org/licenses/mit-license.php) - * @package FirePHPCore - */ - -/** - * FirePHP version - * - * @var string - */ -define('FirePHP_VERSION', '0.3'); // @pinf replace '0.3' with '%%VERSION%%' - -/** - * Firebug LOG level - * - * Logs a message to firebug console - * - * @var string - */ -define('FirePHP_LOG', 'LOG'); - -/** - * Firebug INFO level - * - * Logs a message to firebug console and displays an info icon before the message - * - * @var string - */ -define('FirePHP_INFO', 'INFO'); - -/** - * Firebug WARN level - * - * Logs a message to firebug console, displays a warning icon before the message and colors the line turquoise - * - * @var string - */ -define('FirePHP_WARN', 'WARN'); - -/** - * Firebug ERROR level - * - * Logs a message to firebug console, displays an error icon before the message and colors the line yellow. Also increments the firebug error count. - * - * @var string - */ -define('FirePHP_ERROR', 'ERROR'); - -/** - * Dumps a variable to firebug's server panel - * - * @var string - */ -define('FirePHP_DUMP', 'DUMP'); - -/** - * Displays a stack trace in firebug console - * - * @var string - */ -define('FirePHP_TRACE', 'TRACE'); - -/** - * Displays a table in firebug console - * - * @var string - */ -define('FirePHP_TABLE', 'TABLE'); - -/** - * Starts a group in firebug console - * - * @var string - */ -define('FirePHP_GROUP_START', 'GROUP_START'); - -/** - * Ends a group in firebug console - * - * @var string - */ -define('FirePHP_GROUP_END', 'GROUP_END'); - -/** - * Sends the given data to the FirePHP Firefox Extension. - * The data can be displayed in the Firebug Console or in the - * "Server" request tab. - * - * For more information see: http://www.firephp.org/ - * - * @copyright Copyright (C) 2007+ Christoph Dorn - * @author Christoph Dorn - * @author Michael Day - * @license [MIT License](http://www.opensource.org/licenses/mit-license.php) - * @package FirePHPCore - */ -class FirePHP { - /** - * Wildfire protocol message index - * - * @var int - */ - var $messageIndex = 1; - - /** - * Options for the library - * - * @var array - */ - var $options = array('maxObjectDepth' => 5, - 'maxArrayDepth' => 5, - 'useNativeJsonEncode' => true, - 'includeLineNumbers' => true); - - /** - * Filters used to exclude object members when encoding - * - * @var array - */ - var $objectFilters = array(); - - /** - * A stack of objects used to detect recursion during object encoding - * - * @var object - */ - var $objectStack = array(); - - /** - * Flag to enable/disable logging - * - * @var boolean - */ - var $enabled = true; - - /** - * The object constructor - */ - function FirePHP() { - } - - - /** - * When the object gets serialized only include specific object members. - * - * @return array - */ - function __sleep() { - return array('options','objectFilters','enabled'); - } - - /** - * Gets singleton instance of FirePHP - * - * @param boolean $AutoCreate - * @return FirePHP - */ - function &getInstance($AutoCreate=false) { - global $FirePHP_Instance; - - if($AutoCreate===true && !$FirePHP_Instance) { - $FirePHP_Instance = new FirePHP(); - } - - return $FirePHP_Instance; - } - - /** - * Enable and disable logging to Firebug - * - * @param boolean $Enabled TRUE to enable, FALSE to disable - * @return void - */ - function setEnabled($Enabled) { - $this->enabled = $Enabled; - } - - /** - * Check if logging is enabled - * - * @return boolean TRUE if enabled - */ - function getEnabled() { - return $this->enabled; - } - - /** - * Specify a filter to be used when encoding an object - * - * Filters are used to exclude object members. - * - * @param string $Class The class name of the object - * @param array $Filter An array of members to exclude - * @return void - */ - function setObjectFilter($Class, $Filter) { - $this->objectFilters[strtolower($Class)] = $Filter; - } - - /** - * Set some options for the library - * - * Options: - * - maxObjectDepth: The maximum depth to traverse objects (default: 5) - * - maxArrayDepth: The maximum depth to traverse arrays (default: 5) - * - useNativeJsonEncode: If true will use json_encode() (default: true) - * - includeLineNumbers: If true will include line numbers and filenames (default: true) - * - * @param array $Options The options to be set - * @return void - */ - function setOptions($Options) { - $this->options = array_merge($this->options,$Options); - } - - /** - * Get options from the library - * - * @return array The currently set options - */ - function getOptions() { - return $this->options; - } - - /** - * Register FirePHP as your error handler - * - * Will use FirePHP to log each php error. - * - * @return mixed Returns a string containing the previously defined error handler (if any) - */ - function registerErrorHandler() - { - //NOTE: The following errors will not be caught by this error handler: - // E_ERROR, E_PARSE, E_CORE_ERROR, - // E_CORE_WARNING, E_COMPILE_ERROR, - // E_COMPILE_WARNING, E_STRICT - - return set_error_handler(array($this,'errorHandler')); - } - - /** - * FirePHP's error handler - * - * Logs each php error that will occur. - * - * @param int $errno - * @param string $errstr - * @param string $errfile - * @param int $errline - * @param array $errcontext - */ - function errorHandler($errno, $errstr, $errfile, $errline, $errcontext) - { - global $FirePHP_Instance; - // Don't log error if error reporting is switched off - if (error_reporting() == 0) { - return; - } - // Only log error for errors we are asking for - if (error_reporting() & $errno) { - $FirePHP_Instance->group($errstr); - $FirePHP_Instance->error("{$errfile}, line $errline"); - $FirePHP_Instance->groupEnd(); - } - } - - /** - * Register FirePHP driver as your assert callback - * - * @return mixed Returns the original setting - */ - function registerAssertionHandler() - { - return assert_options(ASSERT_CALLBACK, array($this, 'assertionHandler')); - } - - /** - * FirePHP's assertion handler - * - * Logs all assertions to your firebug console and then stops the script. - * - * @param string $file File source of assertion - * @param int $line Line source of assertion - * @param mixed $code Assertion code - */ - function assertionHandler($file, $line, $code) - { - $this->fb($code, 'Assertion Failed', FirePHP_ERROR, array('File'=>$file,'Line'=>$line)); - } - - /** - * Set custom processor url for FirePHP - * - * @param string $URL - */ - function setProcessorUrl($URL) - { - $this->setHeader('X-FirePHP-ProcessorURL', $URL); - } - - /** - * Set custom renderer url for FirePHP - * - * @param string $URL - */ - function setRendererUrl($URL) - { - $this->setHeader('X-FirePHP-RendererURL', $URL); - } - - /** - * Start a group for following messages. - * - * Options: - * Collapsed: [true|false] - * Color: [#RRGGBB|ColorName] - * - * @param string $Name - * @param array $Options OPTIONAL Instructions on how to log the group - * @return true - * @throws Exception - */ - function group($Name, $Options=null) { - - if(!$Name) { - trigger_error('You must specify a label for the group!'); - } - - if($Options) { - if(!is_array($Options)) { - trigger_error('Options must be defined as an array!'); - } - if(array_key_exists('Collapsed', $Options)) { - $Options['Collapsed'] = ($Options['Collapsed'])?'true':'false'; - } - } - - return $this->fb(null, $Name, FirePHP_GROUP_START, $Options); - } - - /** - * Ends a group you have started before - * - * @return true - * @throws Exception - */ - function groupEnd() { - return $this->fb(null, null, FirePHP_GROUP_END); - } - - /** - * Log object with label to firebug console - * - * @see FirePHP::LOG - * @param mixes $Object - * @param string $Label - * @return true - * @throws Exception - */ - function log($Object, $Label=null) { - return $this->fb($Object, $Label, FirePHP_LOG); - } - - /** - * Log object with label to firebug console - * - * @see FirePHP::INFO - * @param mixes $Object - * @param string $Label - * @return true - * @throws Exception - */ - function info($Object, $Label=null) { - return $this->fb($Object, $Label, FirePHP_INFO); - } - - /** - * Log object with label to firebug console - * - * @see FirePHP::WARN - * @param mixes $Object - * @param string $Label - * @return true - * @throws Exception - */ - function warn($Object, $Label=null) { - return $this->fb($Object, $Label, FirePHP_WARN); - } - - /** - * Log object with label to firebug console - * - * @see FirePHP::ERROR - * @param mixes $Object - * @param string $Label - * @return true - * @throws Exception - */ - function error($Object, $Label=null) { - return $this->fb($Object, $Label, FirePHP_ERROR); - } - - /** - * Dumps key and variable to firebug server panel - * - * @see FirePHP::DUMP - * @param string $Key - * @param mixed $Variable - * @return true - * @throws Exception - */ - function dump($Key, $Variable) { - return $this->fb($Variable, $Key, FirePHP_DUMP); - } - - /** - * Log a trace in the firebug console - * - * @see FirePHP::TRACE - * @param string $Label - * @return true - * @throws Exception - */ - function trace($Label) { - return $this->fb($Label, FirePHP_TRACE); - } - - /** - * Log a table in the firebug console - * - * @see FirePHP::TABLE - * @param string $Label - * @param string $Table - * @return true - * @throws Exception - */ - function table($Label, $Table) { - return $this->fb($Table, $Label, FirePHP_TABLE); - } - - /** - * Check if FirePHP is installed on client - * - * @return boolean - */ - function detectClientExtension() { - // Check if FirePHP is installed on client via User-Agent header - if(@preg_match_all('/\sFirePHP\/([\.\d]*)\s?/si',$this->getUserAgent(),$m) && - version_compare($m[1][0],'0.0.6','>=')) { - return true; - } else - // Check if FirePHP is installed on client via X-FirePHP-Version header - if(@preg_match_all('/^([\.\d]*)$/si',$this->getRequestHeader("X-FirePHP-Version"),$m) && - version_compare($m[1][0],'0.0.6','>=')) { - return true; - } - return false; - } - - /** - * Log varible to Firebug - * - * @see http://www.firephp.org/Wiki/Reference/Fb - * @param mixed $Object The variable to be logged - * @return true Return TRUE if message was added to headers, FALSE otherwise - * @throws Exception - */ - function fb($Object) { - - if(!$this->enabled) { - return false; - } - - if (headers_sent($filename, $linenum)) { - trigger_error('Headers already sent in '.$filename.' on line '.$linenum.'. Cannot send log data to FirePHP. You must have Output Buffering enabled via ob_start() or output_buffering ini directive.'); - } - - $Type = null; - $Label = null; - $Options = array(); - - if(func_num_args()==1) { - } else - if(func_num_args()==2) { - switch(func_get_arg(1)) { - case FirePHP_LOG: - case FirePHP_INFO: - case FirePHP_WARN: - case FirePHP_ERROR: - case FirePHP_DUMP: - case FirePHP_TRACE: - case FirePHP_TABLE: - case FirePHP_GROUP_START: - case FirePHP_GROUP_END: - $Type = func_get_arg(1); - break; - default: - $Label = func_get_arg(1); - break; - } - } else - if(func_num_args()==3) { - $Type = func_get_arg(2); - $Label = func_get_arg(1); - } else - if(func_num_args()==4) { - $Type = func_get_arg(2); - $Label = func_get_arg(1); - $Options = func_get_arg(3); - } else { - trigger_error('Wrong number of arguments to fb() function!'); - } - - - if(!$this->detectClientExtension()) { - return false; - } - - $meta = array(); - $skipFinalObjectEncode = false; - - if($Type==FirePHP_TRACE) { - - $trace = debug_backtrace(); - if(!$trace) return false; - for( $i=0 ; $i_standardizePath($trace[$i]['file']),-18,18)=='FirePHPCore/fb.php' - || substr($this->_standardizePath($trace[$i]['file']),-29,29)=='FirePHPCore/FirePHP.class.php')) { - /* Skip - FB::trace(), FB::send(), $firephp->trace(), $firephp->fb() */ - } else - if(isset($trace[$i]['class']) - && isset($trace[$i+1]['file']) - && $trace[$i]['class']=='FirePHP' - && substr($this->_standardizePath($trace[$i+1]['file']),-18,18)=='FirePHPCore/fb.php') { - /* Skip fb() */ - } else - if($trace[$i]['function']=='fb' - || $trace[$i]['function']=='trace' - || $trace[$i]['function']=='send') { - $Object = array('Class'=>isset($trace[$i]['class'])?$trace[$i]['class']:'', - 'Type'=>isset($trace[$i]['type'])?$trace[$i]['type']:'', - 'Function'=>isset($trace[$i]['function'])?$trace[$i]['function']:'', - 'Message'=>$trace[$i]['args'][0], - 'File'=>isset($trace[$i]['file'])?$this->_escapeTraceFile($trace[$i]['file']):'', - 'Line'=>isset($trace[$i]['line'])?$trace[$i]['line']:'', - 'Args'=>isset($trace[$i]['args'])?$this->encodeObject($trace[$i]['args']):'', - 'Trace'=>$this->_escapeTrace(array_splice($trace,$i+1))); - - $skipFinalObjectEncode = true; - $meta['file'] = isset($trace[$i]['file'])?$this->_escapeTraceFile($trace[$i]['file']):''; - $meta['line'] = isset($trace[$i]['line'])?$trace[$i]['line']:''; - break; - } - } - - } else - if($Type==FirePHP_TABLE) { - - if(isset($Object[0]) && is_string($Object[0])) { - $Object[1] = $this->encodeTable($Object[1]); - } else { - $Object = $this->encodeTable($Object); - } - - $skipFinalObjectEncode = true; - - } else - if($Type==FirePHP_GROUP_START) { - - if(!$Label) { - trigger_error('You must specify a label for the group!'); - } - } else { - if($Type===null) { - $Type = FirePHP_LOG; - } - } - - if($this->options['includeLineNumbers']) { - if(!isset($meta['file']) || !isset($meta['line'])) { - - $trace = debug_backtrace(); - for( $i=0 ; $trace && $i_standardizePath($trace[$i]['file']),-18,18)=='FirePHPCore/fb.php' - || substr($this->_standardizePath($trace[$i]['file']),-29,29)=='FirePHPCore/FirePHP.class.php')) { - /* Skip - FB::trace(), FB::send(), $firephp->trace(), $firephp->fb() */ - } else - if(isset($trace[$i]['class']) - && isset($trace[$i+1]['file']) - && $trace[$i]['class']=='FirePHP' - && substr($this->_standardizePath($trace[$i+1]['file']),-18,18)=='FirePHPCore/fb.php') { - /* Skip fb() */ - } else - if(isset($trace[$i]['file']) - && substr($this->_standardizePath($trace[$i]['file']),-18,18)=='FirePHPCore/fb.php') { - /* Skip FB::fb() */ - } else { - $meta['file'] = isset($trace[$i]['file'])?$this->_escapeTraceFile($trace[$i]['file']):''; - $meta['line'] = isset($trace[$i]['line'])?$trace[$i]['line']:''; - break; - } - } - - } - } else { - unset($meta['file']); - unset($meta['line']); - } - - $this->setHeader('X-Wf-Protocol-1','http://meta.wildfirehq.org/Protocol/JsonStream/0.2'); - $this->setHeader('X-Wf-1-Plugin-1','http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/'.FirePHP_VERSION); - - $structure_index = 1; - if($Type==FirePHP_DUMP) { - $structure_index = 2; - $this->setHeader('X-Wf-1-Structure-2','http://meta.firephp.org/Wildfire/Structure/FirePHP/Dump/0.1'); - } else { - $this->setHeader('X-Wf-1-Structure-1','http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1'); - } - - if($Type==FirePHP_DUMP) { - $msg = '{"'.$Label.'":'.$this->jsonEncode($Object, $skipFinalObjectEncode).'}'; - } else { - $msg_meta = $Options; - $msg_meta['Type'] = $Type; - if($Label!==null) { - $msg_meta['Label'] = $Label; - } - if(isset($meta['file']) && !isset($msg_meta['File'])) { - $msg_meta['File'] = $meta['file']; - } - if(isset($meta['line']) && !isset($msg_meta['Line'])) { - $msg_meta['Line'] = $meta['line']; - } - $msg = '['.$this->jsonEncode($msg_meta).','.$this->jsonEncode($Object, $skipFinalObjectEncode).']'; - } - - $parts = explode("\n",chunk_split($msg, 5000, "\n")); - - for( $i=0 ; $i2) { - // Message needs to be split into multiple parts - $this->setHeader('X-Wf-1-'.$structure_index.'-'.'1-'.$this->messageIndex, - (($i==0)?strlen($msg):'') - . '|' . $part . '|' - . (($isetHeader('X-Wf-1-'.$structure_index.'-'.'1-'.$this->messageIndex, - strlen($part) . '|' . $part . '|'); - } - - $this->messageIndex++; - - if ($this->messageIndex > 99999) { - trigger_error('Maximum number (99,999) of messages reached!'); - } - } - } - - $this->setHeader('X-Wf-1-Index',$this->messageIndex-1); - - return true; - } - - - /** - * Standardizes path for windows systems. - * - * @param string $Path - * @return string - */ - function _standardizePath($Path) { - return preg_replace('/\\\\+/','/',$Path); - } - - /** - * Escape trace path for windows systems - * - * @param array $Trace - * @return array - */ - function _escapeTrace($Trace) { - if(!$Trace) return $Trace; - for( $i=0 ; $i_escapeTraceFile($Trace[$i]['file']); - } - if(isset($Trace[$i]['args'])) { - $Trace[$i]['args'] = $this->encodeObject($Trace[$i]['args']); - } - } - return $Trace; - } - - /** - * Escape file information of trace for windows systems - * - * @param string $File - * @return string - */ - function _escapeTraceFile($File) { - /* Check if we have a windows filepath */ - if(strpos($File,'\\')) { - /* First strip down to single \ */ - - $file = preg_replace('/\\\\+/','\\',$File); - - return $file; - } - return $File; - } - - /** - * Send header - * - * @param string $Name - * @param string_type $Value - */ - function setHeader($Name, $Value) { - return header($Name.': '.$Value); - } - - /** - * Get user agent - * - * @return string|false - */ - function getUserAgent() { - if(!isset($_SERVER['HTTP_USER_AGENT'])) return false; - return $_SERVER['HTTP_USER_AGENT']; - } - - /** - * Get all request headers - * - * @return array - */ - function getAllRequestHeaders() { - $headers = array(); - if(function_exists('getallheaders')) { - foreach( getallheaders() as $name => $value ) { - $headers[strtolower($name)] = $value; - } - } else { - foreach($_SERVER as $name => $value) { - if(substr($name, 0, 5) == 'HTTP_') { - $headers[strtolower(str_replace(' ', '-', str_replace('_', ' ', substr($name, 5))))] = $value; - } - } - } - return $headers; - } - - /** - * Get a request header - * - * @return string|false - */ - function getRequestHeader($Name) - { - $headers = $this->getAllRequestHeaders(); - if (isset($headers[strtolower($Name)])) { - return $headers[strtolower($Name)]; - } - return false; - } - - /** - * Encode an object into a JSON string - * - * Uses PHP's jeson_encode() if available - * - * @param object $Object The object to be encoded - * @return string The JSON string - */ - function jsonEncode($Object, $skipObjectEncode=false) - { - if(!$skipObjectEncode) { - $Object = $this->encodeObject($Object); - } - - if(function_exists('json_encode') - && $this->options['useNativeJsonEncode']!=false) { - - return json_encode($Object); - } else { - return $this->json_encode($Object); - } - } - - /** - * Encodes a table by encoding each row and column with encodeObject() - * - * @param array $Table The table to be encoded - * @return array - */ - function encodeTable($Table) { - - if(!$Table) return $Table; - - $new_table = array(); - foreach($Table as $row) { - - if(is_array($row)) { - $new_row = array(); - - foreach($row as $item) { - $new_row[] = $this->encodeObject($item); - } - - $new_table[] = $new_row; - } - } - - return $new_table; - } - - /** - * Encodes an object - * - * @param Object $Object The object to be encoded - * @param int $Depth The current traversal depth - * @return array All members of the object - */ - function encodeObject($Object, $ObjectDepth = 1, $ArrayDepth = 1) - { - $return = array(); - - if (is_resource($Object)) { - - return '** '.(string)$Object.' **'; - - } else - if (is_object($Object)) { - - if ($ObjectDepth > $this->options['maxObjectDepth']) { - return '** Max Object Depth ('.$this->options['maxObjectDepth'].') **'; - } - - foreach ($this->objectStack as $refVal) { - if ($refVal === $Object) { - return '** Recursion ('.get_class($Object).') **'; - } - } - array_push($this->objectStack, $Object); - - $return['__className'] = $class = get_class($Object); - $class_lower = strtolower($class); - - $members = (array)$Object; - - // Include all members that are not defined in the class - // but exist in the object - foreach( $members as $raw_name => $value ) { - - $name = $raw_name; - - if ($name{0} == "\0") { - $parts = explode("\0", $name); - $name = $parts[2]; - } - - if(!isset($properties[$name])) { - $name = 'undeclared:'.$name; - - if(!(isset($this->objectFilters[$class_lower]) - && is_array($this->objectFilters[$class_lower]) - && in_array($raw_name,$this->objectFilters[$class_lower]))) { - - $return[$name] = $this->encodeObject($value, $ObjectDepth + 1, 1); - } else { - $return[$name] = '** Excluded by Filter **'; - } - } - } - - array_pop($this->objectStack); - - } elseif (is_array($Object)) { - - if ($ArrayDepth > $this->options['maxArrayDepth']) { - return '** Max Array Depth ('.$this->options['maxArrayDepth'].') **'; - } - - foreach ($Object as $key => $val) { - - // Encoding the $GLOBALS PHP array causes an infinite loop - // if the recursion is not reset here as it contains - // a reference to itself. This is the only way I have come up - // with to stop infinite recursion in this case. - if($key=='GLOBALS' - && is_array($val) - && array_key_exists('GLOBALS',$val)) { - $val['GLOBALS'] = '** Recursion (GLOBALS) **'; - } - - $return[$key] = $this->encodeObject($val, 1, $ArrayDepth + 1); - } - } else { - if($this->is_utf8($Object)) { - return $Object; - } else { - return utf8_encode($Object); - } - } - return $return; - - } - - /** - * Returns true if $string is valid UTF-8 and false otherwise. - * - * @param mixed $str String to be tested - * @return boolean - */ - function is_utf8($str) { - $c=0; $b=0; - $bits=0; - $len=strlen($str); - for($i=0; $i<$len; $i++){ - $c=ord($str[$i]); - if($c > 128){ - if(($c >= 254)) return false; - elseif($c >= 252) $bits=6; - elseif($c >= 248) $bits=5; - elseif($c >= 240) $bits=4; - elseif($c >= 224) $bits=3; - elseif($c >= 192) $bits=2; - else return false; - if(($i+$bits) > $len) return false; - while($bits > 1){ - $i++; - $b=ord($str[$i]); - if($b < 128 || $b > 191) return false; - $bits--; - } - } - } - return true; - } - - /** - * Converts to and from JSON format. - * - * JSON (JavaScript Object Notation) is a lightweight data-interchange - * format. It is easy for humans to read and write. It is easy for machines - * to parse and generate. It is based on a subset of the JavaScript - * Programming Language, Standard ECMA-262 3rd Edition - December 1999. - * This feature can also be found in Python. JSON is a text format that is - * completely language independent but uses conventions that are familiar - * to programmers of the C-family of languages, including C, C++, C#, Java, - * JavaScript, Perl, TCL, and many others. These properties make JSON an - * ideal data-interchange language. - * - * This package provides a simple encoder and decoder for JSON notation. It - * is intended for use with client-side Javascript applications that make - * use of HTTPRequest to perform server communication functions - data can - * be encoded into JSON notation for use in a client-side javascript, or - * decoded from incoming Javascript requests. JSON format is native to - * Javascript, and can be directly eval()'ed with no further parsing - * overhead - * - * All strings should be in ASCII or UTF-8 format! - * - * LICENSE: Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: Redistributions of source code must retain the - * above copyright notice, this list of conditions and the following - * disclaimer. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR - * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE - * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH - * DAMAGE. - * - * @category - * @package Services_JSON - * @author Michal Migurski - * @author Matt Knapp - * @author Brett Stimmerman - * @author Christoph Dorn - * @copyright 2005 Michal Migurski - * @version CVS: $Id: JSON.php,v 1.31 2006/06/28 05:54:17 migurski Exp $ - * @license http://www.opensource.org/licenses/bsd-license.php - * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198 - */ - - - /** - * Keep a list of objects as we descend into the array so we can detect recursion. - */ - var $json_objectStack = array(); - - - /** - * convert a string from one UTF-8 char to one UTF-16 char - * - * Normally should be handled by mb_convert_encoding, but - * provides a slower PHP-only method for installations - * that lack the multibye string extension. - * - * @param string $utf8 UTF-8 character - * @return string UTF-16 character - * @access private - */ - function json_utf82utf16($utf8) - { - // oh please oh please oh please oh please oh please - if(function_exists('mb_convert_encoding')) { - return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8'); - } - - switch(strlen($utf8)) { - case 1: - // this case should never be reached, because we are in ASCII range - // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - return $utf8; - - case 2: - // return a UTF-16 character from a 2-byte UTF-8 char - // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - return chr(0x07 & (ord($utf8{0}) >> 2)) - . chr((0xC0 & (ord($utf8{0}) << 6)) - | (0x3F & ord($utf8{1}))); - - case 3: - // return a UTF-16 character from a 3-byte UTF-8 char - // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - return chr((0xF0 & (ord($utf8{0}) << 4)) - | (0x0F & (ord($utf8{1}) >> 2))) - . chr((0xC0 & (ord($utf8{1}) << 6)) - | (0x7F & ord($utf8{2}))); - } - - // ignoring UTF-32 for now, sorry - return ''; - } - - /** - * encodes an arbitrary variable into JSON format - * - * @param mixed $var any number, boolean, string, array, or object to be encoded. - * see argument 1 to Services_JSON() above for array-parsing behavior. - * if var is a strng, note that encode() always expects it - * to be in ASCII or UTF-8 format! - * - * @return mixed JSON string representation of input var or an error if a problem occurs - * @access public - */ - function json_encode($var) - { - - if(is_object($var)) { - if(in_array($var,$this->json_objectStack)) { - return '"** Recursion **"'; - } - } - - switch (gettype($var)) { - case 'boolean': - return $var ? 'true' : 'false'; - - case 'NULL': - return 'null'; - - case 'integer': - return (int) $var; - - case 'double': - case 'float': - return (float) $var; - - case 'string': - // STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT - $ascii = ''; - $strlen_var = strlen($var); - - /* - * Iterate over every character in the string, - * escaping with a slash or encoding to UTF-8 where necessary - */ - for ($c = 0; $c < $strlen_var; ++$c) { - - $ord_var_c = ord($var{$c}); - - switch (true) { - case $ord_var_c == 0x08: - $ascii .= '\b'; - break; - case $ord_var_c == 0x09: - $ascii .= '\t'; - break; - case $ord_var_c == 0x0A: - $ascii .= '\n'; - break; - case $ord_var_c == 0x0C: - $ascii .= '\f'; - break; - case $ord_var_c == 0x0D: - $ascii .= '\r'; - break; - - case $ord_var_c == 0x22: - case $ord_var_c == 0x2F: - case $ord_var_c == 0x5C: - // double quote, slash, slosh - $ascii .= '\\'.$var{$c}; - break; - - case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)): - // characters U-00000000 - U-0000007F (same as ASCII) - $ascii .= $var{$c}; - break; - - case (($ord_var_c & 0xE0) == 0xC0): - // characters U-00000080 - U-000007FF, mask 110XXXXX - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $char = pack('C*', $ord_var_c, ord($var{$c + 1})); - $c += 1; - $utf16 = $this->json_utf82utf16($char); - $ascii .= sprintf('\u%04s', bin2hex($utf16)); - break; - - case (($ord_var_c & 0xF0) == 0xE0): - // characters U-00000800 - U-0000FFFF, mask 1110XXXX - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $char = pack('C*', $ord_var_c, - ord($var{$c + 1}), - ord($var{$c + 2})); - $c += 2; - $utf16 = $this->json_utf82utf16($char); - $ascii .= sprintf('\u%04s', bin2hex($utf16)); - break; - - case (($ord_var_c & 0xF8) == 0xF0): - // characters U-00010000 - U-001FFFFF, mask 11110XXX - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $char = pack('C*', $ord_var_c, - ord($var{$c + 1}), - ord($var{$c + 2}), - ord($var{$c + 3})); - $c += 3; - $utf16 = $this->json_utf82utf16($char); - $ascii .= sprintf('\u%04s', bin2hex($utf16)); - break; - - case (($ord_var_c & 0xFC) == 0xF8): - // characters U-00200000 - U-03FFFFFF, mask 111110XX - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $char = pack('C*', $ord_var_c, - ord($var{$c + 1}), - ord($var{$c + 2}), - ord($var{$c + 3}), - ord($var{$c + 4})); - $c += 4; - $utf16 = $this->json_utf82utf16($char); - $ascii .= sprintf('\u%04s', bin2hex($utf16)); - break; - - case (($ord_var_c & 0xFE) == 0xFC): - // characters U-04000000 - U-7FFFFFFF, mask 1111110X - // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 - $char = pack('C*', $ord_var_c, - ord($var{$c + 1}), - ord($var{$c + 2}), - ord($var{$c + 3}), - ord($var{$c + 4}), - ord($var{$c + 5})); - $c += 5; - $utf16 = $this->json_utf82utf16($char); - $ascii .= sprintf('\u%04s', bin2hex($utf16)); - break; - } - } - - return '"'.$ascii.'"'; - - case 'array': - /* - * As per JSON spec if any array key is not an integer - * we must treat the the whole array as an object. We - * also try to catch a sparsely populated associative - * array with numeric keys here because some JS engines - * will create an array with empty indexes up to - * max_index which can cause memory issues and because - * the keys, which may be relevant, will be remapped - * otherwise. - * - * As per the ECMA and JSON specification an object may - * have any string as a property. Unfortunately due to - * a hole in the ECMA specification if the key is a - * ECMA reserved word or starts with a digit the - * parameter is only accessible using ECMAScript's - * bracket notation. - */ - - // treat as a JSON object - if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) { - - $this->json_objectStack[] = $var; - - $properties = array_map(array($this, 'json_name_value'), - array_keys($var), - array_values($var)); - - array_pop($this->json_objectStack); - - return '{' . join(',', $properties) . '}'; - } - - $this->json_objectStack[] = $var; - - // treat it like a regular array - $elements = array_map(array($this, 'json_encode'), $var); - - array_pop($this->json_objectStack); - - return '[' . join(',', $elements) . ']'; - - case 'object': - $vars = FirePHP::encodeObject($var); - - $this->json_objectStack[] = $var; - - $properties = array_map(array($this, 'json_name_value'), - array_keys($vars), - array_values($vars)); - - array_pop($this->json_objectStack); - - return '{' . join(',', $properties) . '}'; - - default: - return null; - } - } - - /** - * array-walking function for use in generating JSON-formatted name-value pairs - * - * @param string $name name of key to use - * @param mixed $value reference to an array element to be encoded - * - * @return string JSON-formatted name-value pair, like '"name":value' - * @access private - */ - function json_name_value($name, $value) - { - // Encoding the $GLOBALS PHP array causes an infinite loop - // if the recursion is not reset here as it contains - // a reference to itself. This is the only way I have come up - // with to stop infinite recursion in this case. - if($name=='GLOBALS' - && is_array($value) - && array_key_exists('GLOBALS',$value)) { - $value['GLOBALS'] = '** Recursion **'; - } - - $encoded_value = $this->json_encode($value); - - return $this->json_encode(strval($name)) . ':' . $encoded_value; - } -} - diff --git a/vendor/firephp/firephp-core/lib/FirePHPCore/fb.php b/vendor/firephp/firephp-core/lib/FirePHPCore/fb.php deleted file mode 100644 index 8827ba15d..000000000 --- a/vendor/firephp/firephp-core/lib/FirePHPCore/fb.php +++ /dev/null @@ -1,275 +0,0 @@ -, Copyright 2007, New BSD License -// - qbbr, Sokolov Innokenty , Copyright 2011, New BSD License -// - cadorn, Christoph Dorn , Copyright 2011, MIT License - -/** - * ***** BEGIN LICENSE BLOCK ***** - * - * [MIT License](http://www.opensource.org/licenses/mit-license.php) - * - * Copyright (c) 2007+ [Christoph Dorn](http://www.christophdorn.com/) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * ***** END LICENSE BLOCK ***** - * - * @copyright Copyright (C) 2007+ Christoph Dorn - * @author Christoph Dorn - * @license [MIT License](http://www.opensource.org/licenses/mit-license.php) - * @package FirePHPCore - */ - -if (!class_exists('FirePHP', false)) { - require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'FirePHP.class.php'; -} - -/** - * Sends the given data to the FirePHP Firefox Extension. - * The data can be displayed in the Firebug Console or in the - * "Server" request tab. - * - * @see http://www.firephp.org/Wiki/Reference/Fb - * @param mixed $Object - * @return true - * @throws Exception - */ -function fb() -{ - $instance = FirePHP::getInstance(true); - - $args = func_get_args(); - return call_user_func_array(array($instance, 'fb'), $args); -} - - -class FB -{ - /** - * Set an Insight console to direct all logging calls to - * - * @param object $console The console object to log to - * @return void - */ - public static function setLogToInsightConsole($console) - { - FirePHP::getInstance(true)->setLogToInsightConsole($console); - } - - /** - * Enable and disable logging to Firebug - * - * @see FirePHP->setEnabled() - * @param boolean $enabled TRUE to enable, FALSE to disable - * @return void - */ - public static function setEnabled($enabled) - { - FirePHP::getInstance(true)->setEnabled($enabled); - } - - /** - * Check if logging is enabled - * - * @see FirePHP->getEnabled() - * @return boolean TRUE if enabled - */ - public static function getEnabled() - { - return FirePHP::getInstance(true)->getEnabled(); - } - - /** - * Specify a filter to be used when encoding an object - * - * Filters are used to exclude object members. - * - * @see FirePHP->setObjectFilter() - * @param string $class The class name of the object - * @param array $filter An array or members to exclude - * @return void - */ - public static function setObjectFilter($class, $filter) - { - FirePHP::getInstance(true)->setObjectFilter($class, $filter); - } - - /** - * Set some options for the library - * - * @see FirePHP->setOptions() - * @param array $options The options to be set - * @return void - */ - public static function setOptions($options) - { - FirePHP::getInstance(true)->setOptions($options); - } - - /** - * Get options for the library - * - * @see FirePHP->getOptions() - * @return array The options - */ - public static function getOptions() - { - return FirePHP::getInstance(true)->getOptions(); - } - - /** - * Log object to firebug - * - * @see http://www.firephp.org/Wiki/Reference/Fb - * @param mixed $object - * @return true - * @throws Exception - */ - public static function send() - { - $args = func_get_args(); - return call_user_func_array(array(FirePHP::getInstance(true), 'fb'), $args); - } - - /** - * Start a group for following messages - * - * Options: - * Collapsed: [true|false] - * Color: [#RRGGBB|ColorName] - * - * @param string $name - * @param array $options OPTIONAL Instructions on how to log the group - * @return true - */ - public static function group($name, $options=null) - { - return FirePHP::getInstance(true)->group($name, $options); - } - - /** - * Ends a group you have started before - * - * @return true - * @throws Exception - */ - public static function groupEnd() - { - return self::send(null, null, FirePHP::GROUP_END); - } - - /** - * Log object with label to firebug console - * - * @see FirePHP::LOG - * @param mixes $object - * @param string $label - * @return true - * @throws Exception - */ - public static function log($object, $label=null) - { - return self::send($object, $label, FirePHP::LOG); - } - - /** - * Log object with label to firebug console - * - * @see FirePHP::INFO - * @param mixes $object - * @param string $label - * @return true - * @throws Exception - */ - public static function info($object, $label=null) - { - return self::send($object, $label, FirePHP::INFO); - } - - /** - * Log object with label to firebug console - * - * @see FirePHP::WARN - * @param mixes $object - * @param string $label - * @return true - * @throws Exception - */ - public static function warn($object, $label=null) - { - return self::send($object, $label, FirePHP::WARN); - } - - /** - * Log object with label to firebug console - * - * @see FirePHP::ERROR - * @param mixes $object - * @param string $label - * @return true - * @throws Exception - */ - public static function error($object, $label=null) - { - return self::send($object, $label, FirePHP::ERROR); - } - - /** - * Dumps key and variable to firebug server panel - * - * @see FirePHP::DUMP - * @param string $key - * @param mixed $variable - * @return true - * @throws Exception - */ - public static function dump($key, $variable) - { - return self::send($variable, $key, FirePHP::DUMP); - } - - /** - * Log a trace in the firebug console - * - * @see FirePHP::TRACE - * @param string $label - * @return true - * @throws Exception - */ - public static function trace($label) - { - return self::send($label, FirePHP::TRACE); - } - - /** - * Log a table in the firebug console - * - * @see FirePHP::TABLE - * @param string $label - * @param string $table - * @return true - * @throws Exception - */ - public static function table($label, $table) - { - return self::send($table, $label, FirePHP::TABLE); - } - -} \ No newline at end of file diff --git a/vendor/firephp/firephp-core/lib/FirePHPCore/fb.php4 b/vendor/firephp/firephp-core/lib/FirePHPCore/fb.php4 deleted file mode 100644 index eab2f0f68..000000000 --- a/vendor/firephp/firephp-core/lib/FirePHPCore/fb.php4 +++ /dev/null @@ -1,245 +0,0 @@ -, Copyright 2007, New BSD License -// - qbbr, Michael Day , Copyright 2008, New BSD License -// - cadorn, Christoph Dorn , Copyright 2011, MIT License - -/* ***** BEGIN LICENSE BLOCK ***** - * - * [MIT License](http://www.opensource.org/licenses/mit-license.php) - * - * Copyright (c) 2007+ [Christoph Dorn](http://www.christophdorn.com/) - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * ***** END LICENSE BLOCK ***** - * - * @copyright Copyright (C) 2007+ Christoph Dorn - * @author Christoph Dorn - * @author Michael Day - * @license [MIT License](http://www.opensource.org/licenses/mit-license.php) - * @package FirePHPCore - */ - -require_once dirname(__FILE__).'/FirePHP.class.php4'; - -/** - * Sends the given data to the FirePHP Firefox Extension. - * The data can be displayed in the Firebug Console or in the - * "Server" request tab. - * - * @see http://www.firephp.org/Wiki/Reference/Fb - * @param mixed $Object - * @return true - * @throws Exception - */ -function fb() -{ - $instance =& FirePHP::getInstance(true); - - $args = func_get_args(); - return call_user_func_array(array(&$instance,'fb'),$args); -} - - -class FB -{ - /** - * Enable and disable logging to Firebug - * - * @see FirePHP->setEnabled() - * @param boolean $Enabled TRUE to enable, FALSE to disable - * @return void - */ - function setEnabled($Enabled) { - $instance =& FirePHP::getInstance(true); - $instance->setEnabled($Enabled); - } - - /** - * Check if logging is enabled - * - * @see FirePHP->getEnabled() - * @return boolean TRUE if enabled - */ - function getEnabled() { - $instance =& FirePHP::getInstance(true); - return $instance->getEnabled(); - } - - /** - * Specify a filter to be used when encoding an object - * - * Filters are used to exclude object members. - * - * @see FirePHP->setObjectFilter() - * @param string $Class The class name of the object - * @param array $Filter An array or members to exclude - * @return void - */ - function setObjectFilter($Class, $Filter) { - $instance =& FirePHP::getInstance(true); - $instance->setObjectFilter($Class, $Filter); - } - - /** - * Set some options for the library - * - * @see FirePHP->setOptions() - * @param array $Options The options to be set - * @return void - */ - function setOptions($Options) { - $instance =& FirePHP::getInstance(true); - $instance->setOptions($Options); - } - - /** - * Get options for the library - * - * @see FirePHP->getOptions() - * @return array The options - */ - function getOptions() { - $instance =& FirePHP::getInstance(true); - return $instance->getOptions(); - } - - /** - * Log object to firebug - * - * @see http://www.firephp.org/Wiki/Reference/Fb - * @param mixed $Object - * @return true - */ - function send() - { - $instance =& FirePHP::getInstance(true); - $args = func_get_args(); - return call_user_func_array(array(&$instance,'fb'),$args); - } - - /** - * Start a group for following messages - * - * Options: - * Collapsed: [true|false] - * Color: [#RRGGBB|ColorName] - * - * @param string $Name - * @param array $Options OPTIONAL Instructions on how to log the group - * @return true - */ - function group($Name, $Options=null) { - $instance =& FirePHP::getInstance(true); - return $instance->group($Name, $Options); - } - - /** - * Ends a group you have started before - * - * @return true - */ - function groupEnd() { - return FB::send(null, null, FirePHP_GROUP_END); - } - - /** - * Log object with label to firebug console - * - * @see FirePHP::LOG - * @param mixes $Object - * @param string $Label - * @return true - */ - function log($Object, $Label=null) { - return FB::send($Object, $Label, FirePHP_LOG); - } - - /** - * Log object with label to firebug console - * - * @see FirePHP::INFO - * @param mixes $Object - * @param string $Label - * @return true - */ - function info($Object, $Label=null) { - return FB::send($Object, $Label, FirePHP_INFO); - } - - /** - * Log object with label to firebug console - * - * @see FirePHP::WARN - * @param mixes $Object - * @param string $Label - * @return true - */ - function warn($Object, $Label=null) { - return FB::send($Object, $Label, FirePHP_WARN); - } - - /** - * Log object with label to firebug console - * - * @see FirePHP::ERROR - * @param mixes $Object - * @param string $Label - * @return true - */ - function error($Object, $Label=null) { - return FB::send($Object, $Label, FirePHP_ERROR); - } - - /** - * Dumps key and variable to firebug server panel - * - * @see FirePHP::DUMP - * @param string $Key - * @param mixed $Variable - * @return true - */ - function dump($Key, $Variable) { - return FB::send($Variable, $Key, FirePHP_DUMP); - } - - /** - * Log a trace in the firebug console - * - * @see FirePHP::TRACE - * @param string $Label - * @return true - */ - function trace($Label) { - return FB::send($Label, FirePHP_TRACE); - } - - /** - * Log a table in the firebug console - * - * @see FirePHP::TABLE - * @param string $Label - * @param string $Table - * @return true - */ - function table($Label, $Table) { - return FB::send($Table, $Label, FirePHP_TABLE); - } -} diff --git a/vendor/firephp/firephp-core/package.json b/vendor/firephp/firephp-core/package.json deleted file mode 100644 index 291a92022..000000000 --- a/vendor/firephp/firephp-core/package.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "uid": "https://github.com/firephp/firephp-core/", - "name": "firephp-core", - "version": "0.4.0", - "label": "FirePHP Server Library", - "repositories": [ - { - "type": "git", - "url": "git://github.com/firephp/firephp-core.git" - } - ], - "maintainers": [ - { - "name": "Christoph Dorn", - "email": "christoph@christophdorn.com", - "web": "http://www.christophdorn.com/", - "alias": { - "github": "cadorn" - } - } - ], - "contributors": [ - { - "name": "Christoph Dorn", - "email": "christoph@christophdorn.com", - "web": "http://www.christophdorn.com/", - "alias": { - "github": "cadorn" - } - }, - { - "name": "Michael Day", - "email": "manveru.alma@gmail.com" - }, - { - "name": "Sokolov Innokenty", - "email": "sokolov.innokenty@gmail.com", - "alias": { - "github": "qbbr" - } - } - ] -} \ No newline at end of file diff --git a/vendor/firephp/firephp-core/program.json b/vendor/firephp/firephp-core/program.json deleted file mode 100644 index 9889e97a3..000000000 --- a/vendor/firephp/firephp-core/program.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "extends": { - "location": "./workspace/program.json" - } -} \ No newline at end of file diff --git a/vendor/firephp/firephp-core/tests/API/newlines.php b/vendor/firephp/firephp-core/tests/API/newlines.php deleted file mode 100644 index 1e5511e54..000000000 --- a/vendor/firephp/firephp-core/tests/API/newlines.php +++ /dev/null @@ -1,12 +0,0 @@ -dump("key", "value"); - $headers = $firephp->_getHeaders(); - $this->assertEquals('15|{"key":"value"}|', $headers['X-Wf-1-2-1-1']); - $firephp->_clearHeaders(); - - $caught = false; - try { - $firephp->dump(array(), "value"); - } catch(Exception $e) { - // Key passed to dump() is not a string - $caught = true; - } - if(!$caught) $this->fail('No exception thrown'); - - $caught = false; - try { - $firephp->dump("key \n\r value", "value"); - } catch(Exception $e) { - // Key passed to dump() contains invalid characters [a-zA-Z0-9-_\.:] - $caught = true; - } - if(!$caught) $this->fail('No exception thrown'); - - $caught = false; - try { - $firephp->dump("keykeykeykkeykeykeykkeykeykeykkeykeykeykkeykeykeykkeykeykeykkeykeykeykkeykeykeykkeykeykeykkeykeykeyk1", "value"); - } catch(Exception $e) { - // Key passed to dump() is longer than 100 characters - $caught = true; - } - if(!$caught) $this->fail('No exception thrown'); - } - - /** - * @issue http://code.google.com/p/firephp/issues/detail?id=123 - */ - public function testRegisterErrorHandler() - { - $firephp = new FirePHP_Test_Class(); - $firephp->setOption("maxObjectDepth", 1); - $firephp->setOption("maxArrayDepth", 1); - - $firephp->registerErrorHandler(); - trigger_error("Hello World"); - $headers = $firephp->_getHeaders(); - if(!isset($headers["X-Wf-1-1-1-1"])) { - $this->fail("Error not in headers"); - } - } - - /** - * @issue http://code.google.com/p/firephp/issues/detail?id=122 - */ - public function testFirePHPClassInstanceLogging() - { - $firephp = new FirePHP_Test_Class(); - - $firephp->log($firephp); - $headers = $firephp->_getHeaders(); - if(!preg_match_all('/"protected:objectStack":"\\*\\* Excluded by Filter \\*\\*"/', $headers['X-Wf-1-1-1-1'], $m)) { - $this->fail("objectStack member contains value"); - } - if(!preg_match_all('/"protected:static:instance":"\\*\\* Excluded by Filter \\*\\*"/', $headers['X-Wf-1-1-1-1'], $m)) { - $this->fail("instance member should not be logged"); - } - if(!preg_match_all('/"undeclared:json_objectStack":"\\*\\* Excluded by Filter \\*\\*"/', $headers['X-Wf-1-1-1-1'], $m)) { - $this->fail("json_objectStack member should not be logged"); - } - } - - /** - * @issue http://code.google.com/p/firephp/issues/detail?id=114 - */ - public function testCustomFileLineOptions() - { - $firephp = new FirePHP_Test_Class(); - - $firephp->log("message", "label", array("File"=>"/file/path", "Line"=>"1")); - $firephp->info("message", "label", array("File"=>"/file/path", "Line"=>"1")); - $firephp->warn("message", "label", array("File"=>"/file/path", "Line"=>"1")); - $firephp->error("message", "label", array("File"=>"/file/path", "Line"=>"1")); - $firephp->dump("key", "value", array("File"=>"/file/path", "Line"=>"1")); - $firephp->table("label", array(array("header"),array("cell")), array("File"=>"/file/path", "Line"=>"1")); - - $headers = $firephp->_getHeaders(); - - $this->assertEquals('75|[{"File":"\/file\/path","Line":"1","Type":"LOG","Label":"label"},"message"]|', $headers['X-Wf-1-1-1-1']); - $this->assertEquals('76|[{"File":"\/file\/path","Line":"1","Type":"INFO","Label":"label"},"message"]|', $headers['X-Wf-1-1-1-2']); - $this->assertEquals('76|[{"File":"\/file\/path","Line":"1","Type":"WARN","Label":"label"},"message"]|', $headers['X-Wf-1-1-1-3']); - $this->assertEquals('77|[{"File":"\/file\/path","Line":"1","Type":"ERROR","Label":"label"},"message"]|', $headers['X-Wf-1-1-1-4']); - $this->assertEquals('15|{"key":"value"}|', $headers['X-Wf-1-2-1-5']); - $this->assertEquals('89|[{"File":"\/file\/path","Line":"1","Type":"TABLE","Label":"label"},[["header"],["cell"]]]|', $headers['X-Wf-1-1-1-6']); - } - - public function testRecursiveEncode() - { - $firephp = new FirePHP_Test_Class(); - - $obj = new FirePHPCore_FirePHPTest__TestObject(); - $obj->child = $obj; - - $firephp->log($obj, "label", array("File"=>"/file/path", "Line"=>"1")); - $headers = $firephp->_getHeaders(); - $this->assertEquals('215|[{"File":"\/file\/path","Line":"1","Type":"LOG","Label":"label"},{"__className":"FirePHPCore_FirePHPTest__TestObject","public:var":"value","undeclared:child":"** Recursion (FirePHPCore_FirePHPTest__TestObject) **"}]|', $headers['X-Wf-1-1-1-1']); - } - - public function testOptions() - { - $firephp = new FirePHP_Test_Class(); - - // defaults - $this->assertEquals(5, $firephp->getOption("maxObjectDepth")); - $this->assertEquals(5, $firephp->getOption("maxArrayDepth")); - $this->assertEquals(true, $firephp->getOption("useNativeJsonEncode")); - $this->assertEquals(true, $firephp->getOption("includeLineNumbers")); - - // modify - $firephp->setOption("maxObjectDepth", 1); - $this->assertEquals(1, $firephp->getOption("maxObjectDepth")); - - // invalid - $caught = false; - try { - $firephp->setOption("invalidName", 1); - } catch(Exception $e) { - $caught = true; - } - if(!$caught) $this->fail('No exception thrown'); - - $caught = false; - try { - $firephp->getOption("invalidName"); - } catch(Exception $e) { - $caught = true; - } - if(!$caught) $this->fail('No exception thrown'); - } - - public function testDeprecatedMethods() - { - $firephp = new FirePHP_Test_Class(); - - $caught = false; - try { - $firephp->setProcessorUrl('URL'); - } catch(Exception $e) { - $caught = true; - $this->assertEquals(E_USER_DEPRECATED, $e->getCode()); - $this->assertEquals('The FirePHP::setProcessorUrl() method is no longer supported', $e->getMessage()); - } - if(!$caught) $this->fail('No deprecation error thrown'); - - $caught = false; - try { - $firephp->setRendererUrl('URL'); - } catch(Exception $e) { - $caught = true; - $this->assertEquals(E_USER_DEPRECATED, $e->getCode()); - $this->assertEquals('The FirePHP::setRendererUrl() method is no longer supported', $e->getMessage()); - } - if(!$caught) $this->fail('No deprecation error thrown'); - } - -} - - -class FirePHPCore_FirePHPTest__TestObject -{ - public $var = "value"; -} diff --git a/vendor/firephp/firephp-core/tests/TestHelper.php b/vendor/firephp/firephp-core/tests/TestHelper.php deleted file mode 100644 index bb65e7320..000000000 --- a/vendor/firephp/firephp-core/tests/TestHelper.php +++ /dev/null @@ -1,55 +0,0 @@ -_headers; - } - public function _clearHeaders() { - $this->_headers = array(); - } - - - // ###################### - // # Subclassed Methods # - // ###################### - - protected function setHeader($Name, $Value) { - $this->_headers[$Name] = $Value; - } - - protected function headersSent(&$Filename, &$Linenum) { - return false; - } - - public function detectClientExtension() { - return true; - } - -} diff --git a/vendor/firephp/firephp-core/tests/phpunit.xml b/vendor/firephp/firephp-core/tests/phpunit.xml deleted file mode 100644 index b0474e9d6..000000000 --- a/vendor/firephp/firephp-core/tests/phpunit.xml +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/vendor/firephp/firephp-core/workspace/README.md b/vendor/firephp/firephp-core/workspace/README.md deleted file mode 100644 index 999f09a94..000000000 --- a/vendor/firephp/firephp-core/workspace/README.md +++ /dev/null @@ -1,19 +0,0 @@ - -The [PINF JavaScript Loader](https://github.com/pinf/loader-js) is used to provide a development environment and package releases for this project. - -**NOTE:** It is assumed you have the _PINF JavaScript Loader_ mapped to the `commonjs` command and are using the `node` platform by default as explained [here](https://github.com/pinf/loader-js/blob/master/docs/Setup.md). - - -Publishing -========== - - git tag v... - - commonjs -v --script build . - - commonjs -v --script publish . - - -TODO: Auto-upload to PEAR channel server at http://pear.firephp.org/ - -NOTE: For PEAR RC releases: Change release stability to "beta" and capitalize "RC" in release version in package.xml diff --git a/vendor/firephp/firephp-core/workspace/lib/project.js b/vendor/firephp/firephp-core/workspace/lib/project.js deleted file mode 100644 index 913c6d7c6..000000000 --- a/vendor/firephp/firephp-core/workspace/lib/project.js +++ /dev/null @@ -1,5 +0,0 @@ - -exports.main = function(options) -{ - -} diff --git a/vendor/firephp/firephp-core/workspace/package.json b/vendor/firephp/firephp-core/workspace/package.json deleted file mode 100644 index 19e8385ee..000000000 --- a/vendor/firephp/firephp-core/workspace/package.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "name": "firephp-core", - "engine": [ - "node" - ], - "main": "lib/project.js", - "scripts": { - "build": { - "location": "./", - "module": "/scripts/build.js" - }, - "publish": { - "location": "./", - "module": "/scripts/publish.js" - } - }, - "mappings": { - "nodejs": { - "id": "nodejs.org/" - }, - "pinf": { - "id": "pinf.org/loader/" - }, - "modules": { - "id": "github.com/pinf/modules-js/" - } - } -} \ No newline at end of file diff --git a/vendor/firephp/firephp-core/workspace/program.json b/vendor/firephp/firephp-core/workspace/program.json deleted file mode 100644 index 9628b525c..000000000 --- a/vendor/firephp/firephp-core/workspace/program.json +++ /dev/null @@ -1,78 +0,0 @@ -{ - "boot": "workspace", - "engine": [ - "node" - ], - "packages": { - "workspace": { - "locator": { - "location": "./" - } - }, - "nodejs.org/": { - "provider": "nodejs.org/" - }, - "pinf.org/loader/": { - "provider": "pinf.org/loader/" - }, - "github.com/pinf/modules-js/": { - "locator": { - "archive": "https://github.com/pinf/modules-js/zipball/master" - } - }, - "github.com/kriskowal/q/": { - "locator": { - "archive": "https://github.com/kriskowal/q/zipball/v0.3.0" - }, - "descriptor": { - "uid": "https://github.com/kriskowal/q/", - "dependencies": [ - { - "id": "github.com/pinf/modules-js/" - } - ] - } - }, - "private-registry.appspot.com/cadorn.com/github/com.cadorn.baby/projects/sourcemint/packages/client-js/": { - "locator": { - "archive": "https://github.com/cadorn/com.cadorn.baby/zipball/master", - "path": "projects/sourcemint/packages/client-js" - } - }, - "github.com/cadorn/aws-lib/": { - "locator": { - "archive": "https://github.com/cadorn/aws-lib/zipball/master" - }, - "descriptor": { - "uid": "https://github.com/cadorn/aws-lib/", - "native": true, - "dependencies": [ - { - "id": "registry.npmjs.org/sax/" - }, - { - "id": "registry.npmjs.org/xml2js/" - } - ] - } - }, - "registry.npmjs.org/sax/": { - "locator": { - "archive": "http://registry.npmjs.org/sax/-/sax-0.1.2.tgz" - }, - "descriptor": { - "uid": "http://registry.npmjs.org/sax/", - "native": true - } - }, - "registry.npmjs.org/xml2js/": { - "locator": { - "archive": "http://registry.npmjs.org/xml2js/-/xml2js-0.1.6.tgz" - }, - "descriptor": { - "uid": "http://registry.npmjs.org/xml2js/", - "native": true - } - } - } -} \ No newline at end of file diff --git a/vendor/firephp/firephp-core/workspace/scripts/build.js b/vendor/firephp/firephp-core/workspace/scripts/build.js deleted file mode 100644 index 2481d99d3..000000000 --- a/vendor/firephp/firephp-core/workspace/scripts/build.js +++ /dev/null @@ -1,164 +0,0 @@ - -var FILE = require("modules/file"), - Q = require("modules/q"), - SYSTEM = require("modules/system"), - UTIL = require("modules/util"), - JSON = require("modules/json"); - - -var pkgPath = FILE.dirname(FILE.dirname(FILE.dirname(module.id))), - buildPath = pkgPath + "/build", - tplPath = pkgPath + "/workspace/tpl", - version = false; - -exports.getBuildPath = function() -{ - return buildPath; -} - -exports.main = function() -{ - - SYSTEM.exec("rm -Rf " + buildPath, function() - { - FILE.mkdirs(buildPath, 0775); - - SYSTEM.exec("git tag", function(stdout) - { - version = UTIL.trim(stdout).split("\n").pop().match(/^v(.*)$/)[1]; - - // TODO: Compare against version in `../../program.json ~ version` (ensure =) - - module.print("\0cyan(Building version: " + version + "\0)\n"); - - buildZipArchive(function() - { - buildPEARArchive(function() - { - done(); - }); - }); - }); - }); - - function done() - { - module.print("\0green(Done\0)\n"); - } -} - -function buildZipArchive(callback) -{ - var targetBasePath = buildPath + "/FirePHPCore-" + version; - - FILE.mkdirs(targetBasePath, 0775); - - SYSTEM.exec("rsync -r --copy-links --exclude \"- .DS_Store\" --exclude \"- .git/\" --exclude \"- .tmp_*\" " + pkgPath + "/lib " + targetBasePath, function() - { - replaceVariablesInFile(targetBasePath + "/lib/FirePHPCore/FirePHP.class.php"); - replaceVariablesInFile(targetBasePath + "/lib/FirePHPCore/FirePHP.class.php4"); - - SYSTEM.exec("cp -Rf " + pkgPath + "/examples " + targetBasePath, function() - { - next1(); - }); - }); - - function next1() - { - var content = FILE.read(tplPath + "/readme.tpl.md"); - content = content.replace(/%%VERSION%%/g, version); - FILE.write(targetBasePath + "/README.md", content); - - var content = FILE.read(tplPath + "/license.tpl.md"); - FILE.write(targetBasePath + "/LICENSE.md", content); - - FILE.write(buildPath + "/info.json", JSON.encode({ - version: version - })); - - next2(); - } - - function next2() - { - SYSTEM.exec("cd " + buildPath + " ; zip -vr FirePHPCore-" + version + ".zip FirePHPCore-" + version, function(stdout) - { - console.log(stdout); - - callback(); - }); - } -} - -function buildPEARArchive(callback) -{ - var targetBasePath = buildPath + "/pear"; - - FILE.mkdirs(targetBasePath, 0775); - - SYSTEM.exec("rsync -r --copy-links --exclude \"- .DS_Store\" --exclude \"- .git/\" --exclude \"- .tmp_*\" " + pkgPath + "/lib/FirePHPCore/* " + targetBasePath, function() - { - replaceVariablesInFile(targetBasePath + "/FirePHP.class.php"); - replaceVariablesInFile(targetBasePath + "/FirePHP.class.php4"); - - next1(); - }); - - function next1() - { - var content = FILE.read(tplPath + "/pear.package.tpl.xml"); - - var date = new Date(); - content = content.replace(/%%DATE%%/g, date.getFullYear() + "-" + UTIL.padBegin(date.getMonth()+1, 2, "0") + "-" + date.getDate()); - content = content.replace(/%%VERSION%%/g, version); - content = content.replace(/%%STABILITY%%/g, "stable"); - - FILE.write(targetBasePath + "/package.xml", content); - - next2(); - } - - function next2() - { - SYSTEM.exec("pear channel-discover pear.firephp.org", function(stdout) - { - console.log(stdout); - - SYSTEM.exec("cd " + targetBasePath + "; pear package package.xml", function(stdout) - { - console.log(stdout); - - callback(); - }); - }); - } -} - -function replaceVariablesInFile(path) -{ - var content = FILE.read(path); - - // @pinf replace '0.3' with '%%VERSION%%' - var re1 = /\n(.*)\/\/\s*@pinf\s(.*)\n/g; - var match1; - while (match1 = re1.exec(content)) { - var rule = match1[2].match(/^replace (.*?) with (.*)$/); - if(rule) { - // replace variables in rule - var re2 = /%%([^%]*)%%/g; - var match2; - while (match2 = re2.exec(rule[2])) { - var value; - if(match2[1]=="VERSION") { - value = version; - } - rule[2] = rule[2].replace(match2[0], value); - } - match1[1] = match1[1].replace(rule[1], rule[2]); - content = content.replace(match1[0], "\n"+match1[1]+"\n"); - } - } - - FILE.write(path, content); -} diff --git a/vendor/firephp/firephp-core/workspace/scripts/publish.js b/vendor/firephp/firephp-core/workspace/scripts/publish.js deleted file mode 100644 index 39106e1b3..000000000 --- a/vendor/firephp/firephp-core/workspace/scripts/publish.js +++ /dev/null @@ -1,65 +0,0 @@ - -var PINF_LOADER = require("pinf/loader"), - SANDBOX = PINF_LOADER.getSandbox(), - FILE = require("modules/file"), - Q = require("modules/q"), - SYSTEM = require("modules/system"), - BUILD = require("./build"), - JSON = require("modules/json"), - SOURCEMINT_CLIENT = false; - -exports.main = function() -{ - module.load({ - id: "private-registry.appspot.com/cadorn.com/github/com.cadorn.baby/projects/sourcemint/packages/client-js/", - descriptor: { - main: "lib/client.js" - } - }, function(id) - { - SOURCEMINT_CLIENT = require(id); - - publish(); - }); -} - -function publish() -{ - var buildPath = BUILD.getBuildPath(), - info = JSON.decode(FILE.read(buildPath + "/info.json")), - descriptor = JSON.decode(FILE.read(FILE.dirname(FILE.dirname(FILE.dirname(module.id))) + "/package.json")); - - var bundles = {}; - bundles["firephp-core.zip"] = { - "type": "zip", - "options": { - "archivePath": buildPath + "/FirePHPCore-" + info.version + ".zip", - } - }; - - var packages = [ - { - "uid": descriptor.uid, - "stream": "stable", - "version": info.version, - "bundles": bundles - } - ]; - - try - { - Q.when(SOURCEMINT_CLIENT.publish(packages), function(info) - { - module.print("\0green(Published:\n"); - console.log(info); - module.print("\0)"); - }, function(e) - { - throw e; - }); - } - catch(e) - { - console.error("Error: " + e); - } -} diff --git a/vendor/firephp/firephp-core/workspace/tpl/license.tpl.md b/vendor/firephp/firephp-core/workspace/tpl/license.tpl.md deleted file mode 100644 index 1b0aaf269..000000000 --- a/vendor/firephp/firephp-core/workspace/tpl/license.tpl.md +++ /dev/null @@ -1,21 +0,0 @@ -[MIT License](http://www.opensource.org/licenses/mit-license.php) - -Copyright (c) 2007+ [Christoph Dorn](http://www.christophdorn.com/) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. \ No newline at end of file diff --git a/vendor/firephp/firephp-core/workspace/tpl/pear.package.tpl.xml b/vendor/firephp/firephp-core/workspace/tpl/pear.package.tpl.xml deleted file mode 100644 index b9f3d65a4..000000000 --- a/vendor/firephp/firephp-core/workspace/tpl/pear.package.tpl.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - - FirePHPCore - pear.firephp.org - Log variables from PHP to the browser (Firebug Console) - Handles all communication between the PHP code on the server and the client. Also implements all core FirePHP features. - - - Christoph Dorn - cadorn - christoph@christophdorn.com - yes - - - %%DATE%% - - %%VERSION%% - 0.3 - - - - %%STABILITY%% - stable - - - MIT - - No Notes - - - - - - - - - - - - - - - - - 4.0 - - - 1.4.5 - - - - - - - diff --git a/vendor/firephp/firephp-core/workspace/tpl/readme.tpl.md b/vendor/firephp/firephp-core/workspace/tpl/readme.tpl.md deleted file mode 100644 index 01264662e..000000000 --- a/vendor/firephp/firephp-core/workspace/tpl/readme.tpl.md +++ /dev/null @@ -1,17 +0,0 @@ -FirePHPCore Server Library -========================== - -Status: stable - -Version: [%%VERSION%%](https://github.com/firephp/firephp-core/tree/v%%VERSION%%) - -This archive contains the *FirePHPCore* PHP server library. - -Links ------ - - * Documentation: http://docs.sourcemint.org/firephp.org/firephp/1/-docs/ - * Install: http://docs.sourcemint.org/firephp.org/firephp/1/-docs/Configuration/Traditional - * Support: http://docs.sourcemint.org/firephp.org/firephp/1/-docs/OpenSource#support - * Author: [Christoph Dorn](http://www.christophdorn.com/) - * License: [MIT License](http://www.opensource.org/licenses/mit-license.php) diff --git a/vendor/leafo/scssphp/bin/pscss b/vendor/leafo/scssphp/bin/pscss index f4b7ba8f1..3175ea0b6 100755 --- a/vendor/leafo/scssphp/bin/pscss +++ b/vendor/leafo/scssphp/bin/pscss @@ -12,8 +12,8 @@ error_reporting(E_ALL); -if (version_compare(PHP_VERSION, '5.3') < 0) { - die('Requires PHP 5.3 or above'); +if (version_compare(PHP_VERSION, '5.4') < 0) { + die('Requires PHP 5.4 or above'); } include __DIR__ . '/../scss.inc.php'; @@ -30,6 +30,8 @@ $inputFile = null; $changeDir = false; $debugInfo = false; $lineNumbers = false; +$ignoreErrors = false; +$encoding = false; /** * Parse argument @@ -67,14 +69,16 @@ Usage: $exe [options] [input-file] Options include: - --debug-info Annotate selectors with CSS referring to the source file and line number - -h, --help Show this message - -f=format Set the output format (compact, compressed, crunched, expanded, or nested) - -i=path Set import path - --line-numbers Annotate selectors with comments referring to the source file and line number - -p=precision Set decimal number precision (default 5) - -T Dump formatted parse tree - -v, --version Print the version + -h, --help Show this message + --continue-on-error Continue compilation (as best as possible) when error encountered + --debug-info Annotate selectors with CSS referring to the source file and line number + -f=format Set the output format (compact, compressed, crunched, expanded, or nested) + -i=path Set import path + --iso8859-1 Use iso8859-1 encoding instead of utf-8 (default utf-8) + --line-numbers Annotate selectors with comments referring to the source file and line number + -p=precision Set decimal number precision (default 5) + -T Dump formatted parse tree + -v, --version Print the version EOT; exit($HELP); @@ -84,11 +88,21 @@ EOT; exit(Version::VERSION . "\n"); } + if ($argv[$i] === '--continue-on-error') { + $ignoreErrors = true; + continue; + } + if ($argv[$i] === '--debug-info') { $debugInfo = true; continue; } + if ($argv[$i] === '--iso8859-1') { + $encoding = 'iso8859-1'; + continue; + } + if ($argv[$i] === '--line-numbers' || $argv[$i] === '--line-comments') { $lineNumbers = true; continue; @@ -163,6 +177,10 @@ if ($lineNumbers && $inputFile) { $scss->setLineNumberStyle(Compiler::LINE_COMMENTS); } +if ($ignoreErrors) { + $scss->setIgnoreErrors($ignoreErrors); +} + if ($loadPaths) { $scss->setImportPaths(explode(PATH_SEPARATOR, $loadPaths)); } @@ -175,6 +193,10 @@ if ($style) { $scss->setFormatter('Leafo\\ScssPhp\\Formatter\\' . ucfirst($style)); } +if ($encoding) { + $scss->setEncoding($encoding); +} + echo $scss->compile($data, $inputFile); if ($changeDir) { diff --git a/vendor/leafo/scssphp/classmap.php b/vendor/leafo/scssphp/classmap.php deleted file mode 100644 index 2d8a52b8e..000000000 --- a/vendor/leafo/scssphp/classmap.php +++ /dev/null @@ -1,63 +0,0 @@ -=5.3.0" + "php": ">=5.4.0" }, "require-dev": { - "squizlabs/php_codesniffer": "~2.3", + "squizlabs/php_codesniffer": "~2.5", "phpunit/phpunit": "~3.7", "kherge/box": "~2.5" }, diff --git a/vendor/leafo/scssphp/scss.inc.php b/vendor/leafo/scssphp/scss.inc.php index d28711552..b6892fec4 100644 --- a/vendor/leafo/scssphp/scss.inc.php +++ b/vendor/leafo/scssphp/scss.inc.php @@ -1,6 +1,6 @@ */ diff --git a/vendor/leafo/scssphp/src/Block.php b/vendor/leafo/scssphp/src/Block.php index 16f4a9683..6b972a1b9 100644 --- a/vendor/leafo/scssphp/src/Block.php +++ b/vendor/leafo/scssphp/src/Block.php @@ -12,7 +12,7 @@ namespace Leafo\ScssPhp; /** - * SCSS block + * Block * * @author Anthon Pang */ @@ -31,12 +31,17 @@ class Block /** * @var integer */ - public $sourcePosition; + public $sourceIndex; /** * @var integer */ - public $sourceIndex; + public $sourceLine; + + /** + * @var integer + */ + public $sourceColumn; /** * @var array diff --git a/vendor/leafo/scssphp/src/Colors.php b/vendor/leafo/scssphp/src/Colors.php index 0227fbe0f..ff48c199e 100644 --- a/vendor/leafo/scssphp/src/Colors.php +++ b/vendor/leafo/scssphp/src/Colors.php @@ -25,7 +25,7 @@ class Colors * * @var array */ - public static $cssColors = array( + public static $cssColors = [ 'aliceblue' => '240,248,255', 'antiquewhite' => '250,235,215', 'aqua' => '0,255,255', @@ -145,6 +145,7 @@ class Colors 'plum' => '221,160,221', 'powderblue' => '176,224,230', 'purple' => '128,0,128', + 'rebeccapurple' => '102,51,153', 'red' => '255,0,0', 'rosybrown' => '188,143,143', 'royalblue' => '65,105,225', @@ -173,6 +174,6 @@ class Colors 'white' => '255,255,255', 'whitesmoke' => '245,245,245', 'yellow' => '255,255,0', - 'yellowgreen' => '154,205,50' - ); + 'yellowgreen' => '154,205,50', + ]; } diff --git a/vendor/leafo/scssphp/src/Compiler.php b/vendor/leafo/scssphp/src/Compiler.php index 7cf114650..b19b9e56f 100644 --- a/vendor/leafo/scssphp/src/Compiler.php +++ b/vendor/leafo/scssphp/src/Compiler.php @@ -15,6 +15,7 @@ use Leafo\ScssPhp\Base\Range; use Leafo\ScssPhp\Block; use Leafo\ScssPhp\Colors; use Leafo\ScssPhp\Compiler\Environment; +use Leafo\ScssPhp\Exception\CompilerException; use Leafo\ScssPhp\Formatter\OutputBlock; use Leafo\ScssPhp\Node; use Leafo\ScssPhp\Type; @@ -66,7 +67,7 @@ class Compiler /** * @var array */ - static protected $operatorNames = array( + static protected $operatorNames = [ '+' => 'add', '-' => 'sub', '*' => 'mul', @@ -81,39 +82,42 @@ class Compiler '<=' => 'lte', '>=' => 'gte', '<=>' => 'cmp', - ); + ]; /** * @var array */ - static protected $namespaces = array( + static protected $namespaces = [ 'special' => '%', 'mixin' => '@', 'function' => '^', - ); + ]; - static public $true = array(Type::T_KEYWORD, 'true'); - static public $false = array(Type::T_KEYWORD, 'false'); - static public $null = array(Type::T_NULL); - static public $defaultValue = array(Type::T_KEYWORD, ''); - static public $selfSelector = array(Type::T_SELF); - static public $emptyList = array(Type::T_LIST, '', array()); - static public $emptyMap = array(Type::T_MAP, array(), array()); - static public $emptyString = array(Type::T_STRING, '"', array()); - static public $with = array(Type::T_KEYWORD, 'with'); - static public $without = array(Type::T_KEYWORD, 'without'); + static public $true = [Type::T_KEYWORD, 'true']; + static public $false = [Type::T_KEYWORD, 'false']; + static public $null = [Type::T_NULL]; + static public $nullString = [Type::T_STRING, '', []]; + static public $defaultValue = [Type::T_KEYWORD, '']; + static public $selfSelector = [Type::T_SELF]; + static public $emptyList = [Type::T_LIST, '', []]; + static public $emptyMap = [Type::T_MAP, [], []]; + static public $emptyString = [Type::T_STRING, '"', []]; + static public $with = [Type::T_KEYWORD, 'with']; + static public $without = [Type::T_KEYWORD, 'without']; - protected $importPaths = array(''); - protected $importCache = array(); - protected $userFunctions = array(); - protected $registeredVars = array(); - protected $registeredFeatures = array( + protected $importPaths = ['']; + protected $importCache = []; + protected $importedFiles = []; + protected $userFunctions = []; + protected $registeredVars = []; + protected $registeredFeatures = [ 'extend-selector-pseudoclass' => false, 'at-error' => true, 'units-level-3' => false, 'global-variable-shadowing' => false, - ); + ]; + protected $encoding = null; protected $lineNumberStyle = null; protected $formatter = 'Leafo\ScssPhp\Formatter\Nested'; @@ -129,13 +133,24 @@ class Compiler private $env; private $scope; private $parser; - private $sourcePos; - private $sourceParsers; + private $sourceNames; private $sourceIndex; + private $sourceLine; + private $sourceColumn; private $storeEnv; private $charsetSeen; private $stderr; private $shouldEvaluate; + private $ignoreErrors; + + /** + * Constructor + */ + public function __construct() + { + $this->parsedFiles = []; + $this->sourceNames = []; + } /** * Compile scss @@ -152,24 +167,28 @@ class Compiler $locale = setlocale(LC_NUMERIC, 0); setlocale(LC_NUMERIC, 'C'); - $this->indentLevel = -1; - $this->commentsSeen = array(); - $this->extends = array(); - $this->extendsMap = array(); - $this->parsedFiles = array(); - $this->sourceParsers = array(); - $this->sourceIndex = null; - $this->env = null; - $this->scope = null; - $this->storeEnv = null; - $this->stderr = fopen('php://stderr', 'w'); + $this->indentLevel = -1; + $this->commentsSeen = []; + $this->extends = []; + $this->extendsMap = []; + $this->sourceIndex = null; + $this->sourceLine = null; + $this->sourceColumn = null; + $this->env = null; + $this->scope = null; + $this->storeEnv = null; + $this->charsetSeen = null; + $this->shouldEvaluate = null; + $this->stderr = fopen('php://stderr', 'w'); $this->parser = $this->parserFactory($path); $tree = $this->parser->parse($code); + $this->parser = null; $this->formatter = new $this->formatter(); + $this->rootBlock = null; + $this->rootEnv = $this->pushEnv($tree); - $this->rootEnv = $this->pushEnv($tree); $this->injectVariables($this->registeredVars); $this->compileRoot($tree); $this->popEnv(); @@ -190,9 +209,9 @@ class Compiler */ private function parserFactory($path) { - $parser = new Parser($path, count($this->sourceParsers)); + $parser = new Parser($path, count($this->sourceNames), $this->encoding); - $this->sourceParsers[] = $parser; + $this->sourceNames[] = $path; $this->addParsedFile($path); return $parser; @@ -220,23 +239,24 @@ class Compiler /** * Push extends * - * @param array $target - * @param array $origin + * @param array $target + * @param array $origin + * @param \stdClass $block */ - protected function pushExtends($target, $origin) + protected function pushExtends($target, $origin, $block) { if ($this->isSelfExtend($target, $origin)) { return; } $i = count($this->extends); - $this->extends[] = array($target, $origin); + $this->extends[] = [$target, $origin, $block]; foreach ($target as $part) { if (isset($this->extendsMap[$part])) { $this->extendsMap[$part][] = $i; } else { - $this->extendsMap[$part] = array($i); + $this->extendsMap[$part] = [$i]; } } } @@ -253,8 +273,8 @@ class Compiler { $out = new OutputBlock; $out->type = $type; - $out->lines = array(); - $out->children = array(); + $out->lines = []; + $out->children = []; $out->parent = $this->scope; $out->selectors = $selectors; $out->depth = $this->env->depth; @@ -273,6 +293,32 @@ class Compiler $this->compileChildrenNoReturn($rootBlock->children, $this->scope); $this->flattenSelectors($this->scope); + $this->missingSelectors(); + } + + /** + * Report missing selectors + */ + protected function missingSelectors() + { + foreach ($this->extends as $extend) { + if (isset($extend[3])) { + continue; + } + + list($target, $origin, $block) = $extend; + + // ignore if !optional + if ($block[2]) { + continue; + } + + $target = implode(' ', $target); + $origin = $this->collapseSelectors($origin); + + $this->sourceLine = $block[Parser::SOURCE_LINE]; + $this->throwError("\"$origin\" failed to @extend \"$target\". The selector \"$target\" was not found."); + } } /** @@ -284,7 +330,7 @@ class Compiler protected function flattenSelectors(OutputBlock $block, $parentKey = null) { if ($block->selectors) { - $selectors = array(); + $selectors = []; foreach ($block->selectors as $s) { $selectors[] = $s; @@ -310,7 +356,7 @@ class Compiler } } - $block->selectors = array(); + $block->selectors = []; $placeholderSelector = false; foreach ($selectors as $selector) { @@ -405,8 +451,8 @@ class Compiler */ protected function matchExtendsSingle($rawSingle, &$outOrigin) { - $counts = array(); - $single = array(); + $counts = []; + $single = []; foreach ($rawSingle as $part) { // matches Number @@ -429,17 +475,19 @@ class Compiler } } - $outOrigin = array(); + $outOrigin = []; $found = false; foreach ($counts as $idx => $count) { - list($target, $origin) = $this->extends[$idx]; + list($target, $origin, /* $block */) = $this->extends[$idx]; // check count if ($count !== count($target)) { continue; } + $this->extends[$idx][3] = true; + $rem = array_diff($single, $target); foreach ($origin as $j => $new) { @@ -448,7 +496,11 @@ class Compiler return false; } - $origin[$j][count($origin[$j]) - 1] = $this->combineSelectorSingle(end($new), $rem); + $combined = $this->combineSelectorSingle(end($new), $rem); + + if (count(array_diff($combined, $origin[$j][count($origin[$j]) - 1]))) { + $origin[$j][count($origin[$j]) - 1] = $combined; + } } $outOrigin = array_merge($outOrigin, $origin); @@ -469,21 +521,28 @@ class Compiler */ protected function combineSelectorSingle($base, $other) { - $tag = null; - $out = array(); + $tag = []; + $out = []; + $wasTag = true; - foreach (array($base, $other) as $single) { + foreach ([$base, $other] as $single) { foreach ($single as $part) { - if (preg_match('/^[^\[.#:]/', $part)) { - $tag = $part; - } else { + if (preg_match('/^[\[.:#]/', $part)) { $out[] = $part; + $wasTag = false; + } elseif (preg_match('/^[^_-]/', $part)) { + $tag[] = $part; + $wasTag = true; + } elseif ($wasTag) { + $tag[count($tag) - 1] .= $part; + } else { + $out[count($out) - 1] .= $part; } } } - if ($tag) { - array_unshift($out, $tag); + if (count($tag)) { + array_unshift($out, $tag[0]); } return $out; @@ -501,7 +560,7 @@ class Compiler $mediaQuery = $this->compileMediaQuery($this->multiplyMedia($this->env)); if (! empty($mediaQuery)) { - $this->scope = $this->makeOutputBlock(Type::T_MEDIA, array($mediaQuery)); + $this->scope = $this->makeOutputBlock(Type::T_MEDIA, [$mediaQuery]); $parentScope = $this->mediaParent($this->scope); $parentScope->children[] = $this->scope; @@ -524,10 +583,15 @@ class Compiler if ($needsWrap) { $wrapped = new Block; - $wrapped->selectors = array(); - $wrapped->children = $media->children; + $wrapped->sourceIndex = $media->sourceIndex; + $wrapped->sourceLine = $media->sourceLine; + $wrapped->sourceColumn = $media->sourceColumn; + $wrapped->selectors = []; + $wrapped->comments = []; + $wrapped->parent = $media; + $wrapped->children = $media->children; - $media->children = array(array(Type::T_BLOCK, $wrapped)); + $media->children = [[Type::T_BLOCK, $wrapped]]; } $this->compileChildrenNoReturn($media->children, $this->scope); @@ -572,9 +636,9 @@ class Compiler } if ($block->name === 'keyframes' || substr($block->name, -10) === '-keyframes') { - $this->compileKeyframeBlock($block, array($s)); + $this->compileKeyframeBlock($block, [$s]); } else { - $this->compileNestedBlock($block, array($s)); + $this->compileNestedBlock($block, [$s]); } } @@ -592,14 +656,15 @@ class Compiler // wrap inline selector if ($block->selector) { $wrapped = new Block; - $wrapped->parent = $block; - $wrapped->sourcePosition = $block->sourcePosition; - $wrapped->sourceIndex = $block->sourceIndex; - $wrapped->selectors = $block->selector; - $wrapped->comments = array(); - $wrapped->children = $block->children; + $wrapped->sourceIndex = $block->sourceIndex; + $wrapped->sourceLine = $block->sourceLine; + $wrapped->sourceColumn = $block->sourceColumn; + $wrapped->selectors = $block->selector; + $wrapped->comments = []; + $wrapped->parent = $block; + $wrapped->children = $block->children; - $block->children = array(array(Type::T_BLOCK, $wrapped)); + $block->children = [[Type::T_BLOCK, $wrapped]]; } $this->env = $this->filterWithout($envs, $without); @@ -634,7 +699,7 @@ class Compiler continue; } - if (isset($e->block) && $e->block === $block) { + if ($e->block === $block) { continue; } @@ -642,37 +707,32 @@ class Compiler continue; } - if (($without & self::WITH_RULE) && isset($e->block->selectors)) { - continue; - } - - if (($without & self::WITH_MEDIA) && - isset($e->block->type) && $e->block->type === Type::T_MEDIA - ) { - continue; - } - - if (($without & self::WITH_SUPPORTS) && - isset($e->block->type) && $e->block->type === Type::T_DIRECTIVE && - isset($e->block->name) && $e->block->name === 'supports' - ) { + if ($e->block && $this->isWithout($without, $e->block)) { continue; } $b = new Block; + $b->sourceIndex = $e->block->sourceIndex; + $b->sourceLine = $e->block->sourceLine; + $b->sourceColumn = $e->block->sourceColumn; + $b->selectors = []; + $b->comments = $e->block->comments; + $b->parent = null; - if (isset($e->block->sourcePosition)) { - $b->sourcePosition = $e->block->sourcePosition; - } + if ($newBlock) { + $type = isset($newBlock->type) ? $newBlock->type : Type::T_BLOCK; - if (isset($e->block->sourceIndex)) { - $b->sourceIndex = $e->block->sourceIndex; - } + $b->children = [[$type, $newBlock]]; - $b->selectors = array(); + $newBlock->parent = $b; + } elseif (count($block->children)) { + foreach ($block->children as $child) { + if ($child[0] === Type::T_BLOCK) { + $child[1]->parent = $b; + } + } - if (isset($e->block->comments)) { - $b->comments = $e->block->comments; + $b->children = $block->children; } if (isset($e->block->type)) { @@ -691,30 +751,12 @@ class Compiler $b->value = $e->block->value; } - if ($newBlock) { - $type = isset($newBlock->type) ? $newBlock->type : Type::T_BLOCK; - - $b->children = array(array($type, $newBlock)); - - $newBlock->parent = $b; - } elseif (count($block->children)) { - foreach ($block->children as $child) { - if ($child[0] === Type::T_BLOCK) { - $child[1]->parent = $b; - } - } - - $b->children = $block->children; - } - - $b->parent = null; - $newBlock = $b; } $type = isset($newBlock->type) ? $newBlock->type : Type::T_BLOCK; - return array($type, $newBlock); + return [$type, $newBlock]; } /** @@ -726,20 +768,20 @@ class Compiler */ private function compileWith($with) { - static $mapping = array( + static $mapping = [ 'rule' => self::WITH_RULE, 'media' => self::WITH_MEDIA, 'supports' => self::WITH_SUPPORTS, 'all' => self::WITH_ALL, - ); + ]; // exclude selectors by default $without = self::WITH_RULE; - if ($this->libMapHasKey(array($with, self::$with))) { + if ($this->libMapHasKey([$with, self::$with])) { $without = self::WITH_ALL; - $list = $this->coerceList($this->libMapGet(array($with, self::$with))); + $list = $this->coerceList($this->libMapGet([$with, self::$with])); foreach ($list[2] as $item) { $keyword = $this->compileStringContent($this->coerceString($item)); @@ -750,10 +792,10 @@ class Compiler } } - if ($this->libMapHasKey(array($with, self::$without))) { + if ($this->libMapHasKey([$with, self::$without])) { $without = 0; - $list = $this->coerceList($this->libMapGet(array($with, self::$without))); + $list = $this->coerceList($this->libMapGet([$with, self::$without])); foreach ($list[2] as $item) { $keyword = $this->compileStringContent($this->coerceString($item)); @@ -777,23 +819,10 @@ class Compiler */ private function filterWithout($envs, $without) { - $filtered = array(); + $filtered = []; foreach ($envs as $e) { - if (($without & self::WITH_RULE) && isset($e->block->selectors)) { - continue; - } - - if (($without & self::WITH_MEDIA) && - isset($e->block->type) && $e->block->type === Type::T_MEDIA - ) { - continue; - } - - if (($without & self::WITH_SUPPORTS) && - isset($e->block->type) && $e->block->type === Type::T_DIRECTIVE && - isset($e->block->name) && $e->block->name === 'supports' - ) { + if ($e->block && $this->isWithout($without, $e->block)) { continue; } @@ -803,6 +832,29 @@ class Compiler return $this->extractEnv($filtered); } + /** + * Filter WITH rules + * + * @param integer $without + * @param \Leafo\ScssPhp\Block $block + * + * @return boolean + */ + private function isWithout($without, Block $block) + { + if ((($without & self::WITH_RULE) && isset($block->selectors)) || + (($without & self::WITH_MEDIA) && + isset($block->type) && $block->type === Type::T_MEDIA) || + (($without & self::WITH_SUPPORTS) && + isset($block->type) && $block->type === Type::T_DIRECTIVE && + isset($block->name) && $block->name === 'supports') + ) { + return true; + } + + return false; + } + /** * Compile keyframe block * @@ -815,7 +867,7 @@ class Compiler $envs = $this->compactEnv($env); - $this->env = $this->extractEnv(array_filter($envs, function ($e) { + $this->env = $this->extractEnv(array_filter($envs, function (Environment $e) { return ! isset($e->block->selectors); })); @@ -880,9 +932,8 @@ class Compiler $annotation = $this->makeOutputBlock(Type::T_COMMENT); $annotation->depth = 0; - $parser = $this->sourceParsers[$block->sourceIndex]; - $file = $parser->getSourceName(); - $line = $parser->getLineNo($block->sourcePosition); + $file = $this->sourceNames[$block->sourceIndex]; + $line = $block->sourceLine; switch ($this->lineNumberStyle) { case self::LINE_COMMENTS: @@ -934,7 +985,7 @@ class Compiler { $this->shouldEvaluate = false; - $selectors = array_map(array($this, 'evalSelector'), $selectors); + $selectors = array_map([$this, 'evalSelector'], $selectors); // after evaluating interpolates, we might need a second pass if ($this->shouldEvaluate) { @@ -942,7 +993,7 @@ class Compiler $parser = $this->parserFactory(__METHOD__); if ($parser->parseSelector($buffer, $newSelectors)) { - $selectors = array_map(array($this, 'evalSelector'), $newSelectors); + $selectors = array_map([$this, 'evalSelector'], $newSelectors); } } @@ -958,7 +1009,7 @@ class Compiler */ protected function evalSelector($selector) { - return array_map(array($this, 'evalSelectorPart'), $selector); + return array_map([$this, 'evalSelectorPart'], $selector); } /** @@ -998,7 +1049,7 @@ class Compiler */ protected function collapseSelectors($selectors) { - $parts = array(); + $parts = []; foreach ($selectors as $selector) { $output = ''; @@ -1025,7 +1076,7 @@ class Compiler */ protected function flattenSelectorSingle($single) { - $joined = array(); + $joined = []; foreach ($single as $part) { if (empty($joined) || @@ -1062,7 +1113,7 @@ class Compiler return implode( ' ', array_map( - array($this, 'compileSelectorPart'), + [$this, 'compileSelectorPart'], $selector ) ); @@ -1111,7 +1162,7 @@ class Compiler foreach ($selector as $parts) { foreach ($parts as $part) { - if ('%' === $part[0]) { + if (strlen($part) && '%' === $part[0]) { return true; } } @@ -1154,6 +1205,8 @@ class Compiler if (isset($ret)) { $this->throwError('@return may only be used within a function'); + + return; } } } @@ -1172,7 +1225,7 @@ class Compiler foreach ($queryList as $query) { $type = null; - $parts = array(); + $parts = []; foreach ($query as $q) { switch ($q[0]) { @@ -1180,14 +1233,14 @@ class Compiler if ($type) { $type = $this->mergeMediaTypes( $type, - array_map(array($this, 'compileValue'), array_slice($q, 1)) + array_map([$this, 'compileValue'], array_slice($q, 1)) ); if (empty($type)) { // merge failed return null; } } else { - $type = array_map(array($this, 'compileValue'), array_slice($q, 1)); + $type = array_map([$this, 'compileValue'], array_slice($q, 1)); } break; @@ -1273,10 +1326,10 @@ class Compiler return null; } - return array( + return [ $m1 === Type::T_NOT ? $m2 : $m1, $m1 === Type::T_NOT ? $t2 : $t1, - ); + ]; } if ($m1 === Type::T_NOT && $m2 === Type::T_NOT) { @@ -1285,7 +1338,7 @@ class Compiler return null; } - return array(Type::T_NOT, $t1); + return [Type::T_NOT, $t1]; } if ($t1 !== $t2) { @@ -1293,24 +1346,28 @@ class Compiler } // t1 == t2, neither m1 nor m2 are "not" - return array(empty($m1)? $m2 : $m1, $t1); + return [empty($m1)? $m2 : $m1, $t1]; } /** * Compile import; returns true if the value was something that could be imported * - * @param array $rawPath - * @param array $out + * @param array $rawPath + * @param array $out + * @param boolean $once * * @return boolean */ - protected function compileImport($rawPath, $out) + protected function compileImport($rawPath, $out, $once = false) { if ($rawPath[0] === Type::T_STRING) { $path = $this->compileStringContent($rawPath); if ($path = $this->findImport($path)) { - $this->importFile($path, $out); + if (! $once || ! in_array($path, $this->importedFiles)) { + $this->importFile($path, $out); + $this->importedFiles[] = $path; + } return true; } @@ -1350,10 +1407,21 @@ class Compiler */ protected function compileChild($child, OutputBlock $out) { - $this->sourceIndex = isset($child[Parser::SOURCE_INDEX]) ? $child[Parser::SOURCE_INDEX] : null; - $this->sourcePos = isset($child[Parser::SOURCE_POSITION]) ? $child[Parser::SOURCE_POSITION] : -1; + $this->sourceIndex = isset($child[Parser::SOURCE_INDEX]) ? $child[Parser::SOURCE_INDEX] : null; + $this->sourceLine = isset($child[Parser::SOURCE_LINE]) ? $child[Parser::SOURCE_LINE] : -1; + $this->sourceColumn = isset($child[Parser::SOURCE_COLUMN]) ? $child[Parser::SOURCE_COLUMN] : -1; switch ($child[0]) { + case Type::T_SCSSPHP_IMPORT_ONCE: + list(, $rawPath) = $child; + + $rawPath = $this->reduce($rawPath); + + if (! $this->compileImport($rawPath, $out, true)) { + $out->lines[] = '@import ' . $this->compileValue($rawPath) . ';'; + } + break; + case Type::T_IMPORT: list(, $rawPath) = $child; @@ -1431,7 +1499,7 @@ class Compiler if ($value[0] !== Type::T_NULL) { $value = $this->reduce($value); - if ($value[0] === Type::T_NULL) { + if ($value[0] === Type::T_NULL || $value === self::$nullString) { break; } } @@ -1464,13 +1532,13 @@ class Compiler list(, $selectors) = $child; foreach ($selectors as $sel) { - $results = $this->evalSelectors(array($sel)); + $results = $this->evalSelectors([$sel]); foreach ($results as $result) { // only use the first one $result = current($result); - $this->pushExtends($result, $out->selectors); + $this->pushExtends($result, $out->selectors, $child); } } break; @@ -1579,10 +1647,10 @@ class Compiler break; case Type::T_BREAK: - return array(Type::T_CONTROL, true); + return [Type::T_CONTROL, true]; case Type::T_CONTINUE: - return array(Type::T_CONTROL, false); + return [Type::T_CONTROL, false]; case Type::T_RETURN: return $this->reduce($child[1], true); @@ -1590,16 +1658,18 @@ class Compiler case Type::T_NESTED_PROPERTY: list(, $prop) = $child; - $prefixed = array(); + $prefixed = []; $prefix = $this->compileValue($prop->prefix) . '-'; foreach ($prop->children as $child) { - if ($child[0] === Type::T_ASSIGN) { - array_unshift($child[1][2], $prefix); - } + switch ($child[0]) { + case Type::T_ASSIGN: + array_unshift($child[1][2], $prefix); + break; - if ($child[0] === Type::T_NESTED_PROPERTY) { - array_unshift($child[1]->prefix[2], $prefix); + case Type::T_NESTED_PROPERTY: + array_unshift($child[1]->prefix[2], $prefix); + break; } $prefixed[] = $child; @@ -1616,6 +1686,7 @@ class Compiler if (! $mixin) { $this->throwError("Undefined mixin $name"); + break; } $callingScope = $this->getStoreEnv(); @@ -1627,7 +1698,7 @@ class Compiler if (isset($content)) { $content->scope = $callingScope; - $this->setRaw(self::$namespaces['special'] . 'content', $content, $this->getStoreEnv()); + $this->setRaw(self::$namespaces['special'] . 'content', $content, $this->env); } if (isset($mixin->args)) { @@ -1642,13 +1713,11 @@ class Compiler break; case Type::T_MIXIN_CONTENT: - $content = $this->get(self::$namespaces['special'] . 'content', false, $this->getStoreEnv()); + $content = $this->get(self::$namespaces['special'] . 'content', false, $this->getStoreEnv()) + ?: $this->get(self::$namespaces['special'] . 'content', false, $this->env); if (! $content) { $this->throwError('Expected @content inside of mixin'); - } - - if (! isset($content->children)) { break; } @@ -1663,7 +1732,7 @@ class Compiler case Type::T_DEBUG: list(, $value) = $child; - $line = $this->parser->getLineNo($this->sourcePos); + $line = $this->sourceLine; $value = $this->compileValue($this->reduce($value, true)); fwrite($this->stderr, "Line $line DEBUG: $value\n"); break; @@ -1671,7 +1740,7 @@ class Compiler case Type::T_WARN: list(, $value) = $child; - $line = $this->parser->getLineNo($this->sourcePos); + $line = $this->sourceLine; $value = $this->compileValue($this->reduce($value, true)); echo "Line $line WARN: $value\n"; break; @@ -1679,7 +1748,7 @@ class Compiler case Type::T_ERROR: list(, $value) = $child; - $line = $this->parser->getLineNo($this->sourcePos); + $line = $this->sourceLine; $value = $this->compileValue($this->reduce($value, true)); $this->throwError("Line $line ERROR: $value\n"); break; @@ -1702,9 +1771,9 @@ class Compiler */ protected function expToString($exp) { - list(, $op, $left, $right, $inParens, $whiteLeft, $whiteRight) = $exp; + list(, $op, $left, $right, /* $inParens */, $whiteLeft, $whiteRight) = $exp; - $content = array($this->reduce($left)); + $content = [$this->reduce($left)]; if ($whiteLeft) { $content[] = ' '; @@ -1718,7 +1787,7 @@ class Compiler $content[] = $this->reduce($right); - return array(Type::T_STRING, '', $content); + return [Type::T_STRING, '', $content]; } /** @@ -1806,52 +1875,50 @@ class Compiler // 3. op[op name] $fn = "op${ucOpName}${ucLType}${ucRType}"; - if (is_callable(array($this, $fn)) || + if (is_callable([$this, $fn]) || (($fn = "op${ucLType}${ucRType}") && - is_callable(array($this, $fn)) && + is_callable([$this, $fn]) && $passOp = true) || (($fn = "op${ucOpName}") && - is_callable(array($this, $fn)) && + is_callable([$this, $fn]) && $genOp = true) ) { - $unitChange = false; + $coerceUnit = false; if (! isset($genOp) && $left[0] === Type::T_NUMBER && $right[0] === Type::T_NUMBER ) { - if ($opName === 'mod' && ! $right->unitless()) { - $this->throwError( - 'Cannot modulo by a number with units: %s%s', - $right[1], - $right->unitStr() - ); + $coerceUnit = true; + + switch ($opName) { + case 'mul': + $targetUnit = $left[2]; + + foreach ($right[2] as $unit => $exp) { + $targetUnit[$unit] = (isset($targetUnit[$unit]) ? $targetUnit[$unit] : 0) + $exp; + } + break; + + case 'div': + $targetUnit = $left[2]; + + foreach ($right[2] as $unit => $exp) { + $targetUnit[$unit] = (isset($targetUnit[$unit]) ? $targetUnit[$unit] : 0) - $exp; + } + break; + + case 'mod': + $targetUnit = $left[2]; + break; + + default: + $targetUnit = $left->unitless() ? $right[2] : $left[2]; } - $unitChange = true; - $emptyUnit = $left->unitless() || $right->unitless(); - $targetUnit = $left->unitless() ? $right[2] : $left[2]; - - if ($opName !== 'mul') { - $left[2] = $left->unitless() ? $targetUnit : $left[2]; - $right[2] = $right->unitless() ? $targetUnit : $right[2]; - } - - if ($opName !== 'mod') { + if (! $left->unitless() && ! $right->unitless()) { $left = $left->normalize(); $right = $right->normalize(); } - - if ($opName === 'div' && ! $emptyUnit && $left[2] === $right[2]) { - $targetUnit = ''; - } - - if ($opName === 'mul') { - $left[2] = $left->unitless() ? $right[2] : $left[2]; - $right[2] = $right->unitless() ? $left[2] : $right[2]; - } elseif ($opName === 'div' && $left[2] === $right[2]) { - $left[2] = ''; - $right[2] = ''; - } } $shouldEval = $inParens || $inExp; @@ -1863,7 +1930,7 @@ class Compiler } if (isset($out)) { - if ($unitChange && $out[0] === Type::T_NUMBER) { + if ($coerceUnit && $out[0] === Type::T_NUMBER) { $out = $out->coerce($targetUnit); } @@ -1891,7 +1958,7 @@ class Compiler if ($op === 'not') { if ($inExp || $inParens) { - if ($exp === self::$false) { + if ($exp === self::$false || $exp === self::$null) { return self::$true; } @@ -1901,7 +1968,7 @@ class Compiler $op = $op . ' '; } - return array(Type::T_STRING, '', array($op, $exp)); + return [Type::T_STRING, '', [$op, $exp]]; case Type::T_VARIABLE: list(, $name) = $value; @@ -1971,7 +2038,7 @@ class Compiler } // for CSS functions, simply flatten the arguments into a list - $listArgs = array(); + $listArgs = []; foreach ((array) $argValues as $arg) { if (empty($arg[0])) { @@ -1979,7 +2046,7 @@ class Compiler } } - return array(Type::T_FUNCTION, $name, array(Type::T_LIST, ',', $listArgs)); + return [Type::T_FUNCTION, $name, [Type::T_LIST, ',', $listArgs]]; } /** @@ -2011,7 +2078,7 @@ class Compiler $value = $this->extractInterpolation($value); if ($value[0] !== Type::T_LIST) { - return array(Type::T_KEYWORD, $this->compileValue($value)); + return [Type::T_KEYWORD, $this->compileValue($value)]; } foreach ($value[2] as $key => $item) { @@ -2021,13 +2088,13 @@ class Compiler return $value; case Type::T_STRING: - return array($type, '"', array($this->compileStringContent($value))); + return [$type, '"', [$this->compileStringContent($value)]]; case Type::T_NUMBER: return $value->normalize(); case Type::T_INTERPOLATE: - return array(Type::T_KEYWORD, $this->compileValue($value)); + return [Type::T_KEYWORD, $this->compileValue($value)]; default: return $value; @@ -2084,7 +2151,7 @@ class Compiler protected function opDivNumberNumber($left, $right) { if ($right[1] == 0) { - return array(Type::T_STRING, '', array($left[1] . $left[2] . '/' . $right[1] . $right[2])); + return [Type::T_STRING, '', [$left[1] . $left[2] . '/' . $right[1] . $right[2]]]; } return new Node\Number($left[1] / $right[1], $left[2]); @@ -2189,9 +2256,9 @@ class Compiler */ protected function opColorColor($op, $left, $right) { - $out = array(Type::T_COLOR); + $out = [Type::T_COLOR]; - foreach (array(1, 2, 3) as $i) { + foreach ([1, 2, 3] as $i) { $lval = isset($left[$i]) ? $left[$i] : 0; $rval = isset($right[$i]) ? $right[$i] : 0; @@ -2215,6 +2282,7 @@ class Compiler case '/': if ($rval == 0) { $this->throwError("color: Can't divide by zero"); + break 2; } $out[] = (int) ($lval / $rval); @@ -2228,6 +2296,7 @@ class Compiler default: $this->throwError("color: unknown op $op"); + break 2; } } @@ -2256,7 +2325,7 @@ class Compiler return $this->opColorColor( $op, $left, - array(Type::T_COLOR, $value, $value, $value) + [Type::T_COLOR, $value, $value, $value] ); } @@ -2275,7 +2344,7 @@ class Compiler return $this->opColorColor( $op, - array(Type::T_COLOR, $value, $value, $value), + [Type::T_COLOR, $value, $value, $value], $right ); } @@ -2455,7 +2524,7 @@ class Compiler return $h; case Type::T_NUMBER: - return (string) $value; + return $value->output($this); case Type::T_STRING: return $value[1] . $this->compileStringContent($value) . $value[1]; @@ -2478,7 +2547,7 @@ class Compiler $delim .= ' '; } - $filtered = array(); + $filtered = []; foreach ($items as $item) { if ($item[0] === Type::T_NULL) { @@ -2493,7 +2562,7 @@ class Compiler case Type::T_MAP: $keys = $value[1]; $values = $value[2]; - $filtered = array(); + $filtered = []; for ($i = 0, $s = count($keys); $i < $s; $i++) { $filtered[$this->compileValue($keys[$i])] = $this->compileValue($values[$i]); @@ -2527,11 +2596,11 @@ class Compiler switch ($reduced[0]) { case Type::T_STRING: - $reduced = array(Type::T_KEYWORD, $this->compileStringContent($reduced)); + $reduced = [Type::T_KEYWORD, $this->compileStringContent($reduced)]; break; case Type::T_NULL: - $reduced = array(Type::T_KEYWORD, ''); + $reduced = [Type::T_KEYWORD, '']; } return $this->compileValue($reduced); @@ -2565,7 +2634,7 @@ class Compiler */ protected function compileStringContent($string) { - $parts = array(); + $parts = []; foreach ($string[2] as $part) { if (is_array($part) || $part instanceof \ArrayAccess) { @@ -2591,10 +2660,10 @@ class Compiler foreach ($items as $i => $item) { if ($item[0] === Type::T_INTERPOLATE) { - $before = array(Type::T_LIST, $list[1], array_slice($items, 0, $i)); - $after = array(Type::T_LIST, $list[1], array_slice($items, $i + 1)); + $before = [Type::T_LIST, $list[1], array_slice($items, 0, $i)]; + $after = [Type::T_LIST, $list[1], array_slice($items, $i + 1)]; - return array(Type::T_INTERPOLATED, $item, $before, $after); + return [Type::T_INTERPOLATED, $item, $before, $after]; } } @@ -2611,15 +2680,15 @@ class Compiler protected function multiplySelectors(Environment $env) { $envs = $this->compactEnv($env); - $selectors = array(); - $parentSelectors = array(array()); + $selectors = []; + $parentSelectors = [[]]; while ($env = array_pop($envs)) { if (empty($env->selectors)) { continue; } - $selectors = array(); + $selectors = []; foreach ($env->selectors as $selector) { foreach ($parentSelectors as $parent) { @@ -2644,10 +2713,10 @@ class Compiler protected function joinSelectors($parent, $child) { $setSelf = false; - $out = array(); + $out = []; foreach ($child as $part) { - $newPart = array(); + $newPart = []; foreach ($part as $p) { if ($p === self::$selfSelector) { @@ -2656,7 +2725,7 @@ class Compiler foreach ($parent as $i => $parentPart) { if ($i > 0) { $out[] = $newPart; - $newPart = array(); + $newPart = []; } foreach ($parentPart as $pp) { @@ -2697,13 +2766,13 @@ class Compiler $parentQueries = isset($env->block->queryList) ? $env->block->queryList - : array(array(array(Type::T_MEDIA_VALUE, $env->block->value))); + : [[[Type::T_MEDIA_VALUE, $env->block->value]]]; if ($childQueries === null) { $childQueries = $parentQueries; } else { $originalQueries = $childQueries; - $childQueries = array(); + $childQueries = []; foreach ($parentQueries as $parentQuery) { foreach ($originalQueries as $childQuery) { @@ -2724,7 +2793,7 @@ class Compiler */ private function compactEnv(Environment $env) { - for ($envs = array(); $env; $env = $env->parent) { + for ($envs = []; $env; $env = $env->parent) { $envs[] = $env; } @@ -2759,7 +2828,7 @@ class Compiler { $env = new Environment; $env->parent = $this->env; - $env->store = array(); + $env->store = []; $env->block = $block; $env->depth = isset($this->env->depth) ? $this->env->depth + 1 : 0; @@ -3074,7 +3143,7 @@ class Compiler */ public function registerFunction($name, $func, $prototype = null) { - $this->userFunctions[$this->normalizeName($name)] = array($func, $prototype); + $this->userFunctions[$this->normalizeName($name)] = [$func, $prototype]; } /** @@ -3141,12 +3210,12 @@ class Compiler */ public function findImport($url) { - $urls = array(); + $urls = []; // for "normal" scss imports (ignore vanilla css and external requests) if (! preg_match('/\.css$|^https?:\/\//', $url)) { // try both normal and the _partial filename - $urls = array($url, preg_replace('/[^\/]+$/', '_\0', $url)); + $urls = [$url, preg_replace('/[^\/]+$/', '_\0', $url)]; } foreach ($this->importPaths as $dir) { @@ -3176,6 +3245,32 @@ class Compiler return null; } + /** + * Set encoding + * + * @api + * + * @param string $encoding + */ + public function setEncoding($encoding) + { + $this->encoding = $encoding; + } + + /** + * Ignore errors? + * + * @api + * + * @param boolean $ignoreErrors + * + * @return \Leafo\ScssPhp\Compiler + */ + public function setIgnoreErrors($ignoreErrors) + { + $this->ignoreErrors = $ignoreErrors; + } + /** * Throw error (exception) * @@ -3183,20 +3278,22 @@ class Compiler * * @param string $msg Message with optional sprintf()-style vararg parameters * - * @throws \Exception + * @throws \Leafo\ScssPhp\Exception\CompilerException */ public function throwError($msg) { + if ($this->ignoreErrors) { + return; + } + if (func_num_args() > 1) { $msg = call_user_func_array('sprintf', func_get_args()); } - if ($this->sourcePos >= 0 && isset($this->sourceIndex)) { - $parser = $this->sourceParsers[$this->sourceIndex]; - $parser->throwParseError($msg, $this->sourcePos); - } + $line = $this->sourceLine; + $msg = "$msg: line: $line"; - throw new \Exception($msg); + throw new CompilerException($msg); } /** @@ -3209,11 +3306,11 @@ class Compiler private function handleImportLoop($name) { for ($env = $this->env; $env; $env = $env->parent) { - $parser = $this->sourceParsers[$env->block->sourceIndex]; - $file = $parser->getSourceName(); + $file = $this->sourceNames[$env->block->sourceIndex]; if (realpath($file) === $name) { $this->throwError('An @import loop has been found: %s imports %s', $file, basename($file)); + break; } } } @@ -3256,8 +3353,8 @@ class Compiler // throw away lines and children $tmp = new OutputBlock; - $tmp->lines = array(); - $tmp->children = array(); + $tmp->lines = []; + $tmp->children = []; $this->env->marker = 'function'; @@ -3330,14 +3427,12 @@ class Compiler ucfirst($name) ); - return array($this, $libName); + return [$this, $libName]; } /** * Sorts keyword arguments * - * @todo Merge with applyArguments()? - * * @param array $prototype * @param array $args * @@ -3345,8 +3440,8 @@ class Compiler */ protected function sortArgs($prototype, $args) { - $keyArgs = array(); - $posArgs = array(); + $keyArgs = []; + $posArgs = []; // separate positional and keyword arguments foreach ($args as $arg) { @@ -3362,7 +3457,7 @@ class Compiler } if (! isset($prototype)) { - return array($posArgs, $keyArgs); + return [$posArgs, $keyArgs]; } // copy positional args @@ -3377,7 +3472,7 @@ class Compiler } } - return array($finalArgs, $keyArgs); + return [$finalArgs, $keyArgs]; } /** @@ -3396,18 +3491,18 @@ class Compiler $env->store = $storeEnv->store; $hasVariable = false; - $args = array(); + $args = []; foreach ($argDef as $i => $arg) { list($name, $default, $isVariable) = $argDef[$i]; - $args[$name] = array($i, $name, $default, $isVariable); + $args[$name] = [$i, $name, $default, $isVariable]; $hasVariable |= $isVariable; } - $keywordArgs = array(); - $deferredKeywordArgs = array(); - $remaining = array(); + $keywordArgs = []; + $deferredKeywordArgs = []; + $remaining = []; // assign the keyword args foreach ((array) $argValues as $arg) { @@ -3417,14 +3512,17 @@ class Compiler $deferredKeywordArgs[$arg[0][1]] = $arg[1]; } else { $this->throwError("Mixin or function doesn't have an argument named $%s.", $arg[0][1]); + break; } } elseif ($args[$arg[0][1]][0] < count($remaining)) { $this->throwError("The argument $%s was passed both by position and by name.", $arg[0][1]); + break; } else { $keywordArgs[$arg[0][1]] = $arg[1]; } } elseif (count($keywordArgs)) { $this->throwError('Positional arguments must come before keyword arguments.'); + break; } elseif ($arg[2] === true) { $val = $this->reduce($arg[1], true); @@ -3459,7 +3557,7 @@ class Compiler list($i, $name, $default, $isVariable) = $arg; if ($isVariable) { - $val = array(Type::T_LIST, ',', array(), $isVariable); + $val = [Type::T_LIST, ',', [], $isVariable]; for ($count = count($remaining); $i < $count; $i++) { $val[2][] = $remaining[$i]; @@ -3476,6 +3574,7 @@ class Compiler continue; } else { $this->throwError("Missing argument $name"); + break; } $this->set($name, $this->reduce($val, true), true, $env); @@ -3523,7 +3622,7 @@ class Compiler return self::$emptyString; } - return array(Type::T_KEYWORD, $value); + return [Type::T_KEYWORD, $value]; } /** @@ -3543,7 +3642,7 @@ class Compiler return self::$emptyMap; } - return array(Type::T_MAP, array($item), array(self::$null)); + return [Type::T_MAP, [$item], [self::$null]]; } /** @@ -3562,23 +3661,23 @@ class Compiler if (isset($item) && $item[0] === Type::T_MAP) { $keys = $item[1]; $values = $item[2]; - $list = array(); + $list = []; for ($i = 0, $s = count($keys); $i < $s; $i++) { $key = $keys[$i]; $value = $values[$i]; - $list[] = array( + $list[] = [ Type::T_LIST, '', - array(array(Type::T_KEYWORD, $this->compileStringContent($this->coerceString($key))), $value) - ); + [[Type::T_KEYWORD, $this->compileStringContent($this->coerceString($key))], $value] + ]; } - return array(Type::T_LIST, ',', $list); + return [Type::T_LIST, ',', $list]; } - return array(Type::T_LIST, $delim, ! isset($item) ? array(): array($item)); + return [Type::T_LIST, $delim, ! isset($item) ? []: [$item]]; } /** @@ -3617,8 +3716,8 @@ class Compiler $rgba = explode(',', Colors::$cssColors[$name]); return isset($rgba[3]) - ? array(Type::T_COLOR, (int) $rgba[0], (int) $rgba[1], (int) $rgba[2], (int) $rgba[3]) - : array(Type::T_COLOR, (int) $rgba[0], (int) $rgba[1], (int) $rgba[2]); + ? [Type::T_COLOR, (int) $rgba[0], (int) $rgba[1], (int) $rgba[2], (int) $rgba[3]] + : [Type::T_COLOR, (int) $rgba[0], (int) $rgba[1], (int) $rgba[2]]; } return null; @@ -3640,7 +3739,7 @@ class Compiler return $value; } - return array(Type::T_STRING, '', array($this->compileValue($value))); + return [Type::T_STRING, '', [$this->compileValue($value)]]; } /** @@ -3653,7 +3752,7 @@ class Compiler protected function coercePercent($value) { if ($value[0] === Type::T_NUMBER) { - if ($value[2] === '%') { + if (! empty($value[2]['%'])) { return $value[1] / 100; } @@ -3754,7 +3853,7 @@ class Compiler */ protected function fixColor($c) { - foreach (array(1, 2, 3) as $i) { + foreach ([1, 2, 3] as $i) { if ($c[$i] < 0) { $c[$i] = 0; } @@ -3804,7 +3903,7 @@ class Compiler } } - return array(Type::T_HSL, fmod($h, 360), $s * 100, $l / 5.1); + return [Type::T_HSL, fmod($h, 360), $s * 100, $l / 5.1]; } /** @@ -3867,35 +3966,35 @@ class Compiler $g = $this->hueToRGB($m1, $m2, $h) * 255; $b = $this->hueToRGB($m1, $m2, $h - 1/3) * 255; - $out = array(Type::T_COLOR, $r, $g, $b); + $out = [Type::T_COLOR, $r, $g, $b]; return $out; } // Built in functions - //protected static $libCall = array('name', 'args...'); + //protected static $libCall = ['name', 'args...']; protected function libCall($args, $kwargs) { $name = $this->compileStringContent($this->coerceString($this->reduce(array_shift($args), true))); $args = array_map( function ($a) { - return array(null, $a, false); + return [null, $a, false]; }, $args ); if (count($kwargs)) { foreach ($kwargs as $key => $value) { - $args[] = array(array(Type::T_VARIABLE, $key), $value, false); + $args[] = [[Type::T_VARIABLE, $key], $value, false]; } } - return $this->reduce(array(Type::T_FUNCTION_CALL, $name, $args)); + return $this->reduce([Type::T_FUNCTION_CALL, $name, $args]); } - protected static $libIf = array('condition', 'if-true', 'if-false'); + protected static $libIf = ['condition', 'if-true', 'if-false']; protected function libIf($args) { list($cond, $t, $f) = $args; @@ -3907,7 +4006,7 @@ class Compiler return $this->reduce($t, true); } - protected static $libIndex = array('list', 'value'); + protected static $libIndex = ['list', 'value']; protected function libIndex($args) { list($list, $value) = $args; @@ -3928,7 +4027,7 @@ class Compiler return self::$null; } - $values = array(); + $values = []; foreach ($list[2] as $item) { $values[] = $this->normalizeValue($item); @@ -3939,23 +4038,20 @@ class Compiler return false === $key ? self::$null : $key + 1; } - protected static $libRgb = array('red', 'green', 'blue'); + protected static $libRgb = ['red', 'green', 'blue']; protected function libRgb($args) { list($r, $g, $b) = $args; - return array(Type::T_COLOR, $r[1], $g[1], $b[1]); + return [Type::T_COLOR, $r[1], $g[1], $b[1]]; } - protected static $libRgba = array( - array('red', 'color'), - 'green', 'blue', 'alpha'); + protected static $libRgba = [ + ['red', 'color'], + 'green', 'blue', 'alpha']; protected function libRgba($args) { if ($color = $this->coerceColor($args[0])) { - // workaround https://github.com/facebook/hhvm/issues/5457 - reset($args); - $num = ! isset($args[1]) ? $args[3] : $args[1]; $alpha = $this->assertNumber($num); $color[4] = $alpha; @@ -3965,7 +4061,7 @@ class Compiler list($r, $g, $b, $a) = $args; - return array(Type::T_COLOR, $r[1], $g[1], $b[1], $a[1]); + return [Type::T_COLOR, $r[1], $g[1], $b[1], $a[1]]; } // helper function for adjust_color, change_color, and scale_color @@ -3973,10 +4069,7 @@ class Compiler { $color = $this->assertColor($args[0]); - // workaround https://github.com/facebook/hhvm/issues/5457 - reset($args); - - foreach (array(1, 2, 3, 7) as $i) { + foreach ([1, 2, 3, 7] as $i) { if (isset($args[$i])) { $val = $this->assertNumber($args[$i]); $ii = $i === 7 ? 4 : $i; // alpha @@ -3987,7 +4080,7 @@ class Compiler if (isset($args[4]) || isset($args[5]) || isset($args[6])) { $hsl = $this->toHSL($color[1], $color[2], $color[3]); - foreach (array(4, 5, 6) as $i) { + foreach ([4, 5, 6] as $i) { if (isset($args[$i])) { $val = $this->assertNumber($args[$i]); $hsl[$i - 3] = call_user_func($fn, $hsl[$i - 3], $val, $i); @@ -4006,10 +4099,10 @@ class Compiler return $color; } - protected static $libAdjustColor = array( + protected static $libAdjustColor = [ 'color', 'red', 'green', 'blue', 'hue', 'saturation', 'lightness', 'alpha' - ); + ]; protected function libAdjustColor($args) { return $this->alterColor($args, function ($base, $alter, $i) { @@ -4017,10 +4110,10 @@ class Compiler }); } - protected static $libChangeColor = array( + protected static $libChangeColor = [ 'color', 'red', 'green', 'blue', 'hue', 'saturation', 'lightness', 'alpha' - ); + ]; protected function libChangeColor($args) { return $this->alterColor($args, function ($base, $alter, $i) { @@ -4028,10 +4121,10 @@ class Compiler }); } - protected static $libScaleColor = array( + protected static $libScaleColor = [ 'color', 'red', 'green', 'blue', 'hue', 'saturation', 'lightness', 'alpha' - ); + ]; protected function libScaleColor($args) { return $this->alterColor($args, function ($base, $scale, $i) { @@ -4067,16 +4160,16 @@ class Compiler }); } - protected static $libIeHexStr = array('color'); + protected static $libIeHexStr = ['color']; protected function libIeHexStr($args) { $color = $this->coerceColor($args[0]); - $color[4] = isset($color[4]) ? round(255*$color[4]) : 255; + $color[4] = isset($color[4]) ? round(255 * $color[4]) : 255; return sprintf('#%02X%02X%02X%02X', $color[4], $color[1], $color[2], $color[3]); } - protected static $libRed = array('color'); + protected static $libRed = ['color']; protected function libRed($args) { $color = $this->coerceColor($args[0]); @@ -4084,7 +4177,7 @@ class Compiler return $color[1]; } - protected static $libGreen = array('color'); + protected static $libGreen = ['color']; protected function libGreen($args) { $color = $this->coerceColor($args[0]); @@ -4092,7 +4185,7 @@ class Compiler return $color[2]; } - protected static $libBlue = array('color'); + protected static $libBlue = ['color']; protected function libBlue($args) { $color = $this->coerceColor($args[0]); @@ -4100,7 +4193,7 @@ class Compiler return $color[3]; } - protected static $libAlpha = array('color'); + protected static $libAlpha = ['color']; protected function libAlpha($args) { if ($color = $this->coerceColor($args[0])) { @@ -4111,7 +4204,7 @@ class Compiler return null; } - protected static $libOpacity = array('color'); + protected static $libOpacity = ['color']; protected function libOpacity($args) { $value = $args[0]; @@ -4124,7 +4217,7 @@ class Compiler } // mix two colors - protected static $libMix = array('color-1', 'color-2', 'weight'); + protected static $libMix = ['color-1', 'color-2', 'weight']; protected function libMix($args) { list($first, $second, $weight) = $args; @@ -4147,11 +4240,11 @@ class Compiler $w1 = (($w * $a === -1 ? $w : ($w + $a) / (1 + $w * $a)) + 1) / 2.0; $w2 = 1.0 - $w1; - $new = array(Type::T_COLOR, + $new = [Type::T_COLOR, $w1 * $first[1] + $w2 * $second[1], $w1 * $first[2] + $w2 * $second[2], $w1 * $first[3] + $w2 * $second[3], - ); + ]; if ($firstAlpha != 1.0 || $secondAlpha != 1.0) { $new[] = $firstAlpha * $weight + $secondAlpha * ($weight - 1); @@ -4160,7 +4253,7 @@ class Compiler return $this->fixColor($new); } - protected static $libHsl = array('hue', 'saturation', 'lightness'); + protected static $libHsl = ['hue', 'saturation', 'lightness']; protected function libHsl($args) { list($h, $s, $l) = $args; @@ -4168,7 +4261,7 @@ class Compiler return $this->toRGB($h[1], $s[1], $l[1]); } - protected static $libHsla = array('hue', 'saturation', 'lightness', 'alpha'); + protected static $libHsla = ['hue', 'saturation', 'lightness', 'alpha']; protected function libHsla($args) { list($h, $s, $l, $a) = $args; @@ -4179,7 +4272,7 @@ class Compiler return $color; } - protected static $libHue = array('color'); + protected static $libHue = ['color']; protected function libHue($args) { $color = $this->assertColor($args[0]); @@ -4188,7 +4281,7 @@ class Compiler return new Node\Number($hsl[1], 'deg'); } - protected static $libSaturation = array('color'); + protected static $libSaturation = ['color']; protected function libSaturation($args) { $color = $this->assertColor($args[0]); @@ -4197,7 +4290,7 @@ class Compiler return new Node\Number($hsl[2], '%'); } - protected static $libLightness = array('color'); + protected static $libLightness = ['color']; protected function libLightness($args) { $color = $this->assertColor($args[0]); @@ -4219,7 +4312,7 @@ class Compiler return $out; } - protected static $libAdjustHue = array('color', 'degrees'); + protected static $libAdjustHue = ['color', 'degrees']; protected function libAdjustHue($args) { $color = $this->assertColor($args[0]); @@ -4228,7 +4321,7 @@ class Compiler return $this->adjustHsl($color, 1, $degrees); } - protected static $libLighten = array('color', 'amount'); + protected static $libLighten = ['color', 'amount']; protected function libLighten($args) { $color = $this->assertColor($args[0]); @@ -4237,7 +4330,7 @@ class Compiler return $this->adjustHsl($color, 3, $amount); } - protected static $libDarken = array('color', 'amount'); + protected static $libDarken = ['color', 'amount']; protected function libDarken($args) { $color = $this->assertColor($args[0]); @@ -4246,7 +4339,7 @@ class Compiler return $this->adjustHsl($color, 3, -$amount); } - protected static $libSaturate = array('color', 'amount'); + protected static $libSaturate = ['color', 'amount']; protected function libSaturate($args) { $value = $args[0]; @@ -4261,7 +4354,7 @@ class Compiler return $this->adjustHsl($color, 2, $amount); } - protected static $libDesaturate = array('color', 'amount'); + protected static $libDesaturate = ['color', 'amount']; protected function libDesaturate($args) { $color = $this->assertColor($args[0]); @@ -4270,7 +4363,7 @@ class Compiler return $this->adjustHsl($color, 2, -$amount); } - protected static $libGrayscale = array('color'); + protected static $libGrayscale = ['color']; protected function libGrayscale($args) { $value = $args[0]; @@ -4282,13 +4375,13 @@ class Compiler return $this->adjustHsl($this->assertColor($value), 2, -100); } - protected static $libComplement = array('color'); + protected static $libComplement = ['color']; protected function libComplement($args) { return $this->adjustHsl($this->assertColor($args[0]), 1, 180); } - protected static $libInvert = array('color'); + protected static $libInvert = ['color']; protected function libInvert($args) { $value = $args[0]; @@ -4306,7 +4399,7 @@ class Compiler } // increases opacity by amount - protected static $libOpacify = array('color', 'amount'); + protected static $libOpacify = ['color', 'amount']; protected function libOpacify($args) { $color = $this->assertColor($args[0]); @@ -4318,14 +4411,14 @@ class Compiler return $color; } - protected static $libFadeIn = array('color', 'amount'); + protected static $libFadeIn = ['color', 'amount']; protected function libFadeIn($args) { return $this->libOpacify($args); } // decreases opacity by amount - protected static $libTransparentize = array('color', 'amount'); + protected static $libTransparentize = ['color', 'amount']; protected function libTransparentize($args) { $color = $this->assertColor($args[0]); @@ -4337,13 +4430,13 @@ class Compiler return $color; } - protected static $libFadeOut = array('color', 'amount'); + protected static $libFadeOut = ['color', 'amount']; protected function libFadeOut($args) { return $this->libTransparentize($args); } - protected static $libUnquote = array('string'); + protected static $libUnquote = ['string']; protected function libUnquote($args) { $str = $args[0]; @@ -4355,7 +4448,7 @@ class Compiler return $str; } - protected static $libQuote = array('string'); + protected static $libQuote = ['string']; protected function libQuote($args) { $value = $args[0]; @@ -4364,16 +4457,16 @@ class Compiler return $value; } - return array(Type::T_STRING, '"', array($value)); + return [Type::T_STRING, '"', [$value]]; } - protected static $libPercentage = array('value'); + protected static $libPercentage = ['value']; protected function libPercentage($args) { return new Node\Number($this->coercePercent($args[0]) * 100, '%'); } - protected static $libRound = array('value'); + protected static $libRound = ['value']; protected function libRound($args) { $num = $args[0]; @@ -4382,7 +4475,7 @@ class Compiler return $num; } - protected static $libFloor = array('value'); + protected static $libFloor = ['value']; protected function libFloor($args) { $num = $args[0]; @@ -4391,7 +4484,7 @@ class Compiler return $num; } - protected static $libCeil = array('value'); + protected static $libCeil = ['value']; protected function libCeil($args) { $num = $args[0]; @@ -4400,7 +4493,7 @@ class Compiler return $num; } - protected static $libAbs = array('value'); + protected static $libAbs = ['value']; protected function libAbs($args) { $num = $args[0]; @@ -4416,7 +4509,7 @@ class Compiler foreach ($numbers as $key => $number) { if (null === $min || $number[1] <= $min[1]) { - $min = array($key, $number[1]); + $min = [$key, $number[1]]; } } @@ -4430,7 +4523,7 @@ class Compiler foreach ($numbers as $key => $number) { if (null === $max || $number[1] >= $max[1]) { - $max = array($key, $number[1]); + $max = [$key, $number[1]]; } } @@ -4448,11 +4541,12 @@ class Compiler { $unit = null; $originalUnit = null; - $numbers = array(); + $numbers = []; foreach ($args as $key => $item) { if ($item[0] !== Type::T_NUMBER) { $this->throwError('%s is not a number', $item[0]); + break; } $number = $item->normalize(); @@ -4462,6 +4556,7 @@ class Compiler $originalUnit = $item->unitStr(); } elseif ($unit !== $number[2]) { $this->throwError('Incompatible units: "%s" and "%s".', $originalUnit, $item->unitStr()); + break; } $numbers[$key] = $number; @@ -4470,7 +4565,7 @@ class Compiler return $numbers; } - protected static $libLength = array('list'); + protected static $libLength = ['list']; protected function libLength($args) { $list = $this->coerceList($args[0]); @@ -4478,8 +4573,7 @@ class Compiler return count($list[2]); } - // TODO: need a way to declare this built-in as varargs - //protected static $libListSeparator = array('list...'); + //protected static $libListSeparator = ['list...']; protected function libListSeparator($args) { if (count($args) > 1) { @@ -4499,7 +4593,7 @@ class Compiler return 'space'; } - protected static $libNth = array('list', 'n'); + protected static $libNth = ['list', 'n']; protected function libNth($args) { $list = $this->coerceList($args[0]); @@ -4514,7 +4608,7 @@ class Compiler return isset($list[2][$n]) ? $list[2][$n] : self::$defaultValue; } - protected static $libSetNth = array('list', 'n', 'value'); + protected static $libSetNth = ['list', 'n', 'value']; protected function libSetNth($args) { $list = $this->coerceList($args[0]); @@ -4528,6 +4622,8 @@ class Compiler if (! isset($list[2][$n])) { $this->throwError('Invalid argument for "n"'); + + return; } $list[2][$n] = $args[2]; @@ -4535,7 +4631,7 @@ class Compiler return $list; } - protected static $libMapGet = array('map', 'key'); + protected static $libMapGet = ['map', 'key']; protected function libMapGet($args) { $map = $this->assertMap($args[0]); @@ -4550,25 +4646,25 @@ class Compiler return self::$null; } - protected static $libMapKeys = array('map'); + protected static $libMapKeys = ['map']; protected function libMapKeys($args) { $map = $this->assertMap($args[0]); $keys = $map[1]; - return array(Type::T_LIST, ',', $keys); + return [Type::T_LIST, ',', $keys]; } - protected static $libMapValues = array('map'); + protected static $libMapValues = ['map']; protected function libMapValues($args) { $map = $this->assertMap($args[0]); $values = $map[2]; - return array(Type::T_LIST, ',', $values); + return [Type::T_LIST, ',', $values]; } - protected static $libMapRemove = array('map', 'key'); + protected static $libMapRemove = ['map', 'key']; protected function libMapRemove($args) { $map = $this->assertMap($args[0]); @@ -4584,7 +4680,7 @@ class Compiler return $map; } - protected static $libMapHasKey = array('map', 'key'); + protected static $libMapHasKey = ['map', 'key']; protected function libMapHasKey($args) { $map = $this->assertMap($args[0]); @@ -4599,13 +4695,29 @@ class Compiler return false; } - protected static $libMapMerge = array('map-1', 'map-2'); + protected static $libMapMerge = ['map-1', 'map-2']; protected function libMapMerge($args) { $map1 = $this->assertMap($args[0]); $map2 = $this->assertMap($args[1]); - return array(Type::T_MAP, array_merge($map1[1], $map2[1]), array_merge($map1[2], $map2[2])); + return [Type::T_MAP, array_merge($map1[1], $map2[1]), array_merge($map1[2], $map2[2])]; + } + + protected static $libKeywords = ['args']; + protected function libKeywords($args) + { + $this->assertList($args[0]); + + $keys = []; + $values = []; + + foreach ($args[0][2] as $name => $arg) { + $keys[] = [Type::T_KEYWORD, $name]; + $values[] = $arg; + } + + return [Type::T_MAP, $keys, $values]; } protected function listSeparatorForJoin($list1, $sep) @@ -4626,7 +4738,7 @@ class Compiler } } - protected static $libJoin = array('list1', 'list2', 'separator'); + protected static $libJoin = ['list1', 'list2', 'separator']; protected function libJoin($args) { list($list1, $list2, $sep) = $args; @@ -4635,10 +4747,10 @@ class Compiler $list2 = $this->coerceList($list2, ' '); $sep = $this->listSeparatorForJoin($list1, $sep); - return array(Type::T_LIST, $sep, array_merge($list1[2], $list2[2])); + return [Type::T_LIST, $sep, array_merge($list1[2], $list2[2])]; } - protected static $libAppend = array('list', 'val', 'separator'); + protected static $libAppend = ['list', 'val', 'separator']; protected function libAppend($args) { list($list1, $value, $sep) = $args; @@ -4646,7 +4758,7 @@ class Compiler $list1 = $this->coerceList($list1, ' '); $sep = $this->listSeparatorForJoin($list1, $sep); - return array(Type::T_LIST, $sep, array_merge($list1[2], array($value))); + return [Type::T_LIST, $sep, array_merge($list1[2], [$value])]; } protected function libZip($args) @@ -4655,11 +4767,11 @@ class Compiler $this->assertList($arg); } - $lists = array(); + $lists = []; $firstList = array_shift($args); foreach ($firstList[2] as $key => $item) { - $list = array(Type::T_LIST, '', array($item)); + $list = [Type::T_LIST, '', [$item]]; foreach ($args as $arg) { if (isset($arg[2][$key])) { @@ -4672,10 +4784,10 @@ class Compiler $lists[] = $list; } - return array(Type::T_LIST, ',', $lists); + return [Type::T_LIST, ',', $lists]; } - protected static $libTypeOf = array('value'); + protected static $libTypeOf = ['value']; protected function libTypeOf($args) { $value = $args[0]; @@ -4705,19 +4817,19 @@ class Compiler } } - protected static $libUnit = array('number'); + protected static $libUnit = ['number']; protected function libUnit($args) { $num = $args[0]; if ($num[0] === Type::T_NUMBER) { - return array(Type::T_STRING, '"', array($num->unitStr())); + return [Type::T_STRING, '"', [$num->unitStr()]]; } return ''; } - protected static $libUnitless = array('number'); + protected static $libUnitless = ['number']; protected function libUnitless($args) { $value = $args[0]; @@ -4725,7 +4837,7 @@ class Compiler return $value[0] === Type::T_NUMBER && $value->unitless(); } - protected static $libComparable = array('number-1', 'number-2'); + protected static $libComparable = ['number-1', 'number-2']; protected function libComparable($args) { list($number1, $number2) = $args; @@ -4734,6 +4846,8 @@ class Compiler ! isset($number2[0]) || $number2[0] !== Type::T_NUMBER ) { $this->throwError('Invalid argument(s) for "comparable"'); + + return; } $number1 = $number1->normalize(); @@ -4742,7 +4856,7 @@ class Compiler return $number1[2] === $number2[2] || $number1->unitless() || $number2->unitless(); } - protected static $libStrIndex = array('string', 'substring'); + protected static $libStrIndex = ['string', 'substring']; protected function libStrIndex($args) { $string = $this->coerceString($args[0]); @@ -4756,7 +4870,7 @@ class Compiler return $result === false ? self::$null : new Node\Number($result + 1, ''); } - protected static $libStrInsert = array('string', 'insert', 'index'); + protected static $libStrInsert = ['string', 'insert', 'index']; protected function libStrInsert($args) { $string = $this->coerceString($args[0]); @@ -4767,12 +4881,12 @@ class Compiler list(, $index) = $args[2]; - $string[2] = array(substr_replace($stringContent, $insertContent, $index - 1, 0)); + $string[2] = [substr_replace($stringContent, $insertContent, $index - 1, 0)]; return $string; } - protected static $libStrLength = array('string'); + protected static $libStrLength = ['string']; protected function libStrLength($args) { $string = $this->coerceString($args[0]); @@ -4781,47 +4895,55 @@ class Compiler return new Node\Number(strlen($stringContent), ''); } - protected static $libStrSlice = array('string', 'start-at', 'end-at'); + protected static $libStrSlice = ['string', 'start-at', 'end-at']; protected function libStrSlice($args) { - if ($args[2][1] == 0) { - return self::$null; + if (isset($args[2]) && $args[2][1] == 0) { + return self::$nullString; } $string = $this->coerceString($args[0]); $stringContent = $this->compileStringContent($string); - $start = (int) $args[1][1] ?: 1; - $end = (int) $args[2][1]; + $start = (int) $args[1][1]; - $string[2] = array(substr($stringContent, $start - 1, ($end < 0 ? $end : $end - $start) + 1)); + if ($start > 0) { + $start--; + } + + $end = (int) $args[2][1]; + $length = $end < 0 ? $end + 1 : ($end > 0 ? $end - $start : $end); + + $string[2] = $length + ? [substr($stringContent, $start, $length)] + : [substr($stringContent, $start)]; return $string; } - protected static $libToLowerCase = array('string'); + protected static $libToLowerCase = ['string']; protected function libToLowerCase($args) { $string = $this->coerceString($args[0]); $stringContent = $this->compileStringContent($string); - $string[2] = array(mb_strtolower($stringContent)); + $string[2] = [mb_strtolower($stringContent)]; return $string; } - protected static $libToUpperCase = array('string'); + protected static $libToUpperCase = ['string']; protected function libToUpperCase($args) { $string = $this->coerceString($args[0]); $stringContent = $this->compileStringContent($string); - $string[2] = array(mb_strtoupper($stringContent)); + $string[2] = [mb_strtoupper($stringContent)]; return $string; } - protected static $libFeatureExists = array('feature'); + protected static $libFeatureExists = ['feature']; protected function libFeatureExists($args) { $string = $this->coerceString($args[0]); @@ -4832,7 +4954,7 @@ class Compiler ); } - protected static $libFunctionExists = array('name'); + protected static $libFunctionExists = ['name']; protected function libFunctionExists($args) { $string = $this->coerceString($args[0]); @@ -4855,7 +4977,7 @@ class Compiler return $this->toBool(is_callable($f)); } - protected static $libGlobalVariableExists = array('name'); + protected static $libGlobalVariableExists = ['name']; protected function libGlobalVariableExists($args) { $string = $this->coerceString($args[0]); @@ -4864,7 +4986,7 @@ class Compiler return $this->has($name, $this->rootEnv); } - protected static $libMixinExists = array('name'); + protected static $libMixinExists = ['name']; protected function libMixinExists($args) { $string = $this->coerceString($args[0]); @@ -4873,7 +4995,7 @@ class Compiler return $this->has(self::$namespaces['mixin'] . $name); } - protected static $libVariableExists = array('name'); + protected static $libVariableExists = ['name']; protected function libVariableExists($args) { $string = $this->coerceString($args[0]); @@ -4889,11 +5011,12 @@ class Compiler */ protected function libCounter($args) { - $list = array_map(array($this, 'compileValue'), $args); + $list = array_map([$this, 'compileValue'], $args); - return array(Type::T_STRING, '', array('counter(' . implode(',', $list) . ')')); + return [Type::T_STRING, '', ['counter(' . implode(',', $list) . ')']]; } + protected static $libRandom = ['limit']; protected function libRandom($args) { if (isset($args[0])) { @@ -4901,6 +5024,8 @@ class Compiler if ($n < 1) { $this->throwError("limit must be greater than or equal to 1"); + + return; } return new Node\Number(mt_rand(1, $n), ''); @@ -4919,6 +5044,16 @@ class Compiler $id += mt_rand(0, 10) + 1; - return array(Type::T_STRING, '', array('u' . str_pad(base_convert($id, 10, 36), 8, '0', STR_PAD_LEFT))); + return [Type::T_STRING, '', ['u' . str_pad(base_convert($id, 10, 36), 8, '0', STR_PAD_LEFT)]]; + } + + protected static $libInspect = ['value']; + protected function libInspect($args) + { + if ($args[0] === self::$null) { + return [Type::T_KEYWORD, 'null']; + } + + return $args[0]; } } diff --git a/vendor/leafo/scssphp/src/Compiler/Environment.php b/vendor/leafo/scssphp/src/Compiler/Environment.php index f929c74c0..d44bff765 100644 --- a/vendor/leafo/scssphp/src/Compiler/Environment.php +++ b/vendor/leafo/scssphp/src/Compiler/Environment.php @@ -11,10 +11,8 @@ namespace Leafo\ScssPhp\Compiler; -use Leafo\ScssPhp\Block; - /** - * SCSS compiler environment + * Compiler environment * * @author Anthon Pang */ diff --git a/vendor/leafo/scssphp/src/Exception/CompilerException.php b/vendor/leafo/scssphp/src/Exception/CompilerException.php new file mode 100644 index 000000000..777e40ac5 --- /dev/null +++ b/vendor/leafo/scssphp/src/Exception/CompilerException.php @@ -0,0 +1,21 @@ + + */ +class CompilerException extends \Exception +{ +} diff --git a/vendor/leafo/scssphp/src/Exception/ParserException.php b/vendor/leafo/scssphp/src/Exception/ParserException.php new file mode 100644 index 000000000..fbe6388f5 --- /dev/null +++ b/vendor/leafo/scssphp/src/Exception/ParserException.php @@ -0,0 +1,21 @@ + + */ +class ParserException extends \Exception +{ +} diff --git a/vendor/leafo/scssphp/src/Exception/ServerException.php b/vendor/leafo/scssphp/src/Exception/ServerException.php new file mode 100644 index 000000000..5a878d2fb --- /dev/null +++ b/vendor/leafo/scssphp/src/Exception/ServerException.php @@ -0,0 +1,21 @@ + + */ +class ServerException extends \Exception +{ +} diff --git a/vendor/leafo/scssphp/src/Formatter.php b/vendor/leafo/scssphp/src/Formatter.php index 88b7d867d..2770bb2da 100644 --- a/vendor/leafo/scssphp/src/Formatter.php +++ b/vendor/leafo/scssphp/src/Formatter.php @@ -14,7 +14,7 @@ namespace Leafo\ScssPhp; use Leafo\ScssPhp\Formatter\OutputBlock; /** - * SCSS base formatter + * Base formatter * * @author Leaf Corcoran */ @@ -55,6 +55,11 @@ abstract class Formatter */ public $assignSeparator; + /** + * @var boolea + */ + public $keepSemicolons; + /** * Initialize formatter * @@ -96,6 +101,15 @@ abstract class Formatter */ public function stripSemicolon(&$lines) { + if ($this->keepSemicolons) { + return; + } + + if (($count = count($lines)) + && substr($lines[$count - 1], -1) === ';' + ) { + $lines[$count - 1] = substr($lines[$count - 1], 0, -1); + } } /** diff --git a/vendor/leafo/scssphp/src/Formatter/Compact.php b/vendor/leafo/scssphp/src/Formatter/Compact.php index eda6ec24b..94abe3295 100644 --- a/vendor/leafo/scssphp/src/Formatter/Compact.php +++ b/vendor/leafo/scssphp/src/Formatter/Compact.php @@ -14,7 +14,7 @@ namespace Leafo\ScssPhp\Formatter; use Leafo\ScssPhp\Formatter; /** - * SCSS compact formatter + * Compact formatter * * @author Leaf Corcoran */ @@ -32,6 +32,7 @@ class Compact extends Formatter $this->close = "}\n\n"; $this->tagSeparator = ','; $this->assignSeparator = ':'; + $this->keepSemicolons = true; } /** diff --git a/vendor/leafo/scssphp/src/Formatter/Compressed.php b/vendor/leafo/scssphp/src/Formatter/Compressed.php index c51bb26b1..df7bc75fb 100644 --- a/vendor/leafo/scssphp/src/Formatter/Compressed.php +++ b/vendor/leafo/scssphp/src/Formatter/Compressed.php @@ -15,7 +15,7 @@ use Leafo\ScssPhp\Formatter; use Leafo\ScssPhp\Formatter\OutputBlock; /** - * SCSS compressed formatter + * Compressed formatter * * @author Leaf Corcoran */ @@ -33,18 +33,7 @@ class Compressed extends Formatter $this->close = '}'; $this->tagSeparator = ','; $this->assignSeparator = ':'; - } - - /** - * {@inheritdoc} - */ - public function stripSemicolon(&$lines) - { - if (($count = count($lines)) - && substr($lines[$count - 1], -1) === ';' - ) { - $lines[$count - 1] = substr($lines[$count - 1], 0, -1); - } + $this->keepSemicolons = false; } /** @@ -70,15 +59,4 @@ class Compressed extends Formatter echo $this->break; } } - - /** - * {@inherit} - */ - public function format(OutputBlock $block) - { - return parent::format($block); - - // TODO: we need to fix the 2 "compressed" tests where the "close" is applied - return trim(str_replace(';}', '}', parent::format($block))); - } } diff --git a/vendor/leafo/scssphp/src/Formatter/Crunched.php b/vendor/leafo/scssphp/src/Formatter/Crunched.php index 29120cc9e..ccba1333b 100644 --- a/vendor/leafo/scssphp/src/Formatter/Crunched.php +++ b/vendor/leafo/scssphp/src/Formatter/Crunched.php @@ -15,7 +15,7 @@ use Leafo\ScssPhp\Formatter; use Leafo\ScssPhp\Formatter\OutputBlock; /** - * SCSS crunched formatter + * Crunched formatter * * @author Anthon Pang */ @@ -33,18 +33,7 @@ class Crunched extends Formatter $this->close = '}'; $this->tagSeparator = ','; $this->assignSeparator = ':'; - } - - /** - * {@inheritdoc} - */ - public function stripSemicolon(&$lines) - { - if (($count = count($lines)) - && substr($lines[$count - 1], -1) === ';' - ) { - $lines[$count - 1] = substr($lines[$count - 1], 0, -1); - } + $this->keepSemicolons = false; } /** diff --git a/vendor/leafo/scssphp/src/Formatter/Debug.php b/vendor/leafo/scssphp/src/Formatter/Debug.php index e330b2d63..855742e7b 100644 --- a/vendor/leafo/scssphp/src/Formatter/Debug.php +++ b/vendor/leafo/scssphp/src/Formatter/Debug.php @@ -15,7 +15,7 @@ use Leafo\ScssPhp\Formatter; use Leafo\ScssPhp\Formatter\OutputBlock; /** - * SCSS debug formatter + * Debug formatter * * @author Anthon Pang */ @@ -33,6 +33,7 @@ class Debug extends Formatter $this->close = ' }'; $this->tagSeparator = ', '; $this->assignSeparator = ': '; + $this->keepSemicolons = true; } /** diff --git a/vendor/leafo/scssphp/src/Formatter/Expanded.php b/vendor/leafo/scssphp/src/Formatter/Expanded.php index 477318b43..54db742ff 100644 --- a/vendor/leafo/scssphp/src/Formatter/Expanded.php +++ b/vendor/leafo/scssphp/src/Formatter/Expanded.php @@ -15,7 +15,7 @@ use Leafo\ScssPhp\Formatter; use Leafo\ScssPhp\Formatter\OutputBlock; /** - * SCSS expanded formatter + * Expanded formatter * * @author Leaf Corcoran */ @@ -33,6 +33,7 @@ class Expanded extends Formatter $this->close = '}'; $this->tagSeparator = ', '; $this->assignSeparator = ': '; + $this->keepSemicolons = true; } /** diff --git a/vendor/leafo/scssphp/src/Formatter/Nested.php b/vendor/leafo/scssphp/src/Formatter/Nested.php index 8040adaba..9fdb4dd0a 100644 --- a/vendor/leafo/scssphp/src/Formatter/Nested.php +++ b/vendor/leafo/scssphp/src/Formatter/Nested.php @@ -15,7 +15,7 @@ use Leafo\ScssPhp\Formatter; use Leafo\ScssPhp\Formatter\OutputBlock; /** - * SCSS nested formatter + * Nested formatter * * @author Leaf Corcoran */ @@ -38,6 +38,7 @@ class Nested extends Formatter $this->close = ' }'; $this->tagSeparator = ', '; $this->assignSeparator = ': '; + $this->keepSemicolons = true; } /** @@ -154,7 +155,7 @@ class Nested extends Formatter private function adjustAllChildren(OutputBlock $block) { // flatten empty nested blocks - $children = array(); + $children = []; foreach ($block->children as $i => $child) { if (empty($child->lines) && empty($child->children)) { diff --git a/vendor/leafo/scssphp/src/Formatter/OutputBlock.php b/vendor/leafo/scssphp/src/Formatter/OutputBlock.php index bfc383e24..bb8d99b4e 100644 --- a/vendor/leafo/scssphp/src/Formatter/OutputBlock.php +++ b/vendor/leafo/scssphp/src/Formatter/OutputBlock.php @@ -12,7 +12,7 @@ namespace Leafo\ScssPhp\Formatter; /** - * SCSS output block + * Output block * * @author Anthon Pang */ diff --git a/vendor/leafo/scssphp/src/Node.php b/vendor/leafo/scssphp/src/Node.php index d09f597eb..e6ed178ca 100644 --- a/vendor/leafo/scssphp/src/Node.php +++ b/vendor/leafo/scssphp/src/Node.php @@ -12,7 +12,7 @@ namespace Leafo\ScssPhp; /** - * SCSS node + * Base node * * @author Anthon Pang */ @@ -26,10 +26,15 @@ abstract class Node /** * @var integer */ - public $sourcePosition; + public $sourceIndex; /** * @var integer */ - public $sourceIndex; + public $sourceLine; + + /** + * @var integer + */ + public $sourceColumn; } diff --git a/vendor/leafo/scssphp/src/Node/Number.php b/vendor/leafo/scssphp/src/Node/Number.php index a0abcd2bd..a803a6cab 100644 --- a/vendor/leafo/scssphp/src/Node/Number.php +++ b/vendor/leafo/scssphp/src/Node/Number.php @@ -11,11 +11,12 @@ namespace Leafo\ScssPhp\Node; +use Leafo\ScssPhp\Compiler; use Leafo\ScssPhp\Node; use Leafo\ScssPhp\Type; /** - * SCSS dimension + optional units + * Dimension + optional units * * {@internal * This is a work-in-progress. @@ -37,8 +38,8 @@ class Number extends Node implements \ArrayAccess * * @var array */ - static protected $unitTable = array( - 'in' => array( + static protected $unitTable = [ + 'in' => [ 'in' => 1, 'pc' => 6, 'pt' => 72, @@ -46,27 +47,27 @@ class Number extends Node implements \ArrayAccess 'cm' => 2.54, 'mm' => 25.4, 'q' => 101.6, - ), - 'turn' => array( - 'deg' => 180, - 'grad' => 200, - 'rad' => M_PI, - 'turn' => 0.5, - ), - 's' => array( - 's' => 1, + ], + 'turn' => [ + 'deg' => 360, + 'grad' => 400, + 'rad' => 6.28318530717958647692528676, // 2 * M_PI + 'turn' => 1, + ], + 's' => [ + 's' => 1, 'ms' => 1000, - ), - 'Hz' => array( - 'Hz' => 1, + ], + 'Hz' => [ + 'Hz' => 1, 'kHz' => 0.001, - ), - 'dpi' => array( - 'dpi' => 1, + ], + 'dpi' => [ + 'dpi' => 1, 'dpcm' => 2.54, 'dppx' => 96, - ), - ); + ], + ]; /** * @var integer|float @@ -74,21 +75,24 @@ class Number extends Node implements \ArrayAccess public $dimension; /** - * @var string + * @var array */ public $units; /** * Initialize number * - * @param mixed $dimension - * @param string $initialUnit + * @param mixed $dimension + * @param mixed $initialUnit */ public function __construct($dimension, $initialUnit) { $this->type = Type::T_NUMBER; $this->dimension = $dimension; - $this->units = $initialUnit; + $this->units = is_array($initialUnit) + ? $initialUnit + : ($initialUnit ? [$initialUnit => 1] + : []); } /** @@ -100,13 +104,20 @@ class Number extends Node implements \ArrayAccess */ public function coerce($units) { - $value = $this->dimension; - - if (isset(self::$unitTable[$this->units][$units])) { - $value *= self::$unitTable[$this->units][$units]; + if ($this->unitless()) { + return new Number($this->dimension, $units); } - return new Number($value, $units); + $dimension = $this->dimension; + + foreach (self::$unitTable['in'] as $unit => $conv) { + $from = isset($this->units[$unit]) ? $this->units[$unit] : 0; + $to = isset($units[$unit]) ? $units[$unit] : 0; + $factor = pow($conv, $from - $to); + $dimension /= $factor; + } + + return new Number($dimension, $units); } /** @@ -116,13 +127,12 @@ class Number extends Node implements \ArrayAccess */ public function normalize() { - if (isset(self::$unitTable['in'][$this->units])) { - $conv = self::$unitTable['in'][$this->units]; + $dimension = $this->dimension; + $units = []; - return new Number($this->dimension / $conv, 'in'); - } + $this->normalizeUnits($dimension, $units, 'in'); - return new Number($this->dimension, $this->units); + return new Number($dimension, $units); } /** @@ -130,8 +140,12 @@ class Number extends Node implements \ArrayAccess */ public function offsetExists($offset) { + if ($offset === -3) { + return $this->sourceColumn !== null; + } + if ($offset === -2) { - return $sourceIndex !== null; + return $this->sourceLine !== null; } if ($offset === -1 @@ -151,11 +165,14 @@ class Number extends Node implements \ArrayAccess public function offsetGet($offset) { switch ($offset) { + case -3: + return $this->sourceColumn; + case -2: - return $this->sourceIndex; + return $this->sourceLine; case -1: - return $this->sourcePosition; + return $this->sourceIndex; case 0: return $this->type; @@ -178,9 +195,11 @@ class Number extends Node implements \ArrayAccess } elseif ($offset === 2) { $this->units = $value; } elseif ($offset == -1) { - $this->sourcePosition = $value; - } elseif ($offset == -2) { $this->sourceIndex = $value; + } elseif ($offset == -2) { + $this->sourceLine = $value; + } elseif ($offset == -3) { + $this->sourceColumn = $value; } } @@ -194,9 +213,11 @@ class Number extends Node implements \ArrayAccess } elseif ($offset === 2) { $this->units = null; } elseif ($offset === -1) { - $this->sourcePosition = null; - } elseif ($offset === -2) { $this->sourceIndex = null; + } elseif ($offset === -2) { + $this->sourceLine = null; + } elseif ($offset === -3) { + $this->sourceColumn = null; } } @@ -207,7 +228,7 @@ class Number extends Node implements \ArrayAccess */ public function unitless() { - return empty($this->units); + return ! array_sum($this->units); } /** @@ -217,7 +238,61 @@ class Number extends Node implements \ArrayAccess */ public function unitStr() { - return $this->units; + $numerators = []; + $denominators = []; + + foreach ($this->units as $unit => $unitSize) { + if ($unitSize > 0) { + $numerators = array_pad($numerators, count($numerators) + $unitSize, $unit); + continue; + } + + if ($unitSize < 0) { + $denominators = array_pad($denominators, count($denominators) + $unitSize, $unit); + continue; + } + } + + return implode('*', $numerators) . (count($denominators) ? '/' . implode('*', $denominators) : ''); + } + + /** + * Output number + * + * @param \Leafo\ScssPhp\Compiler $compiler + * + * @return string + */ + public function output(Compiler $compiler = null) + { + $dimension = round($this->dimension, self::$precision); + + $units = array_filter($this->units, function ($unitSize) { + return $unitSize; + }); + + if (count($units) > 1 && array_sum($units) === 0) { + $dimension = $this->dimension; + $units = []; + + $this->normalizeUnits($dimension, $units, 'in'); + + $dimension = round($dimension, self::$precision); + $units = array_filter($units, function ($unitSize) { + return $unitSize; + }); + } + + $unitSize = array_sum($units); + + if ($compiler && ($unitSize > 1 || $unitSize < 0 || count($units) > 1)) { + $compiler->throwError((string) $dimension . $this->unitStr() . " isn't a valid CSS value."); + } + + reset($units); + list($unit, ) = each($units); + + return (string) $dimension . $unit; } /** @@ -225,12 +300,30 @@ class Number extends Node implements \ArrayAccess */ public function __toString() { - $value = round($this->dimension, self::$precision); + return $this->output(); + } - if (empty($this->units)) { - return (string) $value; + /** + * Normalize units + * + * @param integer|float $dimension + * @param array $units + * @param string $baseUnit + */ + private function normalizeUnits(&$dimension, &$units, $baseUnit = 'in') + { + $dimension = $this->dimension; + $units = []; + + foreach ($this->units as $unit => $exp) { + if (isset(self::$unitTable[$baseUnit][$unit])) { + $factor = pow(self::$unitTable[$baseUnit][$unit], $exp); + + $unit = $baseUnit; + $dimension /= $factor; + } + + $units[$unit] = $exp + (isset($units[$unit]) ? $units[$unit] : 0); } - - return (string) $value . $this->units; } } diff --git a/vendor/leafo/scssphp/src/Parser.php b/vendor/leafo/scssphp/src/Parser.php index cbf868293..7874a97cf 100644 --- a/vendor/leafo/scssphp/src/Parser.php +++ b/vendor/leafo/scssphp/src/Parser.php @@ -13,23 +13,25 @@ namespace Leafo\ScssPhp; use Leafo\ScssPhp\Block; use Leafo\ScssPhp\Compiler; +use Leafo\ScssPhp\Exception\ParserException; use Leafo\ScssPhp\Node; use Leafo\ScssPhp\Type; /** - * SCSS parser + * Parser * * @author Leaf Corcoran */ class Parser { - const SOURCE_INDEX = -1; - const SOURCE_POSITION = -2; + const SOURCE_INDEX = -1; + const SOURCE_LINE = -2; + const SOURCE_COLUMN = -3; /** * @var array */ - protected static $precedence = array( + protected static $precedence = [ '=' => 0, 'or' => 1, 'and' => 2, @@ -45,7 +47,7 @@ class Parser '*' => 6, '/' => 6, '%' => 6, - ); + ]; protected static $commentPattern; protected static $operatorPattern; @@ -53,12 +55,16 @@ class Parser private $sourceName; private $sourceIndex; + private $sourcePositions; private $charset; private $count; private $env; private $inParens; private $eatWhiteDefault; private $buffer; + private $utf8; + private $encoding; + private $patternModifiers; /** * Constructor @@ -67,12 +73,15 @@ class Parser * * @param string $sourceName * @param integer $sourceIndex + * @param string $encoding */ - public function __construct($sourceName, $sourceIndex = 0) + public function __construct($sourceName, $sourceIndex = 0, $encoding = 'utf-8') { - $this->sourceName = $sourceName ?: '(stdin)'; - $this->sourceIndex = $sourceIndex; - $this->charset = null; + $this->sourceName = $sourceName ?: '(stdin)'; + $this->sourceIndex = $sourceIndex; + $this->charset = null; + $this->utf8 = ! $encoding || strtolower($encoding) === 'utf-8'; + $this->patternModifiers = $this->utf8 ? 'Aisu' : 'Ais'; if (empty(self::$operatorPattern)) { self::$operatorPattern = '([*\/%+-]|[!=]\=|\>\=?|\<\=\>|\<\=?|and|or)'; @@ -82,7 +91,9 @@ class Parser $commentMultiRight = '\*\/'; self::$commentPattern = $commentMultiLeft . '.*?' . $commentMultiRight; - self::$whitePattern = '/' . $commentSingle . '[^\n]*\s*|(' . self::$commentPattern . ')\s*|\s+/Ais'; + self::$whitePattern = $this->utf8 + ? '/' . $commentSingle . '[^\n]*\s*|(' . self::$commentPattern . ')\s*|\s+/AisuS' + : '/' . $commentSingle . '[^\n]*\s*|(' . self::$commentPattern . ')\s*|\s+/AisS'; } } @@ -98,47 +109,26 @@ class Parser return $this->sourceName; } - /** - * Get source line number (given character position in the buffer) - * - * @api - * - * @param integer $pos - * - * @return integer - */ - public function getLineNo($pos) - { - return 1 + substr_count(substr($this->buffer, 0, $pos), "\n"); - } - /** * Throw parser error * * @api * - * @param string $msg - * @param integer $count + * @param string $msg * - * @throws \Exception + * @throws \Leafo\ScssPhp\Exception\ParserException */ - public function throwParseError($msg = 'parse error', $count = null) + public function throwParseError($msg = 'parse error') { - $count = ! isset($count) ? $this->count : $count; + list($line, /* $column */) = $this->getSourcePosition($this->count); - $line = $this->getLineNo($count); + $loc = empty($this->sourceName) ? "line: $line" : "$this->sourceName on line $line"; - if (! empty($this->sourceName)) { - $loc = "$this->sourceName on line $line"; - } else { - $loc = "line: $line"; + if ($this->peek("(.*?)(\n|$)", $m, $this->count)) { + throw new ParserException("$msg: failed at `$m[1]` $loc"); } - if ($this->peek("(.*?)(\n|$)", $m, $count)) { - throw new \Exception("$msg: failed at `$m[1]` $loc"); - } - - throw new \Exception("$msg: $loc"); + throw new ParserException("$msg: $loc"); } /** @@ -158,8 +148,10 @@ class Parser $this->eatWhiteDefault = true; $this->buffer = rtrim($buffer, "\x00..\x1f"); - $this->pushBlock(null); // root block + $this->saveEncoding(); + $this->extractLineNumbers($buffer); + $this->pushBlock(null); // root block $this->whitespace(); $this->pushBlock(null); $this->popBlock(); @@ -182,6 +174,8 @@ class Parser $this->env->isRoot = true; + $this->restoreEncoding(); + return $this->env; } @@ -203,7 +197,13 @@ class Parser $this->eatWhiteDefault = true; $this->buffer = (string) $buffer; - return $this->valueList($out); + $this->saveEncoding(); + + $list = $this->valueList($out); + + $this->restoreEncoding(); + + return $list; } /** @@ -224,7 +224,13 @@ class Parser $this->eatWhiteDefault = true; $this->buffer = (string) $buffer; - return $this->selectors($out); + $this->saveEncoding(); + + $selector = $this->selectors($out); + + $this->restoreEncoding(); + + return $selector; } /** @@ -317,8 +323,7 @@ class Parser ($this->end() || $this->literal('{') && $hasBlock = true) ) { - $child = array(Type::T_INCLUDE, - $mixinName, isset($argValues) ? $argValues : null, null); + $child = [Type::T_INCLUDE, $mixinName, isset($argValues) ? $argValues : null, null]; if (! empty($hasBlock)) { $include = $this->pushSpecialBlock(Type::T_INCLUDE, $s); @@ -332,11 +337,22 @@ class Parser $this->seek($s); + if ($this->literal('@scssphp-import-once') && + $this->valueList($importPath) && + $this->end() + ) { + $this->append([Type::T_SCSSPHP_IMPORT_ONCE, $importPath], $s); + + return true; + } + + $this->seek($s); + if ($this->literal('@import') && $this->valueList($importPath) && $this->end() ) { - $this->append(array(Type::T_IMPORT, $importPath), $s); + $this->append([Type::T_IMPORT, $importPath], $s); return true; } @@ -347,7 +363,7 @@ class Parser $this->url($importPath) && $this->end() ) { - $this->append(array(Type::T_IMPORT, $importPath), $s); + $this->append([Type::T_IMPORT, $importPath], $s); return true; } @@ -355,10 +371,12 @@ class Parser $this->seek($s); if ($this->literal('@extend') && - $this->selectors($selector) && + $this->selectors($selectors) && $this->end() ) { - $this->append(array(Type::T_EXTEND, $selector), $s); + // check for '!flag' + $optional = $this->stripOptionalFlag($selectors); + $this->append([Type::T_EXTEND, $selectors, $optional], $s); return true; } @@ -380,7 +398,7 @@ class Parser $this->seek($s); if ($this->literal('@break') && $this->end()) { - $this->append(array(Type::T_BREAK), $s); + $this->append([Type::T_BREAK], $s); return true; } @@ -388,7 +406,7 @@ class Parser $this->seek($s); if ($this->literal('@continue') && $this->end()) { - $this->append(array(Type::T_CONTINUE), $s); + $this->append([Type::T_CONTINUE], $s); return true; } @@ -397,7 +415,7 @@ class Parser if ($this->literal('@return') && ($this->valueList($retVal) || true) && $this->end()) { - $this->append(array(Type::T_RETURN, isset($retVal) ? $retVal : array(Type::T_NULL)), $s); + $this->append([Type::T_RETURN, isset($retVal) ? $retVal : [Type::T_NULL]], $s); return true; } @@ -458,7 +476,7 @@ class Parser if ($this->literal('@if') && $this->valueList($cond) && $this->literal('{')) { $if = $this->pushSpecialBlock(Type::T_IF, $s); $if->cond = $cond; - $if->cases = array(); + $if->cases = []; return true; } @@ -469,7 +487,7 @@ class Parser $this->valueList($value) && $this->end() ) { - $this->append(array(Type::T_DEBUG, $value), $s); + $this->append([Type::T_DEBUG, $value], $s); return true; } @@ -480,7 +498,7 @@ class Parser $this->valueList($value) && $this->end() ) { - $this->append(array(Type::T_WARN, $value), $s); + $this->append([Type::T_WARN, $value], $s); return true; } @@ -491,7 +509,7 @@ class Parser $this->valueList($value) && $this->end() ) { - $this->append(array(Type::T_ERROR, $value), $s); + $this->append([Type::T_ERROR, $value], $s); return true; } @@ -499,7 +517,7 @@ class Parser $this->seek($s); if ($this->literal('@content') && $this->end()) { - $this->append(array(Type::T_MIXIN_CONTENT), $s); + $this->append([Type::T_MIXIN_CONTENT], $s); return true; } @@ -536,10 +554,13 @@ class Parser $this->end() ) { if (! isset($this->charset)) { - $statement = array(Type::T_CHARSET, $charset); + $statement = [Type::T_CHARSET, $charset]; - $statement[self::SOURCE_POSITION] = $s; - $statement[self::SOURCE_INDEX] = $this->sourceIndex; + list($line, $column) = $this->getSourcePosition($s); + + $statement[self::SOURCE_LINE] = $line; + $statement[self::SOURCE_COLUMN] = $column; + $statement[self::SOURCE_INDEX] = $this->sourceIndex; $this->charset = $statement; } @@ -581,8 +602,8 @@ class Parser $this->valueList($value) && $this->end() ) { - $name = array(Type::T_STRING, '', array($name)); - $this->append(array(Type::T_ASSIGN, $name, $value), $s); + $name = [Type::T_STRING, '', [$name]]; + $this->append([Type::T_ASSIGN, $name, $value], $s); return true; } @@ -597,7 +618,7 @@ class Parser ) { // check for '!flag' $assignmentFlag = $this->stripAssignmentFlag($value); - $this->append(array(Type::T_ASSIGN, $name, $value, $assignmentFlag), $s); + $this->append([Type::T_ASSIGN, $name, $value, $assignmentFlag], $s); return true; } @@ -611,7 +632,7 @@ class Parser // opening css block if ($this->selectors($selectors) && $this->literal('{')) { - $b = $this->pushBlock($selectors, $s); + $this->pushBlock($selectors, $s); return true; } @@ -623,7 +644,7 @@ class Parser $foundSomething = false; if ($this->valueList($value)) { - $this->append(array(Type::T_ASSIGN, $name, $value), $s); + $this->append([Type::T_ASSIGN, $name, $value], $s); $foundSomething = true; } @@ -653,7 +674,7 @@ class Parser $this->append($include, $s); } elseif (empty($block->dontAppend)) { $type = isset($block->type) ? $block->type : Type::T_BLOCK; - $this->append(array($type, $block), $s); + $this->append([$type, $block], $s); } return true; @@ -679,22 +700,25 @@ class Parser */ protected function pushBlock($selectors, $pos = 0) { + list($line, $column) = $this->getSourcePosition($pos); + $b = new Block; - $b->parent = $this->env; - $b->sourcePosition = $pos; - $b->sourceIndex = $this->sourceIndex; - $b->selectors = $selectors; - $b->comments = array(); + $b->sourceLine = $line; + $b->sourceColumn = $column; + $b->sourceIndex = $this->sourceIndex; + $b->selectors = $selectors; + $b->comments = []; + $b->parent = $this->env; if (! $this->env) { - $b->children = array(); + $b->children = []; } elseif (empty($this->env->children)) { $this->env->children = $this->env->comments; - $b->children = array(); - $this->env->comments = array(); + $b->children = []; + $this->env->comments = []; } else { $b->children = $this->env->comments; - $this->env->comments = array(); + $this->env->comments = []; } $this->env = $b; @@ -760,7 +784,7 @@ class Parser $from = $this->count; } - $r = '/' . $regex . '/Ais'; + $r = '/' . $regex . '/' . $this->patternModifiers; $result = preg_match($r, $this->buffer, $out, null, $from); return $result; @@ -801,7 +825,7 @@ class Parser $end = strlen($this->buffer); // look for either ending delim, escape, or string interpolation - foreach (array('#{', '\\', $delim) as $lookahead) { + foreach (['#{', '\\', $delim] as $lookahead) { $pos = strpos($this->buffer, $lookahead, $this->count); if ($pos !== false && $pos < $end) { @@ -815,11 +839,11 @@ class Parser } $match = substr($this->buffer, $this->count, $end - $this->count); - $m = array( + $m = [ $match . $token, $match, $token - ); + ]; $this->count = $end + strlen($token); return true; @@ -840,7 +864,7 @@ class Parser $eatWhitespace = $this->eatWhiteDefault; } - $r = '/' . $regex . '/Ais'; + $r = '/' . $regex . '/' . $this->patternModifiers; if (preg_match($r, $this->buffer, $out, null, $this->count)) { $this->count += strlen($out[0]); @@ -869,22 +893,19 @@ class Parser $eatWhitespace = $this->eatWhiteDefault; } - // shortcut on single letter - if (! isset($what[1]) && isset($this->buffer[$this->count])) { - if ($this->buffer[$this->count] === $what) { - if (! $eatWhitespace) { - $this->count++; + $len = strlen($what); - return true; - } + if (substr($this->buffer, $this->count, $len) === $what) { + $this->count += $len; - // goes below... - } else { - return false; + if ($eatWhitespace) { + $this->whitespace(); } + + return true; } - return $this->match($this->pregQuote($what), $m, $eatWhitespace); + return false; } /** @@ -898,7 +919,7 @@ class Parser while (preg_match(self::$whitePattern, $this->buffer, $m, null, $this->count)) { if (isset($m[1]) && empty($this->commentsSeen[$this->count])) { - $this->appendComment(array(Type::T_COMMENT, $m[1])); + $this->appendComment([Type::T_COMMENT, $m[1]]); $this->commentsSeen[$this->count] = true; } @@ -917,7 +938,7 @@ class Parser */ protected function appendComment($comment) { - $comment[1] = substr(preg_replace(array('/^\s+/m', '/^(.)/m'), array('', ' \1'), $comment[1]), 1); + $comment[1] = substr(preg_replace(['/^\s+/m', '/^(.)/m'], ['', ' \1'], $comment[1]), 1); $this->env->comments[] = $comment; } @@ -931,8 +952,11 @@ class Parser protected function append($statement, $pos = null) { if ($pos !== null) { - $statement[self::SOURCE_POSITION] = $pos; - $statement[self::SOURCE_INDEX] = $this->sourceIndex; + list($line, $column) = $this->getSourcePosition($pos); + + $statement[self::SOURCE_LINE] = $line; + $statement[self::SOURCE_COLUMN] = $column; + $statement[self::SOURCE_INDEX] = $this->sourceIndex; } $this->env->children[] = $statement; @@ -941,7 +965,7 @@ class Parser if (count($comments)) { $this->env->children = array_merge($this->env->children, $comments); - $this->env->comments = array(); + $this->env->comments = []; } } @@ -980,31 +1004,29 @@ class Parser */ protected function mediaQuery(&$out) { - $s = $this->seek(); - $expressions = null; - $parts = array(); + $parts = []; if (($this->literal('only') && ($only = true) || $this->literal('not') && ($not = true) || true) && $this->mixedKeyword($mediaType) ) { - $prop = array(Type::T_MEDIA_TYPE); + $prop = [Type::T_MEDIA_TYPE]; if (isset($only)) { - $prop[] = array(Type::T_KEYWORD, 'only'); + $prop[] = [Type::T_KEYWORD, 'only']; } if (isset($not)) { - $prop[] = array(Type::T_KEYWORD, 'not'); + $prop[] = [Type::T_KEYWORD, 'not']; } - $media = array(Type::T_LIST, '', array()); + $media = [Type::T_LIST, '', []]; - foreach ((array)$mediaType as $type) { + foreach ((array) $mediaType as $type) { if (is_array($type)) { $media[2][] = $type; } else { - $media[2][] = array(Type::T_KEYWORD, $type); + $media[2][] = [Type::T_KEYWORD, $type]; } } @@ -1042,7 +1064,7 @@ class Parser ($this->literal(':') && $this->expression($value) || true) && $this->literal(')') ) { - $out = array(Type::T_MEDIA_EXPRESSION, $feature); + $out = [Type::T_MEDIA_EXPRESSION, $feature]; if ($value) { $out[] = $value; @@ -1093,7 +1115,7 @@ class Parser } if ($this->genericList($value, 'expression')) { - $out = array($keyword, $value, false); + $out = [$keyword, $value, false]; $s = $this->seek(); if ($this->literal('...')) { @@ -1145,7 +1167,7 @@ class Parser protected function genericList(&$out, $parseItem, $delim = '', $flatten = true) { $s = $this->seek(); - $items = array(); + $items = []; while ($this->$parseItem($value)) { $items[] = $value; @@ -1166,7 +1188,7 @@ class Parser if ($flatten && count($items) === 1) { $out = $items[0]; } else { - $out = array(Type::T_LIST, $delim, $items); + $out = [Type::T_LIST, $delim, $items]; } return true; @@ -1185,7 +1207,7 @@ class Parser if ($this->literal('(')) { if ($this->literal(')')) { - $out = array(Type::T_LIST, '', array()); + $out = [Type::T_LIST, '', []]; return true; } @@ -1252,7 +1274,7 @@ class Parser $rhs = $this->expHelper($rhs, self::$precedence[$next[1]]); } - $lhs = array(Type::T_EXPRESSION, $op, $lhs, $rhs, $this->inParens, $whiteBefore, $whiteAfter); + $lhs = [Type::T_EXPRESSION, $op, $lhs, $rhs, $this->inParens, $whiteBefore, $whiteAfter]; $ss = $this->seek(); $whiteBefore = isset($this->buffer[$this->count - 1]) && ctype_space($this->buffer[$this->count - 1]); @@ -1275,7 +1297,7 @@ class Parser $s = $this->seek(); if ($this->literal('not', false) && $this->whitespace() && $this->value($inner)) { - $out = array(Type::T_UNARY, 'not', $inner, $this->inParens); + $out = [Type::T_UNARY, 'not', $inner, $this->inParens]; return true; } @@ -1283,7 +1305,7 @@ class Parser $this->seek($s); if ($this->literal('not', false) && $this->parenValue($inner)) { - $out = array(Type::T_UNARY, 'not', $inner, $this->inParens); + $out = [Type::T_UNARY, 'not', $inner, $this->inParens]; return true; } @@ -1291,7 +1313,7 @@ class Parser $this->seek($s); if ($this->literal('+') && $this->value($inner)) { - $out = array(Type::T_UNARY, '+', $inner, $this->inParens); + $out = [Type::T_UNARY, '+', $inner, $this->inParens]; return true; } @@ -1304,7 +1326,7 @@ class Parser $this->unit($inner) || $this->parenValue($inner)) ) { - $out = array(Type::T_UNARY, '-', $inner, $this->inParens); + $out = [Type::T_UNARY, '-', $inner, $this->inParens]; return true; } @@ -1325,9 +1347,9 @@ class Parser if ($this->keyword($keyword)) { if ($keyword === 'null') { - $out = array(Type::T_NULL); + $out = [Type::T_NULL]; } else { - $out = array(Type::T_KEYWORD, $keyword); + $out = [Type::T_KEYWORD, $keyword]; } return true; @@ -1351,7 +1373,7 @@ class Parser if ($this->literal('(')) { if ($this->literal(')')) { - $out = array(Type::T_LIST, '', array()); + $out = [Type::T_LIST, '', []]; return true; } @@ -1390,9 +1412,9 @@ class Parser $this->openString(')', $args, '('); if ($this->literal(')')) { - $out = array(Type::T_STRING, '', array( + $out = [Type::T_STRING, '', [ 'progid:', $fn, '(', $args, ')' - )); + ]]; return true; } @@ -1418,7 +1440,7 @@ class Parser $this->literal('(') ) { if ($name === 'alpha' && $this->argumentList($args)) { - $func = array(Type::T_FUNCTION, $name, array(Type::T_STRING, '', $args)); + $func = [Type::T_FUNCTION, $name, [Type::T_STRING, '', $args]]; return true; } @@ -1427,7 +1449,7 @@ class Parser $ss = $this->seek(); if ($this->argValues($args) && $this->literal(')')) { - $func = array(Type::T_FUNCTION_CALL, $name, $args); + $func = [Type::T_FUNCTION_CALL, $name, $args]; return true; } @@ -1435,16 +1457,16 @@ class Parser $this->seek($ss); } - if (($this->openString(')', $str, '(') || true ) && + if (($this->openString(')', $str, '(') || true) && $this->literal(')') ) { - $args = array(); + $args = []; if (! empty($str)) { - $args[] = array(null, array(Type::T_STRING, '', array($str))); + $args[] = [null, [Type::T_STRING, '', [$str]]]; } - $func = array(Type::T_FUNCTION_CALL, $name, $args); + $func = [Type::T_FUNCTION_CALL, $name, $args]; return true; } @@ -1467,13 +1489,11 @@ class Parser $s = $this->seek(); $this->literal('('); - $args = array(); + $args = []; while ($this->keyword($var)) { - $ss = $this->seek(); - if ($this->literal('=') && $this->expression($exp)) { - $args[] = array(Type::T_STRING, '', array($var . '=')); + $args[] = [Type::T_STRING, '', [$var . '=']]; $arg = $exp; } else { break; @@ -1485,7 +1505,7 @@ class Parser break; } - $args[] = array(Type::T_STRING, '', array(', ')); + $args[] = [Type::T_STRING, '', [', ']]; } if (! $this->literal(')') || ! count($args)) { @@ -1511,10 +1531,10 @@ class Parser $s = $this->seek(); $this->literal('('); - $args = array(); + $args = []; while ($this->variable($var)) { - $arg = array($var[1], null, false); + $arg = [$var[1], null, false]; $ss = $this->seek(); @@ -1572,8 +1592,8 @@ class Parser return false; } - $keys = array(); - $values = array(); + $keys = []; + $values = []; while ($this->genericList($key, 'expression') && $this->literal(':') && $this->genericList($value, 'expression') @@ -1592,7 +1612,7 @@ class Parser return false; } - $out = array(Type::T_MAP, $keys, $values); + $out = [Type::T_MAP, $keys, $values]; return true; } @@ -1606,13 +1626,13 @@ class Parser */ protected function color(&$out) { - $color = array(Type::T_COLOR); + $color = [Type::T_COLOR]; if ($this->match('(#([0-9a-f]{6})|#([0-9a-f]{3}))', $m)) { if (isset($m[3])) { $num = hexdec($m[3]); - foreach (array(3, 2, 1) as $i) { + foreach ([3, 2, 1] as $i) { $t = $num & 0xf; $color[$i] = $t << 4 | $t; $num >>= 4; @@ -1620,7 +1640,7 @@ class Parser } else { $num = hexdec($m[2]); - foreach (array(3, 2, 1) as $i) { + foreach ([3, 2, 1] as $i) { $color[$i] = $num & 0xff; $num >>= 8; } @@ -1665,33 +1685,39 @@ class Parser if ($this->literal('"', false)) { $delim = '"'; - } elseif ($this->literal('\'', false)) { - $delim = '\''; + } elseif ($this->literal("'", false)) { + $delim = "'"; } else { return false; } - $content = array(); + $content = []; $oldWhite = $this->eatWhiteDefault; $this->eatWhiteDefault = false; + $hasInterpolation = false; while ($this->matchString($m, $delim)) { - $content[] = $m[1]; + if ($m[1] !== '') { + $content[] = $m[1]; + } if ($m[2] === '#{') { $this->count -= strlen($m[2]); if ($this->interpolation($inter, false)) { $content[] = $inter; + $hasInterpolation = true; } else { $this->count += strlen($m[2]); $content[] = '#{'; // ignore it } } elseif ($m[2] === '\\') { - $content[] = $m[2]; - - if ($this->literal($delim, false)) { - $content[] = $delim; + if ($this->literal('"', false)) { + $content[] = $m[2] . '"'; + } elseif ($this->literal("'", false)) { + $content[] = $m[2] . "'"; + } else { + $content[] = $m[2]; } } else { $this->count -= strlen($delim); @@ -1702,7 +1728,19 @@ class Parser $this->eatWhiteDefault = $oldWhite; if ($this->literal($delim)) { - $out = array(Type::T_STRING, $delim, $content); + if ($hasInterpolation) { + $delim = '"'; + + foreach ($content as &$string) { + if ($string === "\\'") { + $string = "'"; + } elseif ($string === '\\"') { + $string = '"'; + } + } + } + + $out = [Type::T_STRING, $delim, $content]; return true; } @@ -1721,9 +1759,7 @@ class Parser */ protected function mixedKeyword(&$out) { - $s = $this->seek(); - - $parts = array(); + $parts = []; $oldWhite = $this->eatWhiteDefault; $this->eatWhiteDefault = false; @@ -1775,7 +1811,7 @@ class Parser $nestingLevel = 0; - $content = array(); + $content = []; while ($this->match($patt, $m, false)) { if (isset($m[1]) && $m[1] !== '') { @@ -1794,7 +1830,7 @@ class Parser break; } - if (($tok === '\'' || $tok === '"') && $this->string($str)) { + if (($tok === "'" || $tok === '"') && $this->string($str)) { $content[] = $str; continue; } @@ -1819,7 +1855,7 @@ class Parser $content[count($content) - 1] = rtrim(end($content)); } - $out = array(Type::T_STRING, '', $content); + $out = [Type::T_STRING, '', $content]; return true; } @@ -1840,8 +1876,6 @@ class Parser $s = $this->seek(); if ($this->literal('#{') && $this->valueList($value) && $this->literal('}', false)) { - // TODO: don't error if out of bounds - if ($lookWhite) { $left = preg_match('/\s/', $this->buffer[$s - 1]) ? ' ' : ''; $right = preg_match('/\s/', $this->buffer[$this->count]) ? ' ': ''; @@ -1849,7 +1883,7 @@ class Parser $left = $right = false; } - $out = array(Type::T_INTERPOLATE, $value, $left, $right); + $out = [Type::T_INTERPOLATE, $value, $left, $right]; $this->eatWhiteDefault = $oldWhite; if ($this->eatWhiteDefault) { @@ -1874,8 +1908,7 @@ class Parser */ protected function propertyName(&$out) { - $s = $this->seek(); - $parts = array(); + $parts = []; $oldWhite = $this->eatWhiteDefault; $this->eatWhiteDefault = false; @@ -1922,7 +1955,7 @@ class Parser $this->whitespace(); // get any extra whitespace - $out = array(Type::T_STRING, '', $parts); + $out = [Type::T_STRING, '', $parts]; return true; } @@ -1937,7 +1970,7 @@ class Parser protected function selectors(&$out) { $s = $this->seek(); - $selectors = array(); + $selectors = []; while ($this->selector($sel)) { $selectors[] = $sel; @@ -1971,11 +2004,11 @@ class Parser */ protected function selector(&$out) { - $selector = array(); + $selector = []; for (;;) { if ($this->match('[>+~]+', $m)) { - $selector[] = array($m[0]); + $selector[] = [$m[0]]; continue; } @@ -1986,7 +2019,7 @@ class Parser } if ($this->match('\/[^\/]+\/', $m)) { - $selector[] = array($m[0]); + $selector[] = [$m[0]]; continue; } @@ -2017,7 +2050,7 @@ class Parser $oldWhite = $this->eatWhiteDefault; $this->eatWhiteDefault = false; - $parts = array(); + $parts = []; if ($this->literal('*', false)) { $parts[] = '*'; @@ -2091,7 +2124,7 @@ class Parser $ss = $this->seek(); if ($this->literal('(') && - ($this->openString(')', $str, '(') || true ) && + ($this->openString(')', $str, '(') || true) && $this->literal(')') ) { $parts[] = '('; @@ -2111,60 +2144,23 @@ class Parser $this->seek($s); // attribute selector - // TODO: replace with open string? - if ($this->literal('[', false)) { - $attrParts = array('['); + if ($this->literal('[') && + ($this->openString(']', $str, '[') || true) && + $this->literal(']') + ) { + $parts[] = '['; - // keyword, string, operator - for (;;) { - if ($this->literal(']', false)) { - $this->count--; - break; // get out early - } - - if ($this->match('\s+', $m)) { - $attrParts[] = ' '; - continue; - } - - if ($this->string($str)) { - $attrParts[] = $str; - continue; - } - - if ($this->keyword($word)) { - $attrParts[] = $word; - continue; - } - - if ($this->interpolation($inter, false)) { - $attrParts[] = $inter; - continue; - } - - // operator, handles attr namespace too - if ($this->match('[|-~\$\*\^=]+', $m)) { - $attrParts[] = $m[0]; - continue; - } - - break; + if (! empty($str)) { + $parts[] = $str; } - if ($this->literal(']', false)) { - $attrParts[] = ']'; + $parts[] = ']'; - foreach ($attrParts as $part) { - $parts[] = $part; - } - - continue; - } - - $this->seek($s); - // TODO: should just break here? + continue; } + $this->seek($s); + break; } @@ -2191,7 +2187,7 @@ class Parser $s = $this->seek(); if ($this->literal('$', false) && $this->keyword($name)) { - $out = array(Type::T_VARIABLE, $name); + $out = [Type::T_VARIABLE, $name]; return true; } @@ -2212,7 +2208,9 @@ class Parser protected function keyword(&$word, $eatWhitespace = null) { if ($this->match( - '(([\w_\-\*!"\']|[\\\\].)([\w\-_"\']|[\\\\].)*)', + $this->utf8 + ? '(([\pL\w_\-\*!"\']|[\\\\].)([\pL\w\-_"\']|[\\\\].)*)' + : '(([\w_\-\*!"\']|[\\\\].)([\w\-_"\']|[\\\\].)*)', $m, $eatWhitespace )) { @@ -2233,7 +2231,12 @@ class Parser */ protected function placeholder(&$placeholder) { - if ($this->match('([\w\-_]+|#[{][$][\w\-_]+[}])', $m)) { + if ($this->match( + $this->utf8 + ? '([\pL\w\-_]+|#[{][$][\pL\w\-_]+[}])' + : '([\w\-_]+|#[{][$][\w\-_]+[}])', + $m + )) { $placeholder = $m[1]; return true; @@ -2252,7 +2255,7 @@ class Parser protected function url(&$out) { if ($this->match('(url\(\s*(["\']?)([^)]+)\2\s*\))', $m)) { - $out = array(Type::T_STRING, '', array('url(' . $m[2] . $m[3] . $m[2] . ')')); + $out = [Type::T_STRING, '', ['url(' . $m[2] . $m[3] . $m[2] . ')']]; return true; } @@ -2293,7 +2296,7 @@ class Parser for ($token = &$value; $token[0] === Type::T_LIST && ($s = count($token[2])); $token = &$lastNode) { $lastNode = &$token[2][$s - 1]; - if ($lastNode[0] === Type::T_KEYWORD && in_array($lastNode[1], array('!default', '!global'))) { + if ($lastNode[0] === Type::T_KEYWORD && in_array($lastNode[1], ['!default', '!global'])) { array_pop($token[2]); $token = $this->flattenList($token); @@ -2305,6 +2308,29 @@ class Parser return false; } + /** + * Strip optional flag from selector list + * + * @param array $selectors + * + * @return string + */ + protected function stripOptionalFlag(&$selectors) + { + $optional = false; + + $selector = end($selectors); + $part = end($selector); + + if ($part === ['!optional']) { + array_pop($selectors[count($selectors) - 1]); + + $optional = true; + } + + return $optional; + } + /** * Turn list of length 1 into value type * @@ -2374,4 +2400,79 @@ class Parser { return preg_quote($what, '/'); } + + /** + * Extract line numbers from buffer + * + * @param string $buffer + */ + private function extractLineNumbers($buffer) + { + $this->sourcePositions = [0 => 0]; + $prev = 0; + + while (($pos = strpos($buffer, "\n", $prev)) !== false) { + $this->sourcePositions[] = $pos; + $prev = $pos + 1; + } + + $this->sourcePositions[] = strlen($buffer); + + if (substr($buffer, -1) !== "\n") { + $this->sourcePositions[] = strlen($buffer) + 1; + } + } + + /** + * Get source line number and column (given character position in the buffer) + * + * @param integer $pos + * + * @return integer + */ + private function getSourcePosition($pos) + { + $low = 0; + $high = count($this->sourcePositions); + + while ($low < $high) { + $mid = (int) (($high + $low) / 2); + + if ($pos < $this->sourcePositions[$mid]) { + $high = $mid - 1; + continue; + } + + if ($pos >= $this->sourcePositions[$mid + 1]) { + $low = $mid + 1; + continue; + } + + return [$mid + 1, $pos - $this->sourcePositions[$mid]]; + } + + return [$low + 1, $pos - $this->sourcePositions[$low]]; + } + + /** + * Save internal encoding + */ + private function saveEncoding() + { + if (ini_get('mbstring.func_overload') & 2) { + $this->encoding = mb_internal_encoding(); + + mb_internal_encoding('iso-8859-1'); + } + } + + /** + * Restore internal encoding + */ + private function restoreEncoding() + { + if ($this->encoding) { + mb_internal_encoding($this->encoding); + } + } } diff --git a/vendor/leafo/scssphp/src/Server.php b/vendor/leafo/scssphp/src/Server.php index 9095e357f..221655cad 100644 --- a/vendor/leafo/scssphp/src/Server.php +++ b/vendor/leafo/scssphp/src/Server.php @@ -12,10 +12,11 @@ namespace Leafo\ScssPhp; use Leafo\ScssPhp\Compiler; +use Leafo\ScssPhp\Exception\ServerException; use Leafo\ScssPhp\Version; /** - * SCSS server + * Server * * @author Leaf Corcoran */ @@ -115,13 +116,12 @@ class Server /** * Determine whether .scss file needs to be re-compiled. * - * @param string $in Input path * @param string $out Output path * @param string $etag ETag * * @return boolean True if compile required. */ - protected function needsCompile($in, $out, &$etag) + protected function needsCompile($out, &$etag) { if (! is_file($out)) { return true; @@ -207,21 +207,21 @@ class Server $elapsed = round((microtime(true) - $start), 4); $v = Version::VERSION; - $t = @date('r'); + $t = date('r'); $css = "/* compiled by scssphp $v on $t (${elapsed}s) */\n\n" . $css; $etag = md5($css); file_put_contents($out, $css); file_put_contents( $this->metadataName($out), - serialize(array( + serialize([ 'etag' => $etag, 'imports' => $this->scss->getParsedFiles(), 'vars' => crc32(serialize($this->scss->getVariables())), - )) + ]) ); - return array($css, $etag); + return [$css, $etag]; } /** @@ -231,11 +231,11 @@ class Server * * @return string */ - protected function createErrorCSS($error) + protected function createErrorCSS(\Exception $error) { $message = str_replace( - array("'", "\n"), - array("\\'", "\\A"), + ["'", "\n"], + ["\\'", "\\A"], $error->getfile() . ":\n\n" . $error->getMessage() ); @@ -269,11 +269,13 @@ class Server * @param string $out Output file (.css) optional * * @return string|bool + * + * @throws \Leafo\ScssPhp\Exception\ServerException */ public function compileFile($in, $out = null) { if (! is_readable($in)) { - throw new \Exception('load error: failed to find ' . $in); + throw new ServerException('load error: failed to find ' . $in); } $pi = pathinfo($in); @@ -323,7 +325,7 @@ class Server $output = $this->cacheName($salt . $input); $etag = $noneMatch = trim($this->getIfNoneMatchHeader(), '"'); - if ($this->needsCompile($input, $output, $etag)) { + if ($this->needsCompile($output, $etag)) { try { list($css, $etag) = $this->compile($input, $output); @@ -334,7 +336,6 @@ class Server header('ETag: "' . $etag . '"'); echo $css; - } catch (\Exception $e) { if ($this->showErrorsAsCSS) { header('Content-type: text/css'); @@ -346,7 +347,6 @@ class Server echo 'Parse error: ' . $e->getMessage() . "\n"; } - } return; @@ -365,7 +365,7 @@ class Server $modifiedSince = $this->getIfModifiedSinceHeader(); $mtime = filemtime($output); - if (@strtotime($modifiedSince) === $mtime) { + if (strtotime($modifiedSince) === $mtime) { header($protocol . ' 304 Not Modified'); return; @@ -395,19 +395,19 @@ class Server * * @return string Compiled CSS results * - * @throws \Exception + * @throws \Leafo\ScssPhp\Exception\ServerException */ public function checkedCachedCompile($in, $out, $force = false) { if (! is_file($in) || ! is_readable($in)) { - throw new \Exception('Invalid or unreadable input file specified.'); + throw new ServerException('Invalid or unreadable input file specified.'); } if (is_dir($out) || ! is_writable(file_exists($out) ? $out : dirname($out))) { - throw new \Exception('Invalid or unwritable output file specified.'); + throw new ServerException('Invalid or unwritable output file specified.'); } - if ($force || $this->needsCompile($in, $out, $etag)) { + if ($force || $this->needsCompile($out, $etag)) { list($css, $etag) = $this->compile($in, $out); } else { $css = file_get_contents($out); @@ -444,6 +444,10 @@ class Server $this->scss = $scss; $this->showErrorsAsCSS = false; + + if (! ini_get('date.timezone')) { + date_default_timezone_set('UTC'); + } } /** diff --git a/vendor/leafo/scssphp/src/Type.php b/vendor/leafo/scssphp/src/Type.php index b750bbe46..8c3886c82 100644 --- a/vendor/leafo/scssphp/src/Type.php +++ b/vendor/leafo/scssphp/src/Type.php @@ -12,7 +12,7 @@ namespace Leafo\ScssPhp; /** - * SCSS block/node types + * Block/node types * * @author Anthon Pang */ @@ -59,6 +59,7 @@ class Type const T_NUMBER = 'number'; const T_RETURN = 'return'; const T_ROOT = 'root'; + const T_SCSSPHP_IMPORT_ONCE = 'scssphp-import-once'; const T_SELF = 'self'; const T_STRING = 'string'; const T_UNARY = 'unary'; diff --git a/vendor/leafo/scssphp/src/Util.php b/vendor/leafo/scssphp/src/Util.php index 714acdb89..9f47c1d79 100644 --- a/vendor/leafo/scssphp/src/Util.php +++ b/vendor/leafo/scssphp/src/Util.php @@ -14,7 +14,7 @@ namespace Leafo\ScssPhp; use Leafo\ScssPhp\Base\Range; /** - * SCSS utilties + * Utilties * * @author Anthon Pang */ diff --git a/vendor/leafo/scssphp/src/Version.php b/vendor/leafo/scssphp/src/Version.php index 9216885a6..8dfa0e931 100644 --- a/vendor/leafo/scssphp/src/Version.php +++ b/vendor/leafo/scssphp/src/Version.php @@ -18,5 +18,5 @@ namespace Leafo\ScssPhp; */ class Version { - const VERSION = 'v0.4.0'; + const VERSION = 'v0.6.3'; } From 1bf110439ad5192f8aae10127609761c4103a3e6 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Tue, 22 Mar 2016 11:29:05 +0900 Subject: [PATCH 09/10] Update Formatter class to use new SCSS compiler --- common/framework/formatter.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/framework/formatter.php b/common/framework/formatter.php index da2e87b9b..6865a17c1 100644 --- a/common/framework/formatter.php +++ b/common/framework/formatter.php @@ -220,8 +220,8 @@ class Formatter // Compile! try { - $scss_compiler = new \scssc; - $scss_compiler->setFormatter($minify ? 'scss_formatter_compressed' : 'scss_formatter'); + $scss_compiler = new \Leafo\ScssPhp\Compiler; + $scss_compiler->setFormatter($minify ? '\Leafo\ScssPhp\Formatter\Crunched' : '\Leafo\ScssPhp\Formatter\Expanded'); $scss_compiler->setImportPaths(array(dirname(is_array($source_filename) ? array_first($source_filename) : $source_filename))); if ($variables) { From a0d9e1c6ad5e8745cfc3b64478b8c96a06f7ff69 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Tue, 22 Mar 2016 11:34:36 +0900 Subject: [PATCH 10/10] Remove outdated checks for old PHP versions --- classes/context/Context.class.php | 16 +--------------- common/framework/password.php | 4 ++-- common/framework/security.php | 8 ++++---- 3 files changed, 7 insertions(+), 21 deletions(-) diff --git a/classes/context/Context.class.php b/classes/context/Context.class.php index 3058d3a3c..1c1a61dad 100644 --- a/classes/context/Context.class.php +++ b/classes/context/Context.class.php @@ -1360,10 +1360,9 @@ class Context * @see Cast variables, such as _srl, page, and cpage, into interger * @param string $key Variable key * @param string $val Variable value - * @param string $do_stripslashes Whether to strip slashes * @return mixed filtered value. Type are string or array */ - public function _filterRequestVar($key, $val, $do_stripslashes = 1) + public function _filterRequestVar($key, $val) { if(!($isArray = is_array($val))) { @@ -1389,19 +1388,6 @@ class Context else { $result[$k] = $v; - - if($do_stripslashes && version_compare(PHP_VERSION, '5.4.0', '<') && get_magic_quotes_gpc()) - { - if (is_array($result[$k])) - { - array_walk_recursive($result[$k], function(&$val) { $val = stripslashes($val); }); - } - else - { - $result[$k] = stripslashes($result[$k]); - } - } - if(is_array($result[$k])) { array_walk_recursive($result[$k], function(&$val) { $val = trim($val); }); diff --git a/common/framework/password.php b/common/framework/password.php index caf9ef49a..a6831090b 100644 --- a/common/framework/password.php +++ b/common/framework/password.php @@ -79,11 +79,11 @@ class Password public static function getSupportedAlgorithms() { $retval = array(); - if (version_compare(PHP_VERSION, '5.3.7', '>=') && defined('\CRYPT_BLOWFISH')) + if (defined('\CRYPT_BLOWFISH')) { $retval['bcrypt'] = 'bcrypt'; } - if (function_exists('hash_hmac') && in_array('sha512', hash_algos())) + if (in_array('sha512', hash_algos())) { $retval['pbkdf2'] = 'pbkdf2'; } diff --git a/common/framework/security.php b/common/framework/security.php index 35abdda61..a474acb58 100644 --- a/common/framework/security.php +++ b/common/framework/security.php @@ -58,7 +58,7 @@ class Security $key = substr(hash('sha256', $key, true), 0, 16); // Use defuse/php-encryption if possible. - if (!$force_compat && version_compare(\PHP_VERSION, '5.4.0', '>=') && function_exists('openssl_encrypt')) + if (!$force_compat && function_exists('openssl_encrypt')) { try { @@ -96,7 +96,7 @@ class Security } // Use defuse/php-encryption if possible. - if (!$force_compat && version_compare(\PHP_VERSION, '5.4.0', '>=') && function_exists('openssl_decrypt')) + if (!$force_compat && function_exists('openssl_decrypt')) { try { @@ -147,11 +147,11 @@ class Security { $entropy = random_bytes($entropy_capped_bytes); } - elseif(function_exists('openssl_random_pseudo_bytes') && (!$is_windows || version_compare(\PHP_VERSION, '5.4', '>='))) + elseif(function_exists('openssl_random_pseudo_bytes')) { $entropy = openssl_random_pseudo_bytes($entropy_capped_bytes); } - elseif(function_exists('mcrypt_create_iv') && (!$is_windows || version_compare(\PHP_VERSION, '5.3.7', '>='))) + elseif(function_exists('mcrypt_create_iv') && !$is_windows) { $entropy = mcrypt_create_iv($entropy_capped_bytes, \MCRYPT_DEV_URANDOM); }