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

Comments

@zuozhehao
Copy link

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

This comment has been minimized.

Copy link
Member

commented Jun 28, 2019

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

This comment has been minimized.

Copy link
Author

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

This comment has been minimized.

Copy link
Member

commented Jun 28, 2019

@dreamsxin Any idea on this? 🤔

@dreamsxin

This comment has been minimized.

Copy link
Member

commented Jun 28, 2019

@sergeyklay I will try fix

dreamsxin added a commit to dreamsxin/zephir that referenced this issue Jun 28, 2019
@dreamsxin dreamsxin referenced this issue Jun 28, 2019
1 of 3 tasks complete
@dreamsxin dreamsxin closed this in f5f8f2a Jun 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.