badoo / badoo/soft-mocks

Improvement request: Closure

Open
#43 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
308
Forks
38
PR merge metrics
No merged PRs in 30d

Description

Is is better to use php Closure and not to write php code in strings? This issue is the only one that stops me to use soft-mocks.

**As it is now:**
```
\Badoo\SoftMocks::redefineFunction(
'strlen',
'$a',
'return \\Badoo\\SoftMocks::callOriginal("strlen", [trim($a)]));'
);
```

**Can be with closure:**

```
\Badoo\SoftMocks::redefineFunction( 'strlen', function( $a ) {
return \Badoo\SoftMocks::callOriginal('strlen', [trim($a)]);
}) ;
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the SoftMocks::redefineFunction entry point and trace how its current string-based arguments are handled. The work is done when the closure form shown in the issue can redefine strlen and call the original function with the trimmed argument, while the existing string form continues to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
testing-qa
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.