Permalink
Browse files

Merge branch 'dev'

  • Loading branch information...
2 parents 505c158 + 05abf7b commit 7a9faef1247e28849586a79c7fa186495f1a1ab1 @nateabele nateabele committed Feb 1, 2013
Showing 398 changed files with 4,384 additions and 1,018 deletions.
View
@@ -8,9 +8,13 @@ php:
- 5.3
- 5.4
-before_script: php tests/ci_depends.php $OPCODE_CACHE
+before_script:
+ - php tests/ci_depends.php $OPCODE_CACHE
+# - cd ../ && git clone git://github.com/UnionOfRAD/li3_quality.git && cd lithium
-script: console/li3 test --filters=Profiler tests/cases
+script:
+ - console/li3 test --filters=Profiler tests/cases
+# - console/li3 test --filters=Profiler tests/cases && cd ../li3_quality && for FILE in $(cd ../lithium/ && git diff-index --name-only --diff-filter=AM HEAD~1); do ../lithium/console/li3 quality syntax ../lithium/${FILE} --silent; done
notifications:
irc: "irc.freenode.org#li3-core"
View
@@ -1,4 +1,4 @@
-Copyright (c) 2012, Union of RAD http://union-of-rad.org
+Copyright (c) 2013, Union of RAD http://union-of-rad.org
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
View
@@ -174,7 +174,7 @@ public function __invoke($request, $dispatchParams, array $options = array()) {
$args = isset($dispatchParams['args']) ? $dispatchParams['args'] : array();
$result = null;
- if (substr($action, 0, 1) == '_' || method_exists(__CLASS__, $action)) {
+ if (substr($action, 0, 1) === '_' || method_exists(__CLASS__, $action)) {
throw new DispatchException('Attempted to invoke a private method.');
}
if (!method_exists($self, $action)) {
View
@@ -231,12 +231,12 @@ public function __isset($name) {
* @todo Refactor to lazy-load environment settings
*/
public function env($key) {
- if (strtolower($key) == 'base') {
+ if (strtolower($key) === 'base') {
return $this->_base;
}
- if ($key == 'SCRIPT_NAME' && !isset($this->_env['SCRIPT_NAME'])) {
- if ($this->_env['PLATFORM'] == 'CGI' || isset($this->_env['SCRIPT_URL'])) {
+ if ($key === 'SCRIPT_NAME' && !isset($this->_env['SCRIPT_NAME'])) {
+ if ($this->_env['PLATFORM'] === 'CGI' || isset($this->_env['SCRIPT_URL'])) {
$key = 'SCRIPT_URL';
}
}
@@ -245,7 +245,8 @@ public function env($key) {
$this->_env[$key] = $val;
if ($key == 'REMOTE_ADDR') {
- foreach (array('HTTP_X_FORWARDED_FOR', 'HTTP_PC_REMOTE_ADDR', 'HTTP_X_REAL_IP') as $altKey) {
+ $https = array('HTTP_X_FORWARDED_FOR', 'HTTP_PC_REMOTE_ADDR', 'HTTP_X_REAL_IP');
+ foreach ($https as $altKey) {
if ($addr = $this->env($altKey)) {
$val = $addr;
break;
@@ -287,7 +288,7 @@ public function env($key) {
));
case 'CGI':
case 'CGI_MODE':
- return ($this->_env['PLATFORM'] == 'CGI');
+ return ($this->_env['PLATFORM'] === 'CGI');
case 'HTTP_BASE':
return preg_replace('/^([^.])*/i', null, $this->_env['HTTP_HOST']);
}
@@ -327,7 +328,7 @@ protected function _parseAccept() {
foreach (array_reverse($accept) as $i => $type) {
unset($accept[$i]);
list($type, $q) = (explode(';q=', $type, 2) + array($type, 1.0 + $i / 100));
- $accept[$type] = ($type == '*/*') ? 0.1 : floatval($q);
+ $accept[$type] = ($type === '*/*') ? 0.1 : floatval($q);
}
arsort($accept, SORT_NUMERIC);
@@ -513,7 +514,7 @@ public function referer($default = null, $local = false) {
if (!$local) {
return $ref;
}
- if (strpos($ref, '://') == false) {
+ if (strpos($ref, '://') === false) {
return $ref;
}
}
@@ -581,7 +582,7 @@ protected function _url() {
if (isset($this->_config['url'])) {
return rtrim($this->_config['url'], '/');
}
- if (!empty($_GET['url']) ) {
+ if (!empty($_GET['url'])) {
return rtrim($_GET['url'], '/');
}
if ($uri = $this->env('REQUEST_URI')) {
View
@@ -16,7 +16,7 @@
* The `Debugger` class provides basic facilities for generating and rendering meta-data about the
* state of an application in its current context.
*/
-class Debugger extends \lithium\core\Object {
+class Debugger extends \lithium\core\StaticObject {
/**
* Used for temporary closure caching.
@@ -87,7 +87,7 @@ public static function trace(array $options = array()) {
}
$trace['functionRef'] = $function;
- if ($options['format'] == 'points' && $trace['file'] != '[internal]') {
+ if ($options['format'] === 'points' && $trace['file'] !== '[internal]') {
$back[] = array('file' => $trace['file'], 'line' => $trace['line']);
} elseif (is_string($options['format']) && $options['format'] != 'array') {
$back[] = String::insert($options['format'], array_map(
@@ -108,7 +108,7 @@ function($data) { return is_object($data) ? get_class($data) : $data; },
}
}
- if ($options['format'] == 'array' || $options['format'] == 'points') {
+ if ($options['format'] === 'array' || $options['format'] === 'points') {
return $back;
}
return join("\n", $back);
View
@@ -49,6 +49,22 @@ class Inspector extends \lithium\core\StaticObject {
);
/**
+ * Will determine if a method can be called.
+ *
+ * @param string|object $class Class to inspect.
+ * @param string $method Method name.
+ * @param bool $internal Interal call or not.
+ * @return bool
+ */
+ public static function isCallable($object, $method, $internal = false) {
+ $methodExists = method_exists($object, $method);
+ $callable = function($object, $method) {
+ return is_callable(array($object, $method));
+ };
+ return $internal ? $methodExists : $methodExists && $callable($object, $method);
+ }
+
+ /**
* Determines if a given $identifier is a class property, a class method, a class itself,
* or a namespace identifier.
*
@@ -88,7 +104,7 @@ public static function info($identifier, $info = array()) {
$result = array();
$class = null;
- if ($type == 'method' || $type == 'property') {
+ if ($type === 'method' || $type === 'property') {
list($class, $identifier) = explode('::', $identifier);
try {
@@ -97,7 +113,7 @@ public static function info($identifier, $info = array()) {
return null;
}
- if ($type == 'property') {
+ if ($type === 'property') {
$identifier = substr($identifier, 1);
$accessor = 'getProperty';
} else {
@@ -111,7 +127,7 @@ public static function info($identifier, $info = array()) {
return null;
}
$result['modifiers'] = static::_modifiers($inspector);
- } elseif ($type == 'class') {
+ } elseif ($type === 'class') {
$inspector = new ReflectionClass($identifier);
} else {
return null;
@@ -123,7 +139,7 @@ public static function info($identifier, $info = array()) {
}
if (method_exists($inspector, static::$_methodMap[$key])) {
$setAccess = (
- ($type == 'method' || $type == 'property') &&
+ ($type === 'method' || $type === 'property') &&
array_intersect($result['modifiers'], array('private', 'protected')) != array()
&& method_exists($inspector, 'setAccessible')
);
@@ -140,7 +156,7 @@ public static function info($identifier, $info = array()) {
}
}
- if ($type == 'property' && !$classInspector->isAbstract()) {
+ if ($type === 'property' && !$classInspector->isAbstract()) {
$inspector->setAccessible(true);
try {
@@ -231,7 +247,7 @@ function($ln) use ($start) { return $ln + $start - 1; },
$result = array_keys(array_filter($lines, function($line) use ($options) {
$line = trim($line);
$empty = preg_match($options['pattern'], $line);
- return $empty ? false : (str_replace($options['empty'], '', $line) != '');
+ return $empty ? false : (str_replace($options['empty'], '', $line) !== '');
}));
}
return $result;
@@ -373,7 +389,7 @@ public static function lines($data, $lines) {
$file = new SplFileObject($data);
foreach ($file as $current) {
- $c[$file->key()+1] = rtrim($file->current());
+ $c[$file->key() + 1] = rtrim($file->current());
}
}
@@ -434,17 +450,19 @@ function($class) { return new ReflectionClass($class); }, $list
include $file;
$list = array_diff(get_declared_classes(), $list);
} else {
- $filter = function($class) use ($file) { return $class->getFileName() == $file; };
- $list = $loaded->find($filter)->getName();
+ $filter = function($class) use ($file) { return $class->getFileName() === $file; };
+ $list = $loaded->find($filter)->map(function ($class) {
+ return $class->getName() ?: $class->name;
+ }, array('collect' => false));
}
}
foreach ($list as $class) {
$inspector = new ReflectionClass($class);
- if ($options['group'] == 'classes') {
+ if ($options['group'] === 'classes') {
$inspector->getFileName() ? $classes[$class] = $inspector->getFileName() : null;
- } elseif ($options['group'] == 'files') {
+ } elseif ($options['group'] === 'files') {
$classes[$inspector->getFileName()][] = $inspector;
}
}
@@ -543,7 +561,7 @@ protected static function _items($class, $method, $options) {
if ($options['self']) {
$data = array_filter($data, function($item) use ($class) {
- return ($item->getDeclaringClass()->getName() == $class->getName());
+ return ($item->getDeclaringClass()->getName() === $class->getName());
});
}
View
@@ -140,6 +140,17 @@ public static function __callStatic($priority, $params) {
}
/**
+ * Custom check to determine if our given magic methods can be responded to.
+ *
+ * @param string $method Method name.
+ * @param bool $internal Interal call or not.
+ * @return bool
+ */
+ public static function respondsTo($method, $internal = false) {
+ return isset(static::$_priorities[$method]) || parent::respondsTo($method, $internal);
+ }
+
+ /**
* This method is called automatically to initialize the default configuration of a log adapter,
* such that the adapter defaults to accepting log messages of any priority (i.e. the
* `'priority'` key is set to `true`).
View
@@ -75,9 +75,7 @@ public static function tokenize($code, array $options = array()) {
}
$tokens[] = array('id' => $id, 'name' => $name, 'content' => $content, 'line' => $line);
- if ($id === T_WHITESPACE) {
- $line += count(preg_split('/\r\n|\r|\n/', $content)) - 1;
- }
+ $line += count(preg_split('/\r\n|\r|\n/', $content)) - 1;
}
if ($options['wrap'] && empty($options['include'])) {
@@ -272,13 +270,13 @@ public static function matchToken($pattern, $token) {
$match = $pattern['content'];
$content = $token['content'];
- if ($pattern['name'] == 'T_VARIABLE') {
+ if ($pattern['name'] === 'T_VARIABLE') {
$match = substr($match, 1);
$content = substr($content, 1);
}
switch (true) {
- case ($match == '_' || $match == $content):
+ case ($match === '_' || $match == $content):
return true;
}
return false;
View
@@ -2,7 +2,7 @@
/**
* Lithium: the most rad php framework
*
- * @copyright Copyright 2012, Union of RAD (http://union-of-rad.org)
+ * @copyright Copyright 2013, Union of RAD (http://union-of-rad.org)
* @license http://opensource.org/licenses/bsd-license.php The BSD License
*/
@@ -224,7 +224,7 @@ public function in($prompt = null, array $options = array()) {
} while (
!empty($options['choices']) && !in_array($result, $options['choices'], true)
&& (empty($options['quit']) || $result !== $options['quit'])
- && ($options['default'] == null || $result !== '')
+ && (!$options['default'] || $result !== '')
);
if ($result == $options['quit']) {
View
@@ -2,7 +2,7 @@
/**
* Lithium: the most rad php framework
*
- * @copyright Copyright 2012, Union of RAD (http://union-of-rad.org)
+ * @copyright Copyright 2013, Union of RAD (http://union-of-rad.org)
* @license http://opensource.org/licenses/bsd-license.php The BSD License
*/
View
@@ -2,7 +2,7 @@
/**
* Lithium: the most rad php framework
*
- * @copyright Copyright 2012, Union of RAD (http://union-of-rad.org)
+ * @copyright Copyright 2013, Union of RAD (http://union-of-rad.org)
* @license http://opensource.org/licenses/bsd-license.php The BSD License
*/
View
@@ -2,7 +2,7 @@
/**
* Lithium: the most rad php framework
*
- * @copyright Copyright 2012, Union of RAD (http://union-of-rad.org)
+ * @copyright Copyright 2013, Union of RAD (http://union-of-rad.org)
* @license http://opensource.org/licenses/bsd-license.php The BSD License
*/
@@ -209,7 +209,7 @@ protected function _instance($name, array $config = array()) {
return new $class(array(
'request' => $this->request,
- 'classes'=> $this->_classes
+ 'classes' => $this->_classes
));
}
return parent::_instance($name, $config);
@@ -245,7 +245,7 @@ protected function _save(array $params = array()) {
if (file_exists($file)) {
$prompt = "{$relative} already exists. Overwrite?";
$choices = array('y', 'n');
- if ($this->in($prompt, compact('choices')) != 'y') {
+ if ($this->in($prompt, compact('choices')) !== 'y') {
return "{$params['class']} skipped.";
}
}
View
@@ -2,7 +2,7 @@
/**
* Lithium: the most rad php framework
*
- * @copyright Copyright 2012, Union of RAD (http://union-of-rad.org)
+ * @copyright Copyright 2013, Union of RAD (http://union-of-rad.org)
* @license http://opensource.org/licenses/bsd-license.php The BSD License
*/
View
@@ -2,7 +2,7 @@
/**
* Lithium: the most rad php framework
*
- * @copyright Copyright 2012, Union of RAD (http://union-of-rad.org)
+ * @copyright Copyright 2013, Union of RAD (http://union-of-rad.org)
* @license http://opensource.org/licenses/bsd-license.php The BSD License
*/
Oops, something went wrong.

0 comments on commit 7a9faef

Please sign in to comment.