Skip to content

Commit

Permalink
cleaned up syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
cgarvis committed Feb 16, 2012
1 parent a31cadb commit b746e26
Show file tree
Hide file tree
Showing 20 changed files with 52 additions and 47 deletions.
2 changes: 0 additions & 2 deletions action/Response.php
Expand Up @@ -8,8 +8,6 @@

namespace lithium\action;

use BadMethodCallException;

/**
* A `Response` object is typically instantiated automatically by the `Controller`. It is assigned
* any headers set in the course of the request, as well as any content rendered by the
Expand Down
15 changes: 8 additions & 7 deletions data/source/Http.php
Expand Up @@ -101,14 +101,14 @@ public function __get($property) {
}

/**
* Pass methods to service connection. Path and method are determined from Http::$_method. If not
* set, a GET request with the $method as the path will be used.
* Pass methods to service connection. Path and method are determined from Http::$_method. If
* not set, a GET request with the $method as the path will be used.
*
* @see lithium\data\source\Http::$_method
* @param string $method
* @param array $params
* @return mixed
* @filter
* @see lithium\data\source\Http::$_method
*/
public function __call($method, $params) {
$params += array(array(), array());
Expand All @@ -120,20 +120,21 @@ public function __call($method, $params) {
}

if (!isset($string['path'])) {
$string['path'] = '/'.$method;
$string['path'] = '/' . $method;
}

$conn =& $this->connection;
$filter = function($self, $params) use (&$conn, $string) {
list($query, $options) = $params;

if(is_object($query)) {
if (is_object($query)) {
$options += array_filter($query->export($self), function($v) {
return $v !== null;
});
$data = $query->data();
} else {
$data = in_array($string['method'], array('post', 'put')) ? (array) $query : array();
$data = in_array($string['method'], array('post', 'put')) ?
(array) $query : array();
}

preg_match_all('/\{:(\w+)\}/', $string['path'], $matches);
Expand Down Expand Up @@ -279,4 +280,4 @@ public function name($name) {
}
}

?>
?>
4 changes: 2 additions & 2 deletions net/http/Media.php
Expand Up @@ -249,7 +249,7 @@ public static function type($type, $content = null, array $options = array()) {
return compact('content') + array('options' => static::_handlers($type));
}
if ($content) {
static::$_types[$type] = (array)$content;
static::$_types[$type] = (array) $content;
}
static::$_handlers[$type] = $options ? Set::merge($defaults, $options) : array();
}
Expand Down Expand Up @@ -867,4 +867,4 @@ protected static function _assets($type = null) {
}
}

?>
?>
10 changes: 5 additions & 5 deletions net/http/Request.php
Expand Up @@ -98,10 +98,10 @@ public function __construct(array $config = array()) {
*/
protected function _encode($body) {
$media = $this->_classes['media'];
if($type = $media::type($this->_type)) {
if ($type = $media::type($this->_type)) {
$body = $media::encode($this->_type, $body) ?: $body;
}
if(is_array($body)) {
if (is_array($body)) {
$body = join("\r\n", $body);
}
return $body;
Expand Down Expand Up @@ -240,9 +240,9 @@ public function to($format, array $options = array()) {
$this->headers('Authorization', "Basic {$auth}");
}
}
if(in_array($options['method'], array('POST', 'PUT'))) {
if (in_array($options['method'], array('POST', 'PUT'))) {
$media = $this->_classes['media'];
if($type = $media::type($this->_type)) {
if ($type = $media::type($this->_type)) {
$this->headers('Content-Type', $type['content'][0]);
}
}
Expand Down Expand Up @@ -284,4 +284,4 @@ public function __toString() {
}
}

?>
?>
4 changes: 2 additions & 2 deletions net/http/Response.php
Expand Up @@ -128,7 +128,7 @@ protected function _init() {
*/
protected function _decode($body) {
$media = $this->_classes['media'];
if($type = $media::type($this->_type)) {
if ($type = $media::type($this->_type)) {
$body = $media::decode($this->_type, $body) ?: $body;
}
return $body;
Expand Down Expand Up @@ -252,4 +252,4 @@ public function __toString() {
}
}

?>
?>
2 changes: 1 addition & 1 deletion net/http/Service.php
Expand Up @@ -222,4 +222,4 @@ protected function _request($method, $path, $data, $options) {
}
}

?>
?>
2 changes: 1 addition & 1 deletion net/socket/Curl.php
Expand Up @@ -197,4 +197,4 @@ public function set($flags, $value = null) {
}
}

?>
?>
2 changes: 1 addition & 1 deletion storage/session/strategy/Encrypt.php
Expand Up @@ -267,4 +267,4 @@ protected static function _vectorSize() {
}
}

?>
?>
6 changes: 3 additions & 3 deletions template/helper/Html.php
Expand Up @@ -126,9 +126,9 @@ public function charset($encoding = null) {
*
* @param string $title The content to be wrapped by an `<a />` tag.
* @param mixed $url Can be a string representing a URL relative to the base of your Lithium
* application, an external URL (starts with `'http://'` or `'https://'`), an anchor
* name starting with `'#'` (i.e. `'#top'`), or an array defining a set of request
* parameters that should be matched against a route in `Router`.
* application, an external URL (starts with `'http://'` or `'https://'`), an
* anchor name starting with `'#'` (i.e. `'#top'`), or an array defining a set
* of request parameters that should be matched against a route in `Router`.
* @param array $options Array of HTML s and other options.
* @return string Returns an `<a />` or `<link />` element.
*/
Expand Down
2 changes: 1 addition & 1 deletion tests/cases/action/ControllerTest.php
Expand Up @@ -374,4 +374,4 @@ public function testNonExistentFunction() {
}
}

?>
?>
8 changes: 4 additions & 4 deletions tests/cases/console/command/RouteTest.php
Expand Up @@ -206,7 +206,7 @@ public function testShowWithInvalidRoute() {
);
$command = new Route(compact('request') + array(
'routes' => $this->_config['routes'],
'classes' => array('response' => 'lithium\tests\mocks\console\MockResponse'),
'classes' => array('response' => 'lithium\tests\mocks\console\MockResponse')
));
$command->show();

Expand All @@ -222,7 +222,7 @@ public function testShowWithValidRoute() {
$request->params = array('args' => array('/'));
$command = new Route(compact('request') + array(
'routes' => $this->_config['routes'],
'classes' => array('response' => 'lithium\tests\mocks\console\MockResponse'),
'classes' => array('response' => 'lithium\tests\mocks\console\MockResponse')
));
$command->show();

Expand All @@ -241,7 +241,7 @@ public function testShowWithEnvironment() {
);
$command = new Route(compact('request') + array(
'routes' => $this->_config['routes'],
'classes' => array('response' => 'lithium\tests\mocks\console\MockResponse'),
'classes' => array('response' => 'lithium\tests\mocks\console\MockResponse')
));

$command->show();
Expand All @@ -262,7 +262,7 @@ public function testShowWithHttpMethod() {
);
$command = new Route(compact('request') + array(
'routes' => $this->_config['routes'],
'classes' => array('response' => 'lithium\tests\mocks\console\MockResponse'),
'classes' => array('response' => 'lithium\tests\mocks\console\MockResponse')
));

$command->show();
Expand Down
1 change: 0 additions & 1 deletion tests/cases/data/ModelTest.php
Expand Up @@ -9,7 +9,6 @@
namespace lithium\tests\cases\data;

use lithium\data\Model;
use lithium\data\Entity;
use lithium\data\model\Query;
use lithium\data\Connections;
use lithium\data\entity\Record;
Expand Down
2 changes: 1 addition & 1 deletion tests/cases/data/source/HttpTest.php
Expand Up @@ -321,4 +321,4 @@ public function testCustomPostMethodWithModel() {
}
}

?>
?>
7 changes: 5 additions & 2 deletions tests/cases/net/http/MediaTest.php
Expand Up @@ -51,7 +51,10 @@ public function testMediaTypes() {
$this->assertEqual($expected, $result['options']);

// Add a custom media type with a custom view class:
Media::type('my', 'text/x-my', array('view' => 'my\custom\View', 'paths' => array('layout' => false)));
Media::type('my', 'text/x-my', array(
'view' => 'my\custom\View',
'paths' => array('layout' => false)
));

$result = Media::types();
$this->assertTrue(in_array('my', $result));
Expand Down Expand Up @@ -625,4 +628,4 @@ public function testContentNegotiationByUserAgent() {
}
}

?>
?>
2 changes: 1 addition & 1 deletion tests/cases/net/socket/CurlTest.php
Expand Up @@ -155,4 +155,4 @@ public function testSendPostThenGet() {
}
}

?>
?>
18 changes: 12 additions & 6 deletions tests/cases/template/helper/FormTest.php
Expand Up @@ -467,18 +467,24 @@ public function testCustomValueCheckbox() {

public function testRadioGeneration() {
$result = $this->form->radio('foo');
$this->assertTags($result, array(
array('input' => array('type' => 'radio', 'value' => '1', 'name' => 'foo', 'id' => 'Foo'))
$this->assertTags($result, array(array(
'input' => array('type' => 'radio', 'value' => '1', 'name' => 'foo', 'id' => 'Foo'))
));

$result = $this->form->radio('foo', array('checked' => false));
$this->assertTags($result, array(
array('input' => array('type' => 'radio', 'value' => '1', 'name' => 'foo', 'id' => 'Foo'))
$this->assertTags($result, array(array(
'input' => array('type' => 'radio', 'value' => '1', 'name' => 'foo', 'id' => 'Foo'))
));

$result = $this->form->radio('foo', array('checked' => true));
$this->assertTags($result, array(
array('input' => array('type' => 'radio', 'value' => '1', 'name' => 'foo', 'checked' => 'checked', 'id' => 'Foo'))
$this->assertTags($result, array(array(
'input' => array(
'type' => 'radio',
'value' => '1',
'name' => 'foo',
'checked' => 'checked',
'id' => 'Foo')
)
));

$record = new Record(array('model' => $this->_model, 'data' => array('foo' => true)));
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/data/CrudTest.php
Expand Up @@ -162,7 +162,7 @@ public function testUpdateWithNewProperties() {
protected static function _createCompany() {
Companies::create(array(
'name' => 'Acme, Inc.',
'active' => true,
'active' => true
))->save();
}
}
Expand Down
1 change: 0 additions & 1 deletion tests/integration/data/SourceTest.php
Expand Up @@ -8,7 +8,6 @@

namespace lithium\tests\integration\data;

use Exception;
use lithium\data\Connections;
use lithium\tests\mocks\data\Companies;
use lithium\tests\mocks\data\Employees;
Expand Down
5 changes: 2 additions & 3 deletions tests/integration/net/http/MediaTest.php
Expand Up @@ -8,7 +8,6 @@

namespace lithium\tests\integration\net\http;

use lithium\template\View;
use lithium\net\http\Media;
use lithium\net\http\Response;

Expand All @@ -27,7 +26,7 @@ public function testMediaTypeViewRender() {
'layout' => false,
'template' => array(
'{:library}/tests/mocks/template/view/adapters/{:template}.{:type}.php',
'{:library}/tests/mocks/template/view/adapters/{:template}.html.php',
'{:library}/tests/mocks/template/view/adapters/{:template}.html.php'
)
)
));
Expand Down Expand Up @@ -59,7 +58,7 @@ public function testMediaTypeViewRender() {
'layout' => '{:library}/tests/mocks/template/view/adapters/testLayoutFile.html.php',
'template' => array(
'{:library}/tests/mocks/template/view/adapters/{:template}.{:type}.php',
'{:library}/tests/mocks/template/view/adapters/{:template}.html.php',
'{:library}/tests/mocks/template/view/adapters/{:template}.html.php'
)
)
));
Expand Down
4 changes: 2 additions & 2 deletions tests/mocks/data/MockCompanies.php
Expand Up @@ -6,12 +6,12 @@ class MockCompanies extends \lithium\data\Model {
public $hasMany = array(
'Employees' => array(
'key' => array('id' => 'company_id'),
'to' => 'lithium\\tests\\mocks\\data\\MockEmployees',
'to' => 'lithium\\tests\\mocks\\data\\MockEmployees'
)
);
protected $_meta = array(
'source' => 'companies',
'connection' => 'lithium_mysql_test',
'connection' => 'lithium_mysql_test'
);
}

Expand Down

0 comments on commit b746e26

Please sign in to comment.