本文整理汇总了PHP中bailout函数的典型用法代码示例。如果您正苦于以下问题:PHP bailout函数的具体用法?PHP bailout怎么用?PHP bailout使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bailout函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load_resource_bundle
function load_resource_bundle($locale, $directory)
{
$bundle = \ResourceBundle::create($locale, $directory);
if (null === $bundle) {
bailout('The resource bundle for locale ' . $locale . ' could not be loaded from directory ' . $directory);
}
return $bundle;
}
示例2: get_icu_version_from_genrb
function get_icu_version_from_genrb($genrb)
{
exec($genrb . ' --version 2>&1', $output, $status);
if (0 !== $status) {
bailout($genrb . ' failed.');
}
if (!preg_match('/ICU version ([\\d\\.]+)/', implode('', $output), $matches)) {
return null;
}
return $matches[1];
}
示例3: bailout
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use Symfony\Component\Intl\Intl;
require_once __DIR__ . '/common.php';
require_once __DIR__ . '/autoload.php';
if (1 !== $GLOBALS['argc']) {
bailout(<<<MESSAGE
Usage: php test-compat.php
Tests the compatibility of the current ICU version (bundled in ext/intl) with
different versions of symfony/icu.
For running this script, the intl extension must be loaded and all vendors
must have been installed through composer:
composer install --dev
MESSAGE
);
}
echo LINE;
echo centered("ICU Compatibility Test") . "\n";
echo LINE;
echo "Your ICU version: " . Intl::getIcuVersion() . "\n";
echo "Compatibility with symfony/icu:\n";
$branches = array('1.1.x', '1.2.x');
cd(__DIR__ . '/../../vendor/symfony/icu/Symfony/Component/Icu');
foreach ($branches as $branch) {
示例4: create_svn_info_file
function create_svn_info_file($source, $target)
{
exec('svn info --xml ' . $source, $output, $result);
$xml = simplexml_load_string(implode("\n", $output));
if ($result !== 0) {
bailout('svn info failed');
}
$url = (string) $xml->entry->url;
$revision = (string) $xml->entry->commit['revision'];
$author = (string) $xml->entry->commit->author;
$date = (string) $xml->entry->commit->date;
$data = <<<SVN_INFO_DATA
SVN info data
=============
URL: {$url}
Revision: {$revision}
Author: {$author}
Date: {$date}
SVN_INFO_DATA;
file_put_contents($target . DIRECTORY_SEPARATOR . 'svn-info.txt', $data);
}
示例5: centered
build is stored in the second parameter. The build directory needs to contain
the subdirectories bin/ and lib/.
For running this script, the intl extension must be loaded and all vendors
must have been installed through composer:
composer install
MESSAGE
);
}
echo LINE;
echo centered('ICU Resource Bundle Compilation') . "\n";
echo LINE;
if (!Intl::isExtensionLoaded()) {
bailout('The intl extension for PHP is not installed.');
}
$filesystem = new Filesystem();
$urls = parse_ini_file(__DIR__ . '/icu.ini');
echo "icu.ini parsed. Available versions:\n";
$maxVersion = 0;
foreach ($urls as $urlVersion => $url) {
$maxVersion = IcuVersion::compare($maxVersion, $urlVersion, '<') ? $urlVersion : $maxVersion;
echo " {$urlVersion}\n";
}
$shortIcuVersion = strip_minor_versions($maxVersion);
if ($argc >= 2) {
$sourceDir = $argv[1];
$svn = new SvnRepository($sourceDir);
echo "Using existing SVN repository at {$sourceDir}.\n";
} else {
示例6: bailout
}
if (!class_exists('\\Symfony\\Component\\Icu\\IcuData')) {
bailout('You must run "composer update --dev" before running this script.');
}
$stubBranch = '1.0.x';
if (IcuData::isStubbed()) {
bailout("Please switch to a branch of the Icu component that contains .res files (anything but {$stubBranch}).");
}
$shortIcuVersionInPhp = strip_minor_versions(Intl::getIcuVersion());
$shortIcuVersionInIntlComponent = strip_minor_versions(Intl::getIcuStubVersion());
$shortIcuVersionInIcuComponent = strip_minor_versions(IcuData::getVersion());
if ($shortIcuVersionInPhp !== $shortIcuVersionInIcuComponent) {
bailout("The ICU version of the component ({$shortIcuVersionInIcuComponent}) does not match the ICU version in the intl extension ({$shortIcuVersionInPhp}).");
}
if ($shortIcuVersionInIntlComponent !== $shortIcuVersionInIcuComponent) {
bailout("The ICU version of the component ({$shortIcuVersionInIcuComponent}) does not match the ICU version of the stub classes in the Intl component ({$shortIcuVersionInIntlComponent}).");
}
echo wordwrap("Make sure that you don't have any ICU development files " . "installed. If the build fails, try to run:\n", LINE_WIDTH);
echo "\n sudo apt-get remove libicu-dev\n\n";
$icuVersionInIcuComponent = IcuData::getVersion();
echo "Compiling stubs for ICU version {$icuVersionInIcuComponent}.\n";
echo "Preparing stub creation...\n";
$targetDir = sys_get_temp_dir() . '/icu-stubs';
$context = new StubbingContext(IcuData::getResourceDirectory(), $targetDir, new Filesystem(), $icuVersionInIcuComponent);
$transformer = new BundleTransformer();
$transformer->addRule(new LanguageBundleTransformationRule());
$transformer->addRule(new RegionBundleTransformationRule());
$transformer->addRule(new CurrencyBundleTransformationRule());
$transformer->addRule(new LocaleBundleTransformationRule());
echo "Starting stub creation...\n";
$transformer->createStubs($context);
示例7: centered
echo LINE;
echo centered("ICU Resource Bundle Compilation") . "\n";
echo LINE;
if (!Intl::isExtensionLoaded()) {
bailout('The intl extension for PHP is not installed.');
}
if (!class_exists('\\Symfony\\Component\\Icu\\IcuData')) {
bailout('You must run "composer update --dev" before running this script.');
}
$filesystem = new Filesystem();
$icuVersionInPhp = Intl::getIcuVersion();
echo "Found intl extension with ICU version {$icuVersionInPhp}.\n";
$shortIcuVersion = strip_minor_versions($icuVersionInPhp);
$urls = parse_ini_file(__DIR__ . '/icu.ini');
if (!isset($urls[$shortIcuVersion])) {
bailout('The version ' . $shortIcuVersion . ' is not available in the icu.ini file.');
}
echo "icu.ini parsed. Available versions:\n";
foreach ($urls as $urlVersion => $url) {
echo " {$urlVersion}\n";
}
if ($GLOBALS['argc'] >= 2) {
$sourceDir = $GLOBALS['argv'][1];
$svn = new SvnRepository($sourceDir);
echo "Using existing SVN repository at {$sourceDir}.\n";
} else {
echo "Starting SVN checkout for version {$shortIcuVersion}. This may take a while...\n";
$sourceDir = sys_get_temp_dir() . '/icu-data/' . $shortIcuVersion . '/source';
$svn = SvnRepository::download($urls[$shortIcuVersion], $sourceDir);
echo "SVN checkout to {$sourceDir} complete.\n";
}
示例8: centered
Copies stub files created with create-stubs.php to the Icu component.
For running this script, the intl extension must be loaded and all vendors
must have been installed through composer:
composer install --dev
MESSAGE
);
}
echo LINE;
echo centered("ICU Resource Bundle Stub Update") . "\n";
echo LINE;
if (!class_exists('\\Symfony\\Component\\Icu\\IcuData')) {
bailout('You must run "composer update --dev" before running this script.');
}
$stubBranch = '1.0.x';
if (!IcuData::isStubbed()) {
bailout("Please switch to the Icu component branch {$stubBranch}.");
}
$filesystem = new Filesystem();
$sourceDir = sys_get_temp_dir() . '/icu-stubs';
$targetDir = IcuData::getResourceDirectory();
if (!$filesystem->exists($sourceDir)) {
bailout("The directory {$sourceDir} does not exist. Please run create-stubs.php first.");
}
$filesystem->remove($targetDir);
echo "Copying files from {$sourceDir} to {$targetDir}...\n";
$filesystem->mirror($sourceDir, $targetDir);
echo "Done.\n";
示例9: bailout
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
$autoload = __DIR__ . '/../../vendor/autoload.php';
if (!file_exists($autoload)) {
bailout('You should run "composer install --dev" in the component before running this script.');
}
require_once realpath($autoload);
示例10: str_replace
$targetpage = str_replace(' ', '_', $_GET['p']);
$targetpage = explode('?', $_GET['p']);
$getpage = $targetpage[0];
echo "<h2>Voters for <a href=\"//en.wikipedia.org/wiki/{$getpage}\">{$getpage}</a></h2>";
//$buffer = file_get_contents('input.txt');
//$buffer = $wpq->getpage($getpage);
//$buffer = $wiki->get($wikipedia . $getpage);
echo "<!--";
$mypage = initPage($getpage);
$buffer = $mypage->get_text();
echo "-->";
if ($buffer === False or trim($buffer) == '') {
bailout("Failed to load \"{$getpage}\" from server");
}
if (preg_match("/#redirect:?\\s*?\\[\\[\\s*?(.*?)\\s*?\\]\\]/i", $buffer, $match)) {
bailout("Page redirects to {$match[1]}<br /><a href=\"{$_SERVER['PHP_SELF']}?p=" . urlencode($match[1]) . "\">Click here to analyze it</a>");
}
//Create an RFA object
$myRFA = new RFA();
$result = $myRFA->analyze($buffer);
if ($result !== TRUE) {
//bailout($myRFA->lasterror);
}
$enddate = $myRFA->enddate;
$tally = count($myRFA->support) . '/' . count($myRFA->oppose) . '/' . count($myRFA->neutral);
$totalVotes = count($myRFA->support) + count($myRFA->oppose);
if ($totalVotes != 0) {
$tally .= ", " . number_format(count($myRFA->support) / $totalVotes * 100, 2) . "%";
}
echo '<a href="//en.wikipedia.org/wiki/User:' . $myRFA->username . '">' . $myRFA->username . '</a>\'s RfA (' . $tally . '); End date: ' . $enddate . '<br />';
echo 'Found <strong>' . count($myRFA->duplicates) . '</strong> duplicate votes (highlighted in <span class="dup">red</span>).' . ' Votes the tool is unsure about are <span class="iffy1">italicized</span>.';