Skip to content
This repository has been archived by the owner on Oct 4, 2018. It is now read-only.

Commit

Permalink
Convert remaining getAttribute() calls to ->: operator
Browse files Browse the repository at this point in the history
No new problems found.
  • Loading branch information
fredemmott committed Jan 29, 2015
1 parent 883baab commit 40fdc91
Show file tree
Hide file tree
Showing 18 changed files with 43 additions and 43 deletions.
4 changes: 2 additions & 2 deletions lib/xhp-bootstrap/alert.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ protected function compose(): :xhp {
$child->addClass('alert-link');
}
$ret =
<div class={$this->getAttribute('class')}>
<div class={$this->:class}>
{$this->getChildren()}
</div>;

$ret->addClass('alert');
$ret->addClass('alert-'.$this->getAttribute('use'));
$ret->addClass('alert-'.$this->:use);

return $ret;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/xhp-bootstrap/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,14 @@ public function getID(): string {
}

public function requireUniqueID(): string {
if (!($id = $this->getAttribute('id'))) {
if (!($id = $this->:id)) {
$this->setAttribute('id', $id = substr(md5(mt_rand(0, 100000)), 0, 10));
}
return $id;
}

public function addClass(string $class): this {
$this->setAttribute('class', trim($this->getAttribute('class').' '.$class));
$this->setAttribute('class', trim($this->:class.' '.$class));
return $this;
}

Expand Down
6 changes: 3 additions & 3 deletions lib/xhp-bootstrap/button-group.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ enum {
children ((:bootstrap:button|:bootstrap:button-group)+);

protected function compose(): :xhp {
$class = $this->getAttribute('orientation') === 'horizontal'
$class = $this->:orientation === 'horizontal'
? 'btn-group' : 'btn-group-vertical';
$ret = <div class={$class}>{$this->getChildren()}</div>;
switch ($this->getAttribute('size')) {
switch ($this->:size) {
case 'large':
$ret->addClass('btn-group-lg');
break;
Expand All @@ -42,7 +42,7 @@ protected function compose(): :xhp {
$ret->addClass('btn-group-xs');
break;
}
if ($this->getAttribute('justified')) {
if ($this->:justified) {
$ret->addClass('btn-group-justified');
}

Expand Down
12 changes: 6 additions & 6 deletions lib/xhp-bootstrap/button.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ enum {

protected function compose(): :xhp {
$ret =
<a href={$this->getAttribute('href')}>
<a href={$this->:href}>
{$this->getChildren()}
</a>;

$ret->addClass('btn');
$ret->addClass('btn-'.$this->getAttribute('use'));
$ret->addClass('btn-'.$this->:use);

switch ($this->getAttribute('size')) {
switch ($this->:size) {
case 'large':
$ret->addClass('btn-lg');
break;
Expand All @@ -53,13 +53,13 @@ protected function compose(): :xhp {
$ret->addClass('btn-xs');
break;
}
if ($this->getAttribute('block')) {
if ($this->:block) {
$ret->addClass('btn-block');
}
if ($this->getAttribute('active')) {
if ($this->:active) {
$ret->addClass('active');
}
if ($this->getAttribute('disabled')) {
if ($this->:disabled) {
$ret->addClass('disabled');
}
return $ret;
Expand Down
2 changes: 1 addition & 1 deletion lib/xhp-bootstrap/container.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protected function compose(): :xhp {
}
$this->addClass("container");
return
<div class={$this->getAttribute('class')}>
<div class={$this->:class}>
{$this->getChildren()}
</div>;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/xhp-bootstrap/dropdown/item.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected function compose(): :xhp {
</a>;

$ret = <li role="presentation">{$link}</li>;
if ($this->getAttribute('disabled')) {
if ($this->:disabled) {
$ret->addClass('disabled');
}
return $ret;
Expand Down
2 changes: 1 addition & 1 deletion lib/xhp-bootstrap/glyphicon.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ enum {

protected function compose(): :xhp {
$this->addClass('glyphicon');
$this->addClass('glyphicon-'.$this->getAttribute('icon'));
$this->addClass('glyphicon-'.$this->:icon);

return <span/>;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/xhp-bootstrap/jumbotron.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class :bootstrap:jumbotron extends :bootstrap:base {
string title;

protected function compose(): :xhp {
$title = $this->getAttribute('title');
$title = $this->:title;
if ($title) {
$title = <h1>{$title}</h1>;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/xhp-bootstrap/label.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ enum {

protected function compose(): :xhp {
$ret =
<span class={$this->getAttribute('class')}>
<span class={$this->:class}>
{$this->getChildren()}
</span>;
$ret->addClass('label');
$ret->addClass('label-'.$this->getAttribute('use'));
$ret->addClass('label-'.$this->:use);
return $ret;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/xhp-bootstrap/list-group/list-group-item.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ enum {

protected function compose(): :xhp {
$ret = <a>{$this->getChildren()}</a>;
if ($this->getAttribute('active')) {
if ($this->:active) {
$ret->addClass('active');
}
$ret->addClass('list-group-item');
switch ($this->getAttribute('use')) {
switch ($this->:use) {
case 'success':
$ret->addClass('list-group-item-success');
break;
Expand Down
2 changes: 1 addition & 1 deletion lib/xhp-bootstrap/navigation/brand.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class :bootstrap:navbar:brand extends :bootstrap:base {

protected function compose(): :xhp {
return
<a href={$this->getAttribute('href')} class="navbar-brand">
<a href={$this->:href} class="navbar-brand">
{$this->getChildren()}
</a>;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/xhp-bootstrap/navigation/nav.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ protected function compose(): :xhp {
{$this->getChildren()}
</ul>;

$ret->addClass('nav-'.$this->getAttribute('navstyle'));
$ret->addClass('nav-'.$this->:navstyle);

$layout_class = $this->getAttribute('layout');
$layout_class = $this->:layout;
if ($layout_class != 'base') {
$ret->addClass('nav-'.$layout_class);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/xhp-bootstrap/navigation/navbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ enum {
);

protected function compose(): :xhp {
$theme = $this->getAttribute('theme');
$position = $this->getAttribute('position');
$theme = $this->:theme;
$position = $this->:position;

$header = $this->getChildren('bootstrap:navbar:brand');
if ($header) {
Expand Down
4 changes: 2 additions & 2 deletions lib/xhp-bootstrap/navigation/navigation_link.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class :bootstrap:navigation:link extends :bootstrap:base {

protected function compose(): :xhp {
return
<li class={$this->getAttribute('active') ? 'active' : null}>
<a href={$this->getAttribute('href')}>
<li class={$this->:active ? 'active' : null}>
<a href={$this->:href}>
{$this->getChildren()}
</a>
</li>;
Expand Down
4 changes: 2 additions & 2 deletions lib/xhp-bootstrap/page-header.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class :bootstrap:page-header extends :bootstrap:base {
string subtext;

protected function compose(): :xhp {
$subtext = $this->getAttribute('subtext');
$subtext = $this->:subtext;
if ($subtext !== null) {
$subtext =
<x:frag>
Expand All @@ -33,7 +33,7 @@ protected function compose(): :xhp {

return
<div class="page-header">
<h1>{$this->getAttribute('title')} {$subtext}</h1>
<h1>{$this->:title} {$subtext}</h1>
{$lead}
</div>;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/xhp-bootstrap/panels/panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ enum {

protected function compose(): :xhp {
$ret =
<div class={$this->getAttribute('class')}>
<div class={$this->:class}>
{$this->getChildren()}
</div>;

$ret->addClass('panel');
$ret->addClass('panel-'.$this->getAttribute('use'));
$ret->addClass('panel-'.$this->:use);
return $ret;
}

Expand Down
12 changes: 6 additions & 6 deletions lib/xhp-bootstrap/progress-bar.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ enum {
int max = 100;

protected function compose(): :xhp {
$val = $this->getAttribute('value');
$min = $this->getAttribute('min');
$max = $this->getAttribute('max');
$val = $this->:value;
$min = $this->:min;
$max = $this->:max;
if (($min >= $max) || ($val >= $max)) {
$width = 100;
} else if ($val < $max) {
Expand All @@ -42,16 +42,16 @@ protected function compose(): :xhp {
}
$style = "width: {$width}%";
$ret =
<div class={$this->getAttribute('class')} style={$style}
<div class={$this->:class} style={$style}
role="progressbar"
aria-valuenow={$val}
aria-valuemin={$min}
aria-valuemax={$max}>
{$this->getChildren()}
</div>;
$ret->addClass('progress-bar');
$ret->addClass('progress-bar-'.$this->getAttribute('use'));
switch ($this->getAttribute('stripes')) {
$ret->addClass('progress-bar-'.$this->:use);
switch ($this->:stripes) {
case 'active':
$ret->addClass('active');
// FALLTHROUGH
Expand Down
10 changes: 5 additions & 5 deletions lib/xhp-bootstrap/table.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ final class :bootstrap:table extends :bootstrap:base {
protected function compose(): :xhp {
$table = <table>{$this->getChildren()}</table>;
$table->addClass('table');
if ($this->getAttribute('striped')) {
if ($this->:striped) {
$table->addClass('table-striped');
}
if ($this->getAttribute('border')) {
if ($this->:border) {
$table->addClass('table-bordered');
}
if ($this->getAttribute('hover-rows')) {
if ($this->:hover-rows) {
$table->addClass('table-hover');
}
if ($this->getAttribute('condensed')) {
if ($this->:condensed) {
$table->addClass('table-condensed');
}

if ($this->getAttribute('responsive')) {
if ($this->:responsive) {
return <div class="table-responsive">{$table}</div>;
}
return $table;
Expand Down

0 comments on commit 40fdc91

Please sign in to comment.