Fix: PHP Style corrections

* Explicit function visibility
* Uniform constant definition

Change-Id: I5f064d2eac0dedd4c8cc94f442c65f0e338ebbf4
This commit is contained in:
physikerwelt 2013-06-07 15:37:56 +00:00
parent f420e06763
commit 90d678782f
2 changed files with 13 additions and 13 deletions

View File

@ -17,21 +17,21 @@
* @author Brion Vibber * @author Brion Vibber
* @author Moritz Schubotz * @author Moritz Schubotz
*/ */
define( 'MW_TEXVC_SUCCESS', -1 );
class MathTexvc extends MathRenderer { class MathTexvc extends MathRenderer {
const CONSERVATIVE = 2; const CONSERVATIVE = 2;
const MODERATE = 1; const MODERATE = 1;
const LIBERAL = 0; const LIBERAL = 0;
const MW_TEXVC_SUCCESS = -1;
/** /**
* Renders TeX using texvc * Renders TeX using texvc
* *
* @return string rendered TeK * @return string rendered TeK
*/ */
function render() { public function render() {
if ( !$this->readCache() ) { // cache miss if ( !$this->readCache() ) { // cache miss
$result = $this->callTexvc(); $result = $this->callTexvc();
if ( $result != MW_TEXVC_SUCCESS ) { if ( $result != self::MW_TEXVC_SUCCESS ) {
return $result; return $result;
} }
} }
@ -43,7 +43,7 @@ class MathTexvc extends MathRenderer {
* *
* @return string Storage directory * @return string Storage directory
*/ */
function getHashPath() { public function getHashPath() {
$path = $this->getBackend()->getRootStoragePath() . $path = $this->getBackend()->getRootStoragePath() .
'/math-render/' . $this->getHashSubPath(); '/math-render/' . $this->getHashSubPath();
wfDebugLog("Math", "TeX: getHashPath, hash is: {$this->getHash()}, path is: $path\n" ); wfDebugLog("Math", "TeX: getHashPath, hash is: {$this->getHash()}, path is: $path\n" );
@ -55,7 +55,7 @@ class MathTexvc extends MathRenderer {
* *
* @return string Relative directory * @return string Relative directory
*/ */
function getHashSubPath() { public function getHashSubPath() {
return substr( $this->getHash(), 0, 1 ) return substr( $this->getHash(), 0, 1 )
. '/' . substr( $this->getHash(), 1, 1 ) . '/' . substr( $this->getHash(), 1, 1 )
. '/' . substr( $this->getHash(), 2, 1 ); . '/' . substr( $this->getHash(), 2, 1 );
@ -66,7 +66,7 @@ class MathTexvc extends MathRenderer {
* *
* @return string image URL * @return string image URL
*/ */
function getMathImageUrl() { public function getMathImageUrl() {
global $wgMathPath; global $wgMathPath;
$dir = $this->getHashSubPath(); $dir = $this->getHashSubPath();
return "$wgMathPath/$dir/{$this->getHash()}.png"; return "$wgMathPath/$dir/{$this->getHash()}.png";
@ -77,7 +77,7 @@ class MathTexvc extends MathRenderer {
* *
* @return string img HTML * @return string img HTML
*/ */
function getMathImageHTML() { public function getMathImageHTML() {
$url = $this->getMathImageUrl(); $url = $this->getMathImageUrl();
return Xml::element( 'img', return Xml::element( 'img',
@ -125,7 +125,7 @@ class MathTexvc extends MathRenderer {
* *
* @return int|string MW_TEXVC_SUCCESS or error string * @return int|string MW_TEXVC_SUCCESS or error string
*/ */
function callTexvc() { public function callTexvc() {
global $wgTexvc, $wgTexvcBackgroundColor, $wgUseSquid, $wgMathCheckFiles; global $wgTexvc, $wgTexvcBackgroundColor, $wgUseSquid, $wgMathCheckFiles;
$tmpDir = wfTempDir(); $tmpDir = wfTempDir();
if ( !is_executable( $wgTexvc ) ) { if ( !is_executable( $wgTexvc ) ) {
@ -228,7 +228,7 @@ class MathTexvc extends MathRenderer {
) { ) {
return $this->getError( 'math_output_error' ); return $this->getError( 'math_output_error' );
} }
return MW_TEXVC_SUCCESS; return self::MW_TEXVC_SUCCESS;
} }
/** /**
@ -236,7 +236,7 @@ class MathTexvc extends MathRenderer {
* *
* @return FileBackend appropriate file backend * @return FileBackend appropriate file backend
*/ */
function getBackend() { public function getBackend() {
global $wgMathFileBackend, $wgMathDirectory; global $wgMathFileBackend, $wgMathDirectory;
if ( $wgMathFileBackend ) { if ( $wgMathFileBackend ) {
return FileBackendGroup::singleton()->get( $wgMathFileBackend ); return FileBackendGroup::singleton()->get( $wgMathFileBackend );
@ -259,7 +259,7 @@ class MathTexvc extends MathRenderer {
* *
* @return string HTML string * @return string HTML string
*/ */
function doHTMLRender() { public function doHTMLRender() {
if ( $this->getMode() == MW_MATH_MATHML && $this->getMathml() != '' ) { if ( $this->getMode() == MW_MATH_MATHML && $this->getMathml() != '' ) {
return Xml::tags( 'math', return Xml::tags( 'math',
$this->getAttributes( 'math', $this->getAttributes( 'math',
@ -306,7 +306,7 @@ class MathTexvc extends MathRenderer {
* *
* @return boolean true if retrieved, false otherwise * @return boolean true if retrieved, false otherwise
*/ */
function readCache() { public function readCache() {
global $wgMathCheckFiles; global $wgMathCheckFiles;
if ( $this->readFromDatabase() ) { if ( $this->readFromDatabase() ) {
if ( !$wgMathCheckFiles ) { if ( !$wgMathCheckFiles ) {

View File

@ -74,7 +74,7 @@ class MathTexvcTest extends MediaWikiTestCase {
// ... on cache miss, MathTexvc will shell out to texvc: // ... on cache miss, MathTexvc will shell out to texvc:
$texvc->expects( $this->once() ) $texvc->expects( $this->once() )
->method( 'callTexvc' ) ->method( 'callTexvc' )
->will( $this->returnValue( MW_TEXVC_SUCCESS ) ); ->will( $this->returnValue( MathTexvc::MW_TEXVC_SUCCESS ) );
// ... if texvc succeeds, MathTexvc will generate HTML: // ... if texvc succeeds, MathTexvc will generate HTML:
$texvc->expects( $this->once() ) $texvc->expects( $this->once() )