Browse Source

"YiiRequirementChecker" definition has been reverted to match PHP 4.3

tags/2.0.0-beta
Paul Klimov 12 years ago
parent
commit
004d0b044a
  1. 35
      yii/requirements/YiiRequirementChecker.php

35
yii/requirements/YiiRequirementChecker.php

@ -46,6 +46,9 @@ if (version_compare(PHP_VERSION, '4.3', '<')) {
* );
* ~~~
*
* Note: this class definition does not match ordinary Yii style, because it should match PHP 4.3
* and should not use features from the older PHP version!
*
* @property array|null $result the check results, this property is for internal usage only.
*
* @author Paul Klimov <klimov.paul@gmail.com>
@ -62,7 +65,7 @@ class YiiRequirementChecker
* If a string, it is treated as the path of the file, which contains the requirements;
* @return YiiRequirementChecker self instance.
*/
public function check($requirements)
function check($requirements)
{
if (is_string($requirements)) {
$requirements = require($requirements);
@ -106,7 +109,7 @@ class YiiRequirementChecker
* Performs the check for the Yii core requirements.
* @return YiiRequirementChecker self instance.
*/
public function checkYii()
function checkYii()
{
return $this->check(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'requirements.php');
}
@ -132,7 +135,7 @@ class YiiRequirementChecker
* )
* </code>
*/
public function getResult()
function getResult()
{
if (isset($this->result)) {
return $this->result;
@ -145,7 +148,7 @@ class YiiRequirementChecker
* Renders the requirements check result.
* The output will vary depending is a script running from web or from console.
*/
public function render()
function render()
{
if (!isset($this->result)) {
$this->usageError('Nothing to render!');
@ -166,7 +169,7 @@ class YiiRequirementChecker
* @param string $compare comparison operator, by default '>='
* @return boolean if PHP extension version matches.
*/
public function checkPhpExtensionVersion($extensionName, $version, $compare = '>=')
function checkPhpExtensionVersion($extensionName, $version, $compare = '>=')
{
if (!extension_loaded($extensionName)) {
return false;
@ -183,7 +186,7 @@ class YiiRequirementChecker
* @param string $name configuration option name.
* @return boolean option is on.
*/
public function checkPhpIniOn($name)
function checkPhpIniOn($name)
{
$value = ini_get($name);
if (empty($value)) {
@ -197,7 +200,7 @@ class YiiRequirementChecker
* @param string $name configuration option name.
* @return boolean option is off.
*/
public function checkPhpIniOff($name)
function checkPhpIniOff($name)
{
$value = ini_get($name);
if (empty($value)) {
@ -214,7 +217,7 @@ class YiiRequirementChecker
* @param string $compare comparison operator, by default '>='.
* @return boolean comparison result.
*/
public function compareByteSize($a, $b, $compare = '>=')
function compareByteSize($a, $b, $compare = '>=')
{
$compareExpression = '(' . $this->getByteSize($a) . $compare . $this->getByteSize($b) . ')';
return $this->evaluateExpression($compareExpression);
@ -226,7 +229,7 @@ class YiiRequirementChecker
* @param string $verboseSize verbose size representation.
* @return integer actual size in bytes.
*/
public function getByteSize($verboseSize)
function getByteSize($verboseSize)
{
if (empty($verboseSize)) {
return 0;
@ -265,7 +268,7 @@ class YiiRequirementChecker
* @param string|null $max verbose file size maximum required value, pass null to skip maximum check.
* @return boolean success.
*/
public function checkUploadMaxFileSize($min = null, $max = null)
function checkUploadMaxFileSize($min = null, $max = null)
{
$postMaxSize = ini_get('post_max_size');
$uploadMaxFileSize = ini_get('upload_max_filesize');
@ -292,7 +295,7 @@ class YiiRequirementChecker
* @param boolean $_return_ whether the rendering result should be returned as a string
* @return string the rendering result. Null if the rendering result is not required.
*/
public function renderViewFile($_viewFile_, $_data_ = null, $_return_ = false)
function renderViewFile($_viewFile_, $_data_ = null, $_return_ = false)
{
// we use special variable names here to avoid conflict when extracting data
if (is_array($_data_)) {
@ -316,7 +319,7 @@ class YiiRequirementChecker
* @param int $requirementKey requirement key in the list.
* @return array normalized requirement.
*/
public function normalizeRequirement($requirement, $requirementKey = 0)
function normalizeRequirement($requirement, $requirementKey = 0)
{
if (!is_array($requirement)) {
$this->usageError('Requirement must be an array!');
@ -354,7 +357,7 @@ class YiiRequirementChecker
* This method will then terminate the execution of the current application.
* @param string $message the error message
*/
public function usageError($message)
function usageError($message)
{
echo "Error: $message\n\n";
exit(1);
@ -365,7 +368,7 @@ class YiiRequirementChecker
* @param string $expression a PHP expression to be evaluated.
* @return mixed the expression result.
*/
public function evaluateExpression($expression)
function evaluateExpression($expression)
{
return eval('return ' . $expression . ';');
}
@ -374,7 +377,7 @@ class YiiRequirementChecker
* Returns the server information.
* @return string server information.
*/
public function getServerInfo()
function getServerInfo()
{
$info = isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : '';
return $info;
@ -384,7 +387,7 @@ class YiiRequirementChecker
* Returns the now date if possible in string representation.
* @return string now date.
*/
public function getNowDate()
function getNowDate()
{
$nowDate = @strftime('%Y-%m-%d %H:%M', time());
return $nowDate;

Loading…
Cancel
Save