我怎样才能获得23的,而不是1对$lastnum1?
$text = "1 out of 23";
$lastnum1 = $this->getEval(eregi_replace("[^* out of]", '', $text));
Run Code Online (Sandbox Code Playgroud) 我正在使用Ant的<parallel>任务来执行多个使用<exec>任务的同时目标,但由于它是交错的,所以很难读取输出.有没有办法更改[exec]每行输出之前出现的标签以使用命令或目标名称?
例如,在运行pdepend和phpcpd我想改变[exec],以[pdepend]和[phpcpd]:
pdepend:
[exec] PHP_Depend 0.10.5 by Manuel Pichler
[exec]
phpcpd:
[exec] Parsing source files:
[exec] phpcpd 1.3.2 by Sebastian Bergmann.
[exec]
[exec] ............................................................ 60
[exec] Found 26 exact clones with 640 duplicated lines in 28 files:
[exec]
[exec] - application/modules/controllers/IndexController.php:16-31
[exec] ............................................................ 120
[exec] application/modules/controllers/ErrorController.php:15-30
[exec]
[exec] - application/modules/controllers/PhotosController.php:24-33
[exec] ............................................................ 180
[exec] ............................................................ 240
Run Code Online (Sandbox Code Playgroud)
变
pdepend:
[pdepend] PHP_Depend 0.10.5 by Manuel Pichler …Run Code Online (Sandbox Code Playgroud) 我想创建自定义注释来抑制单个FindBugs警告,以便通过代码完成更容易地使用它们.例如,这个忽略不设置所有@Nonnull字段的构造函数.
@TypeQualifierDefault(ElementType.CONSTRUCTOR)
@SuppressFBWarnings("NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR")
@Retention(RetentionPolicy.CLASS)
public @interface SuppressNonnullFieldNotInitializedWarning
{ }
Run Code Online (Sandbox Code Playgroud)
但是,在使用注释时我仍然会看到警告.
public class User {
@Nonnull
private String name;
@SuppressNonnullFieldNotInitializedWarning
public User() {
// "Nonnull field name is not initialized by new User()"
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试了不同的保留策略和元素类型,将注释放在构造函数和类上,甚至@TypeQualifierNickname.
这种模式适用@Nonnull于类中的所有字段.
@Nonnull
@TypeQualifierDefault(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface FieldsAreNonnullByDefault
{ }
Run Code Online (Sandbox Code Playgroud)
FindBugs正确显示分配null给代码的警告name.
@FieldsAreNonnullByDefault
public class User {
private String name;
public UserModel() {
name = null;
// "Store of null value into field User.name annotated Nonnull"
} …Run Code Online (Sandbox Code Playgroud) 简短而看似愚蠢的问题,因为这么简单,你会想到无处不在:有没有人在RequireJS前端项目(非NodeJS)中使用任何类型的代码覆盖?
这似乎是一个愚蠢的问题,因为JS世界中TDD方法的普及以及AMD开发的接管.
我已经尝试了一百万种方法,但都缺乏.我的项目是一个带有Jasmine单元测试的Backbone项目:
1)带有Coverage插件的JSTD.JSTD无法正确加载和检测AMD模块.如果我在单个js文件上运行JSTD(由RequireJS优化器组合),那么代码覆盖率可以很好地工作,除了收集覆盖范围并在ENTIRE文件上定义度量标准.太棒了,这没用,因为它包括第三方库,因为我无法针对单个单元来帮助测试开发.哎呀.
2)JSCoverage - 总失败,不喜欢AMD模块.
3)特定于Chrome和Firebug的"现场"指导员 - 失败,不喜欢AMD模块.
我尝试的每一种方法似乎都需要大量的定制工作.那么也许我需要从头开始自定义解决方案?
如何使用以下方法:将RequireJS优化器扩展为仪器代码并创建覆盖范围.它将是内存中的检测,可以使用require.config({instrument:true})标志启用.每次需要加载模块时,它会自动对其进行检测并将其放置在模块库中.覆盖率统计信息收集在全局require对象下的对象中,并且可以从任何地方访问,例如,在Jasmine测试运行之后.
输入?
我想知道放置ini_set()函数的最佳位置在哪里,因为我觉得当ini_set函数在这个方法里面时这样:
private function archiveBackup() {
ini_set('memory_limit', '128M');
ini_set('max_execution_time', 0);
...
}
Run Code Online (Sandbox Code Playgroud)
该ini_set功能不起作用?!
我的脚本就是这样的:jQuery ajax query - > ajax.php文件(make类的实例并调用一些方法) - >调用类的方法.
最好的地方在哪里?在ajax.php文件中或在类或内部方法的开头?
我正在使用几个单独的asp.net应用程序,并将它们组合在一起.
一个问题是合理化两个应用程序之间的CSS - app1有两个css文件,而app2有大约8个.两个应用程序之间的大部分CSS都是相同的,但存在一些差异.我正在寻找一个工具来比较每个应用程序的所有元素,并显示缺少什么,有什么不同,等等.理想情况下,输出将是3个文件:Common,app1和app2,但如果它我不会那么挑剔可以告诉我两个应用程序之间的差异.
这样的工具存在吗?
我已经创建了自己的codeniffer规则标准.他们工作正常.现在我想使用PHP UnitTest测试代码的不同规则.PhpCodesniffer已经有了PHPUnit测试用例的框架.
所以使用它我已经扩展了他们的AbstractSniffUnitTest单元测试类
Standards/TestRules/Tests/Function/FunctionUnitTest.php和要测试的脚本Standards/TestRules/Tests/Function/FunctionUnitTest.inc.
但是当我要按命令运行脚本时phpunit PEAR\PHP\tests\AllTests.php,它会出现以下错误.
PHPUnit 3.5.14 by Sebastian Bergmann.
......................................F
Time: 6 seconds, Memory: 10.00Mb
There was 1 failure:
1) TestRules_Tests_Function_FunctionUnitTest::getErrorList
An unexpected exception has been caught: Source file C:/Program Files/PHP/PEAR/PHP/CodeSniffer/Standards/TestRules/Tests/Function/FunctionUnitTest.inc does not exist
C:\Program Files\PHP\PEAR\PHP\tests\Standards\AbstractSniffUnitTest.php:138
C:\Program Files\PHP\PEAR\PHP\tests\TestSuite.php:48
FAILURES!
Tests: 39, Assertions: 146, Failures: 1.
Warning: Deprecated PHPUnit features are being used 2 times!
Use --verbose for more information.
Run Code Online (Sandbox Code Playgroud)
它给出了FunctionUnitTest.inc在给定位置找不到的错误文件.我已经给予文件夹的完全权限,也验证了路径和文件位置,但它给出了同样的错误.我也在linux机器上测试了它,但它给出了同样的错误.
这是我的代码问题还是代码单元测试框架问题?
我正在使用PHPUnit和Jenkins测试Zend Framework应用程序.我需要覆盖PHPUnit 文件中APPLICATION_ENV使用PHP访问的环境变量:getenvbootstrap.php
<?php
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'testing'));
... use APPLICATION_ENV to pick database, configuration, etc. ...
Run Code Online (Sandbox Code Playgroud)
我有两个环境:( testing对于本地机器)和testing-ci(对于Jenkins机器).如何将变量设置为testing-ci在Jenkins中运行时?有没有办法build.xml为Ant或Phing 设置它?
这是我在渲染方法中的表单,用于用户登录。
<form onSubmit={this.handleSubmit}>
<Avatar className={classes.avatar}>
<LockOutlinedIcon />
</Avatar>
<Typography component="h1" variant="h5">
Sign in
</Typography>
<TextField variant="outlined" margin="normal" fullWidth id="email"
label="Email Address" name="email" onChange={this.handleEmailChange}
/>
<TextField variant="outlined" margin="normal" fullWidth
name="password" onChange={this.handlePasswordChange}
/>
{loginError && (
<Typography component="p" className={classes.errorText}>
Incorrect email or password.
</Typography>
)}
<Button type="button" fullWidth variant="contained" color="primary"
className={classes.submit} onClick={this.handleSubmit}
>
Sign In
</Button>
</form>
Run Code Online (Sandbox Code Playgroud)
以下是我的句柄提交方法。
handleSubmit = () => {
const { dispatch } = this.props;
const { email, password } = this.state;
dispatch(loginUser(email, password));
};
Run Code Online (Sandbox Code Playgroud)
如何通过按键提交表单Enter?我正在使用标准的 …
我在Grunt中有多个子任务(src,lib和test)的JSHint设置,效果很好.但是,由于我们刚开始使用此设置,因此我们的许多源文件中存在许多错误.
$ grunt jshint:src
... lots of errors ...
Run Code Online (Sandbox Code Playgroud)
在一次处理一个文件的同时,是否可以重新打印该单个文件?
$ grunt jshint:src:one.js
... only errors from one.js ...
Run Code Online (Sandbox Code Playgroud)
更新
一个复杂因素是监视任务还有多个子任务,可根据编辑的文件类型触发不同的任务.
watch: {
src: {
files: [ SRC_DIR + "hgm*.js" ],
tasks: [ "jshint:src", "test" ]
},
lib: {
files: [ "lib/hgm-test-setup.js", "lib/hgm.loader.js" ],
tasks: [ "jshint:lib", "test" ]
},
test: {
files: [ "tests/**/*.js" ],
tasks: [ "jshint:test", "test" ]
}
}
Run Code Online (Sandbox Code Playgroud)
这样做的原因是,src和lib使用一个.jshint同时test使用不同的一个指定用于测试如断言的所有全局变量.我可以结合src和lib,但我可以覆盖为JSHint配置文件 …
php ×3
ant ×2
javascript ×2
phpunit ×2
annotations ×1
codesniffer ×1
css ×1
echo ×1
exec ×1
findbugs ×1
forms ×1
gruntjs ×1
ini-set ×1
java ×1
jenkins ×1
js-amd ×1
jshint ×1
material-ui ×1
phing ×1
reactjs ×1
regex ×1
requirejs ×1
unit-testing ×1