Commit graph

11 commits

Author SHA1 Message Date
Timo Tijhof
6bb00b92bb phpunit: Add @covers to ObjectFactoryTest
* expandClosures() wasn't covered at all.
  Make the test dedicated to this feature cover that method.

* constructClassInstance() coverage was almost complete except for
  the exception case. This was covered in a separate test, but it
  was missing its @covers tag.

Change-Id: I73252849a92440fd7ae2c44f9ca58f7bf9c1f92c
2016-08-17 09:11:51 -07:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
Gergő Tisza
10cf632683 Disallow associative arguments in ObjectFactory
There is no strong use case for associative "decoration"
of constructor arguments (the documentation benefits
mentioned in I43aa085 are outweighed by the confusion
caused by not failing loudly when someone passes an
associative argument by accident, e.g. by omitting an
array nesting level), so disallow them but make sure
they fail nicely, not with an invalid offset error.

Change-Id: I09e4af85ded6a1497b0db0265d2ee6707f91f5e3
2015-11-24 00:10:42 +00:00
Gergő Tisza
20b7696494 Support named arguments in ObjectFactory
Arguments are sometimes given as array( 'foo' => 1, 'bar' => 2 )
which makes the configuration self-documenting.

Change-Id: I43aa085090f1014ba841641867ebf9559d16e76d
2015-11-23 23:04:08 +00:00
Bryan Davis
fecb2320a8 ObjectFactory: avoid using ReflectionClass
Add a new ObjectFactory::constructClassInstance() method that uses
a loop unrolling type of technique to avoid using ReflectionClass when
creating new class instances with 10 or fewer constructor arguments.

I really wanted to also include the use of PHP 5.6's `...` splat
operator when supported but there is no way to conditionally use a new
operator in a way that still allows older versions of PHP to parse the
same source file.

Bug: T115729
Change-Id: Ia29c4526f4bac51696654c9b0677cb3f70359966
2015-10-25 00:13:32 +00:00
umherirrender
eca8c2a72f Rename ObjectFactoryTest_Fixture to camel case name
Change-Id: Ib909c4f694b9774a0983abbb23bfd38ed8c05d5b
2015-10-03 21:29:17 +02:00
Bryan Davis
e53600c4b6 ObjectFactory: add support for setter injection
Extend ObjectFactory::getObjectFromSpec() to support setter injection on
created objects when the specification includes a 'calls' member.

Bug: T107440
Change-Id: Ie2ece2e9658dd2d895d3935da4dc2da8a0a316e2
2015-07-30 11:24:07 -06:00
Vivek Ghaisas
fd9178e4c3 Fix braces code style
Bug: T102805
Change-Id: I7ce4c71dd605f9be79a630602391271bb269b962
2015-06-17 16:28:51 +03:00
Timo Tijhof
ff6513f28b Remove '@section LICENSE'
This was used in 2 special classes, the logger classes and spread
to a few other random classes.

Afaik this has no meaning. Is for something we don't use, and
goes against the meaning of '@section' in Doxygen, which we do
use.

In Doxygen output, all LICENSE references became links to
ProfilerXhprof (the one Doxygen encoutered first).

Bug: T72328
Change-Id: Icc7c443245c70bc0f549bee7d105eef5691c864d
2014-11-26 02:20:55 +00:00
Kunal Mehta
e774a8a779 Add @covers tags to ObjectFactoryTest
Change-Id: I0130b133ef8261e43082d90b08cf2b9abf64ffc9
2014-11-12 17:17:36 +00:00
Kunal Mehta
d5563db924 Deprecate MWFunction::newObj() in favor of ObjectFactory
Change-Id: Iaa803311409cf7b649f64f69bafe2935a418d31c
2014-11-06 13:41:18 -07:00