当前位置: 首页>>代码示例>>PHP>>正文


PHP stdClass::setFoo方法代码示例

本文整理汇总了PHP中stdClass::setFoo方法的典型用法代码示例。如果您正苦于以下问题:PHP stdClass::setFoo方法的具体用法?PHP stdClass::setFoo怎么用?PHP stdClass::setFoo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在stdClass的用法示例。


在下文中一共展示了stdClass::setFoo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: provideFixturesToGenerate

 public function provideFixturesToGenerate()
 {
     (yield 'empty instance' => [[\stdClass::class => ['dummy' => []]], ['parameters' => [], 'objects' => ['dummy' => new \stdClass()]]]);
     (yield 'static value' => [[\stdClass::class => ['dummy' => ['foo' => 'bar']]], ['parameters' => [], 'objects' => ['dummy' => StdClassFactory::create(['foo' => 'bar'])]]]);
     (yield 'reference value' => [[\stdClass::class => ['dummy' => ['foo' => 'bar'], 'another_dummy' => ['dummy' => '@dummy']]], ['parameters' => [], 'objects' => ['dummy' => $dummy = StdClassFactory::create(['foo' => 'bar']), 'another_dummy' => StdClassFactory::create(['dummy' => $dummy])]]]);
     (yield 'inverted reference value' => [[\stdClass::class => ['another_dummy' => ['dummy' => '@dummy'], 'dummy' => ['foo' => 'bar']]], ['parameters' => [], 'objects' => ['dummy' => $dummy = StdClassFactory::create(['foo' => 'bar']), 'another_dummy' => StdClassFactory::create(['dummy' => $dummy])]]]);
     (yield 'dynamic reference' => [[\stdClass::class => ['dummy{1..2}' => ['name' => '<current()>'], 'another_dummy{1..2}' => ['dummy' => '@dummy<current()>']]], ['parameters' => [], 'objects' => ['dummy1' => $dummy1 = StdClassFactory::create(['name' => '1']), 'dummy2' => $dummy2 = StdClassFactory::create(['name' => '2']), 'another_dummy1' => StdClassFactory::create(['dummy' => $dummy1]), 'another_dummy2' => StdClassFactory::create(['dummy' => $dummy2])]]]);
     (yield 'inverted dynamic reference' => [[\stdClass::class => ['dummy{1..2}' => ['relatedDummy' => '@another_dummy<current()>'], 'another_dummy{1..2}' => ['name' => '<current()>']]], ['parameters' => [], 'objects' => ['another_dummy1' => $anotherDummy1 = StdClassFactory::create(['name' => '1']), 'another_dummy2' => $anotherDummy2 = StdClassFactory::create(['name' => '2']), 'dummy1' => StdClassFactory::create(['relatedDummy' => $anotherDummy1]), 'dummy2' => StdClassFactory::create(['relatedDummy' => $anotherDummy2])]]]);
     (yield 'property reference value' => [[\stdClass::class => ['dummy' => ['foo' => 'bar'], 'another_dummy' => ['foo' => '@dummy->foo']]], ['parameters' => [], 'objects' => ['dummy' => $dummy = StdClassFactory::create(['foo' => 'bar']), 'another_dummy' => StdClassFactory::create(['foo' => 'bar'])]]]);
     (yield 'inverted property reference value' => [[\stdClass::class => ['dummy' => ['name' => '@another_dummy->name'], 'another_dummy' => ['name' => 'foo']]], ['parameters' => [], 'objects' => ['dummy' => StdClassFactory::create(['name' => 'foo']), 'another_dummy' => StdClassFactory::create(['name' => 'foo'])]]]);
     (yield 'non existing property reference' => [[\stdClass::class => ['dummy' => ['foo' => 'bar'], 'another_dummy' => ['foo' => '@dummy->bob']]], null]);
     (yield 'property reference value with a getter' => [[DummyWithGetter::class => ['dummy' => ['name' => 'foo'], 'another_dummy' => ['name' => '@dummy->name']]], ['parameters' => [], 'objects' => ['dummy' => $dummy = (new DummyWithGetter())->setName('foo'), 'another_dummy' => (new DummyWithGetter())->setName('__get__foo')]]]);
     (yield 'inverted property reference value with a getter' => [[DummyWithGetter::class => ['dummy' => ['name' => '@another_dummy->name'], 'another_dummy' => ['name' => 'foo']]], ['parameters' => [], 'objects' => ['dummy' => $dummy = (new DummyWithGetter())->setName('__get__foo'), 'another_dummy' => (new DummyWithGetter())->setName('foo')]]]);
     (yield 'array value' => [[\stdClass::class => ['dummy' => ['foo' => 'bar'], 'another_dummy' => ['dummies' => ['@dummy', '@dummy', '@dummy']]]], ['parameters' => [], 'objects' => ['dummy' => $dummy = StdClassFactory::create(['foo' => 'bar']), 'another_dummy' => StdClassFactory::create(['dummies' => [$dummy, $dummy, $dummy]])]]]);
     (yield 'wildcard reference value' => [[\stdClass::class => ['dummy_0' => ['foo' => 'bar'], 'another_dummy' => ['dummy' => '@dummy*']]], ['parameters' => [], 'objects' => ['dummy_0' => $dummy = StdClassFactory::create(['foo' => 'bar']), 'another_dummy' => StdClassFactory::create(['dummy' => $dummy])]]]);
     (yield 'wildcard property reference value' => [[\stdClass::class => ['dummy' => ['foo' => 'bar'], 'another_dummy' => ['foo' => '@dummy*->foo']]], ['parameters' => [], 'objects' => ['dummy' => StdClassFactory::create(['foo' => 'bar']), 'another_dummy' => StdClassFactory::create(['foo' => 'bar'])]]]);
     (yield 'dynamic array value' => [[\stdClass::class => ['dummy' => ['foo' => 'bar'], 'another_dummy' => ['dummies' => '3x @dummy']]], ['parameters' => [], 'objects' => ['dummy' => $dummy = StdClassFactory::create(['foo' => 'bar']), 'another_dummy' => StdClassFactory::create(['dummies' => [$dummy, $dummy, $dummy]])]]]);
     (yield 'array value' => [[\stdClass::class => ['dummy' => ['foo' => 'bar'], 'another_dummy' => ['dummies' => ['@dummy', '@dummy', '@dummy']]]], ['parameters' => [], 'objects' => ['dummy' => $dummy = StdClassFactory::create(['foo' => 'bar']), 'another_dummy' => StdClassFactory::create(['dummies' => [$dummy, $dummy, $dummy]])]]]);
     (yield 'dynamic array value with wildcard' => [[\stdClass::class => ['dummy' => ['foo' => 'bar'], 'another_dummy' => ['dummies' => '3x @dummy*']]], ['parameters' => [], 'objects' => ['dummy' => $dummy = StdClassFactory::create(['foo' => 'bar']), 'another_dummy' => StdClassFactory::create(['dummies' => [$dummy, $dummy, $dummy]])]]]);
     (yield 'objects with dots in their references' => [[\stdClass::class => ['user.alice' => ['username' => 'alice'], 'user.alias.alice_alias' => ['username' => '@user.alice->username'], 'user.deep_alias' => ['username' => '@user.alias.alice_alias->username']]], ['parameters' => [], 'objects' => ['user.alice' => StdClassFactory::create(['username' => 'alice']), 'user.alias.alice_alias' => StdClassFactory::create(['username' => 'alice']), 'user.deep_alias' => StdClassFactory::create(['username' => 'alice'])]]]);
     (yield '[special characters] references with underscores' => [[\stdClass::class => ['user_alice' => ['username' => 'alice'], 'user_alias' => ['username' => '@user_alice->username'], 'user_deep_alias' => ['username' => '@user_alias->username']]], ['parameters' => [], 'objects' => ['user_alice' => StdClassFactory::create(['username' => 'alice']), 'user_alias' => StdClassFactory::create(['username' => 'alice']), 'user_deep_alias' => StdClassFactory::create(['username' => 'alice'])]]]);
     (yield '[special characters] references with slashes' => [[\stdClass::class => ['user/alice' => ['username' => 'alice'], 'user/alias/alice_alias' => ['username' => '@user/alice->username'], 'user/deep_alias' => ['username' => '@user/alias/alice_alias->username']]], ['parameters' => [], 'objects' => ['user/alice' => StdClassFactory::create(['username' => 'alice']), 'user/alias/alice_alias' => StdClassFactory::create(['username' => 'alice']), 'user/deep_alias' => StdClassFactory::create(['username' => 'alice'])]]]);
     (yield '[provider] faker functions' => [[\stdClass::class => ['dummy' => ['foo' => '<numberBetween(0, 0)>']]], ['parameters' => [], 'objects' => ['dummy' => StdClassFactory::create(['foo' => 0])]]]);
     (yield '[function] call PHP native function' => [[\stdClass::class => ['dummy' => ['foo' => '<strtolower("BAR")>']]], ['parameters' => [], 'objects' => ['dummy' => StdClassFactory::create(['foo' => 'bar'])]]]);
     (yield '[self reference] alone' => [[\stdClass::class => ['dummy' => ['itself' => '@self']]], ['parameters' => [], 'objects' => ['dummy' => (function () {
         $dummy = new \stdClass();
         $dummy->itself = $dummy;
         return $dummy;
     })()]]]);
     (yield '[self reference] evaluated with a function' => [[\stdClass::class => ['dummy' => ['itself' => '@<("self")>']]], ['parameters' => [], 'objects' => ['dummy' => (function () {
         $dummy = new \stdClass();
         $dummy->itself = $dummy;
         return $dummy;
     })()]]]);
     (yield '[self reference] property' => [[\stdClass::class => ['dummy' => ['foo' => 'bar', 'itself' => '@self']]], ['parameters' => [], 'objects' => ['dummy' => (function () {
         $dummy = new \stdClass();
         $dummy->foo = 'bar';
         $dummy->itself = $dummy;
         return $dummy;
     })()]]]);
     (yield 'identity provider' => [[\stdClass::class => ['dummy' => ['foo' => 'bar', 'identity_foo' => '<identity($foo)>'], 'another_dummy' => ['foo' => 'bar_baz', 'identity_foo' => '<identity(str_replace("_", " ", $foo))>']]], ['parameters' => [], 'objects' => ['dummy' => StdClassFactory::create(['foo' => 'bar', 'identity_foo' => 'bar']), 'another_dummy' => StdClassFactory::create(['foo' => 'bar_baz', 'identity_foo' => 'bar baz'])]]]);
     (yield '[self reference] alone' => [[\stdClass::class => ['dummy' => ['itself' => '@self']]], ['parameters' => [], 'objects' => ['dummy' => (function () {
         $dummy = new \stdClass();
         $dummy->itself = $dummy;
         return $dummy;
     })()]]]);
     (yield '[self reference] property' => [[\stdClass::class => ['dummy' => ['foo' => 'bar', 'itself' => '@self']]], ['parameters' => [], 'objects' => ['dummy' => (function () {
         $dummy = new \stdClass();
         $dummy->foo = 'bar';
         $dummy->itself = $dummy;
         return $dummy;
     })()]]]);
     (yield '[variable] nominal' => [[\Nelmio\Alice\Entity\DummyWithGetter::class => ['dummy' => ['foo' => 'bar', 'fooVal' => '$foo'], 'another_dummy' => ['foo' => 'bar', 'fooVal' => '@self->foo']]], ['parameters' => [], 'objects' => ['dummy' => (function (\Nelmio\Alice\Entity\DummyWithGetter $dummy) {
         $dummy->setFoo('bar');
         $dummy->fooVal = 'bar';
         return $dummy;
     })(new \Nelmio\Alice\Entity\DummyWithGetter()), 'another_dummy' => (function (\Nelmio\Alice\Entity\DummyWithGetter $dummy) {
         $dummy->setFoo('bar');
         $dummy->fooVal = 'rab';
         return $dummy;
     })(new \Nelmio\Alice\Entity\DummyWithGetter())]]]);
     (yield '[variable] variables are scoped to the fixture' => [[\Nelmio\Alice\Entity\DummyWithGetter::class => ['dummy' => ['foo' => 'bar', 'fooVal' => '$foo'], 'another_dummy' => ['foo' => '$foo']]], null]);
     (yield '[identity] evaluate the argument as if it was a plain PHP function' => [[\stdClass::class => ['dummy' => ['foo' => '<("Hello"." "."world!")>', 'bar' => '<(str_replace("_", " ", "Hello_world!"))>']]], ['parameters' => [], 'objects' => ['dummy' => StdClassFactory::create(['foo' => 'Hello world!', 'bar' => 'Hello world!'])]]]);
     (yield '[identity] has access to variables' => [[\stdClass::class => ['dummy' => ['foo' => 'bar', 'foz' => '<($foo)>']]], ['parameters' => [], 'objects' => ['dummy' => StdClassFactory::create(['foo' => 'bar', 'foz' => 'bar'])]]]);
     (yield '[identity] has access to fixtures' => [[\stdClass::class => ['dummy' => ['foo' => 'bar'], 'another_dummy' => ['foo' => '<(@dummy->foo)>']]], ['parameters' => [], 'objects' => ['dummy' => StdClassFactory::create(['foo' => 'bar']), 'another_dummy' => StdClassFactory::create(['foo' => 'bar'])]]]);
     (yield '[identity] has access to current' => [[\stdClass::class => ['dummy_{1..2}' => ['foo' => '<($current)>']]], ['parameters' => [], 'objects' => ['dummy_1' => StdClassFactory::create(['foo' => '1']), 'dummy_2' => StdClassFactory::create(['foo' => '2'])]]]);
     (yield '[templating] templates are not returned' => [[\stdClass::class => ['base_dummy (template)' => [], 'dummy' => []]], ['parameters' => [], 'objects' => ['dummy' => new \stdClass()]]]);
     (yield '[templating] nominal' => [[\stdClass::class => ['base_dummy (template)' => ['foo' => 'bar'], 'another_base_dummy (template)' => ['foo' => 'baz', 'ping' => 'pong'], 'dummy0 (extends base_dummy, extends another_base_dummy)' => ['foo' => 'baz', 'ping' => 'pong'], 'dummy1 (extends another_base_dummy, extends base_dummy)' => ['foo' => 'bar', 'ping' => 'pong']]], ['parameters' => [], 'objects' => ['dummy0' => StdClassFactory::create(['foo' => 'baz', 'ping' => 'pong']), 'dummy1' => StdClassFactory::create(['foo' => 'bar', 'ping' => 'pong'])]]]);
     (yield '[current] nominal' => [[\stdClass::class => ['dummy{1..2}' => ['val' => '<current()>'], 'dummy_{alice, bob}' => ['val' => '<current()>']]], ['parameters' => [], 'objects' => ['dummy1' => StdClassFactory::create(['val' => 1]), 'dummy2' => StdClassFactory::create(['val' => 2]), 'dummy_alice' => StdClassFactory::create(['val' => 'alice']), 'dummy_bob' => StdClassFactory::create(['val' => 'bob'])]]]);
     (yield '[current] in constructor' => [[DummyWithConstructorParam::class => ['dummy{1..2}' => ['__construct' => ['<current()>']], 'dummy_{alice, bob}' => ['__construct' => ['<current()>']]]], ['parameters' => [], 'objects' => ['dummy1' => new DummyWithConstructorParam(1), 'dummy2' => new DummyWithConstructorParam(2), 'dummy_alice' => new DummyWithConstructorParam('alice'), 'dummy_bob' => new DummyWithConstructorParam('bob')]]]);
     (yield 'at literal is not resolved' => [[\stdClass::class => ['dummy' => ['atValues' => ['\\@<("hello")>', '\\\\', '\\\\\\@foo', '\\\\foo']]]], ['parameters' => [], 'objects' => ['dummy' => StdClassFactory::create(['atValues' => ['@hello', '\\', '\\@foo', '\\foo']])]]]);
     (yield '[parameter] simple' => [['parameters' => ['foo' => 'bar'], \stdClass::class => ['dummy' => ['foo' => '<{foo}>']]], ['parameters' => ['foo' => 'bar'], 'objects' => ['dummy' => StdClassFactory::create(['foo' => 'bar'])]]]);
     (yield '[parameter] array parameter' => [['parameters' => ['foo' => ['bar']], \stdClass::class => ['dummy' => ['foo' => '<randomElement(<{foo}>)>']]], ['parameters' => ['foo' => ['bar']], 'objects' => ['dummy' => StdClassFactory::create(['foo' => 'bar'])]]]);
     (yield '[parameter] composite parameter' => [['parameters' => ['foo' => 'NaN', 'bar' => 'Bat', 'composite' => '<{foo}> <{bar}>!'], \stdClass::class => ['dummy' => ['foo' => '<{foo}> <{bar}>!'], 'another_dummy' => ['foo' => '<{composite}>']]], ['parameters' => ['foo' => 'NaN', 'bar' => 'Bat', 'composite' => 'NaN Bat!'], 'objects' => ['dummy' => StdClassFactory::create(['foo' => 'NaN Bat!']), 'another_dummy' => StdClassFactory::create(['foo' => 'NaN Bat!'])]]]);
     (yield '[parameter] nested parameter' => [['parameters' => ['param1' => 2, 'param2' => 1, 'param3' => '<{param<{param2}>}>'], 'objects' => []], ['parameters' => ['param1' => 2, 'param2' => 1, 'param3' => '2'], 'objects' => []]]);
     (yield '[parameter] circular reference' => [['parameters' => ['foo' => '<{bar}>', 'bar' => '<{foo}>']], null]);
     (yield 'dynamic array with scalar value' => [[\stdClass::class => ['dummy' => ['foo' => '5x bar']]], ['parameters' => [], 'objects' => ['dummy' => StdClassFactory::create(['foo' => ['bar', 'bar', 'bar', 'bar', 'bar']])]]]);
     (yield 'object circular reference' => [[DummyWithConstructorParam::class => ['dummy' => ['__construct' => ['@another_dummy']], 'another_dummy' => ['__construct' => ['@dummy']]]], null]);
     (yield 'has proper stdClass support' => [[\stdClass::class => ['dummy' => ['foo' => 'bar'], 'another_dummy' => ['foo' => '@dummy->foo']]], ['parameters' => [], 'objects' => ['dummy' => StdClassFactory::create(['foo' => 'bar']), 'another_dummy' => StdClassFactory::create(['foo' => 'bar'])]]]);
 }
开发者ID:nelmio,项目名称:alice,代码行数:80,代码来源:LoaderIntegrationTest.php


注:本文中的stdClass::setFoo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。