Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG change yaconf value #1879

Closed
zuozhehao opened this issue Jun 28, 2019 · 4 comments
Closed

BUG change yaconf value #1879

zuozhehao opened this issue Jun 28, 2019 · 4 comments

Comments

@zuozhehao
Copy link

zuozhehao commented Jun 28, 2019

example.ini

[dir]
a = ../test/dir

Test.zep

namespace Example;

class Test {

    public function __construct(array! config) {

        var k, v;

        for k, v in config["dir"] {

           let config["dir"][k] = realpath(v);

        } 

    }
}

example.php

$config = Yaconf::get('example');
print_r($config);

new \Example\Test($config);

print_r($config);

When I refresh my browser, the printed path is not fixed, sometimes relative, sometimes absolute.

https://github.com/laruence/yaconf

@sergeyklay
Copy link
Contributor

It should be something like this:

class Test {

+   private  config = [];

    public function __construct(array! config) {

        var k, v;

        for k, v in config["dir"] {

           let config["dir"][k] = realpath(v);

        } 

+       let this->config = config;

    }

+   public function get()
+   {
+       return this->config;
+   }
}
  $config = Yaconf::get('example');
  print_r($config);

- new \Example\Test($config);
+ $test = new \Example\Test($config);


- print_r($config);
+ print_r($test->get());

@zuozhehao
Copy link
Author

zuozhehao commented Jun 28, 2019

$config = Yaconf::get('example');
print_r($config);

new \Example\Test($config);

The correct one should be the same every time the output is the same.
But \Example\Test Influencing Yaconf::get result.

In this code it must output result 1 every time, but actually it sometimes outputs result 1 and sometimes outputs result 2

// result 1:
Array
(
    [dir] => Array
        (
            [a] => ../test/dir
        )

)

// result 2:
Array
(
    [dir] => Array
        (
            [a] => /tmp/test/dir
        )

)

@sergeyklay
Copy link
Contributor

@dreamsxin Any idea on this? 🤔

@dreamsxin
Copy link
Contributor

@sergeyklay I will try fix

dreamsxin added a commit to dreamsxin/zephir that referenced this issue Jun 28, 2019
@dreamsxin dreamsxin mentioned this issue Jun 28, 2019
3 tasks
dreamsxin added a commit to dreamsxin/zephir that referenced this issue Nov 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants