Codeception / Codeception/Codeception

Build creates variables in proxy function's parameter default

Open
#6,657 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
4.9k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Description

#### What are you trying to achieve?
Set a default value in a Helper function that contains `$`

Kinda surprised this hasn't come up - i tried several searches but didn't see anything.
Seems like single-quote strings should be used for generating the proxies, unless there's some special slickness going on to require `" "`.

#### What do you get instead?
The build process wraps default string values in `" "`, which creates a syntax error in the proxy.

> Provide test source code if related

```php
/*
* Support/Helper/Foo.php
*/
public function seeSomethingSomething(
mixed $value,
string $message = 'a default $tring parameter'
) { // ^^^^^^ legal, single-quote string
// irrelevant
}
```
```yaml
## Functional.suite.yml

actor: FunctionalTester
modules:
enabled:
- Asserts
- Tests\Support\Helper\Foo
```
```bash
$ php ./vendor/bin/codecept build
```
```php
/*
* Support/_generated/FunctionalTesterActions.php
*/
public function seeSomethingSomething(
mixed $value,
string $message = "a default $tring parameter"
) { // ^^^^^^ illegal expression in parameter default
// irrelevant
}
```

### Details

* Codeception version: `5.0.10`
* PHP Version: 7.4+
* Operating System: Windows
* Installation type: Composer
* List of installed packages (`composer show`)
( * lines are specified in composer.json)
```
behat/gherkin v4.9.0
* codeception/codeception 5.0.10
codeception/lib-asserts 2.1.0
codeception/stub 4.1.0
fig/http-message-util 1.1.5
* guzzlehttp/guzzle 7.5.0
guzzlehttp/promises 1.5.2
guzzlehttp/psr7 2.4.4
laravel/serializable-closure v1.3.0
* monolog/monolog 2.9.1
myclabs/deep-copy 1.11.1
nikic/fast-route v1.3.0
nikic/php-parser v4.15.4
phar-io/manifest 2.0.3
phar-io/version 3.2.1
php-di/invoker 2.3.3
* php-di/php-di 6.4.0
php-di/phpdoc-reader 2.2.1
phpunit/php-code-coverage 10.0.2
phpunit/php-file-iterator 4.0.1
phpunit/php-invoker 4.0.0
phpunit/php-text-template 3.0.0
phpunit/php-timer 6.0.0
phpunit/phpunit 10.0.19
psr/container 1.1.2
psr/event-dispatcher 1.0.0
psr/http-client 1.0.1
psr/http-factory 1.0.1
psr/http-message 1.0.1
psr/http-server-handler 1.0.1
psr/http-server-middleware 1.0.1
psr/log 3.0.0
psy/psysh v0.11.14
ralouphie/getallheaders 3.0.3
sebastian/cli-parser 2.0.0
sebastian/code-unit 2.0.0
sebastian/code-unit-reverse-lookup 3.0.0
sebastian/comparator 5.0.0
sebastian/complexity 3.0.0
sebastian/diff 5.0.1
sebastian/environment 6.0.0
sebastian/exporter 5.0.0
sebastian/global-state 6.0.0
sebastian/lines-of-code 2.0.0
sebastian/object-enumerator 5.0.0
sebastian/object-reflector 3.0.0
sebastian/recursion-context 5.0.0
sebastian/type 4.0.0
sebastian/version 4.0.1
* shrikeh/teapot dev-master
* slim/psr7 1.6
* slim/slim 4.11.0
symfony/console v6.2.7
symfony/css-selector v6.2.7
symfony/deprecation-contracts v3.2.1
symfony/event-dispatcher v6.2.7
symfony/event-dispatcher-contracts v3.2.1
symfony/finder v6.2.7
symfony/polyfill-ctype v1.27.0
symfony/polyfill-intl-grapheme v1.27.0
symfony/polyfill-intl-normalizer v1.27.0
symfony/polyfill-mbstring v1.27.0
symfony/polyfill-php80 v1.27.0
symfony/service-contracts v2.5.2
symfony/string v6.2.7
symfony/var-dumper v6.2.7
symfony/yaml v6.2.7
teapot/status-code v1.1.2
theseer/tokenizer 1.2.1
```

* Suite configuration:

```yml
## Functional.suite.yml

actor: FunctionalTester
modules:
enabled:
- Asserts
- Tests\Support\Helper\Foo
config:
DoclerLabs\CodeceptionSlimModule\Module\Slim:
application: tests/test.php
step_decorators: ~
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.