On 17.07.2012, at 23:20, Stas Malyshev wrote:
> Hi!
>
>> That would be: tokenizer + static analysis (with type inference) + replacing some of the
>> tokens.
>> Not a trivial task, but definitely doable.
>
> So what would this tool do with this code?
>
> $a = getFirstArrayName();
> $b = getSecondArrayName();
> $$a = $$b;
> $b[1] = 0;
Something like this:
$a = getFirstArrayName();
$b = getSecondArrayName();
if ($$b instanceof ArrayObject) {
$$a = clone $$b;
} else {
$$a = $$b;
}
$b[1] = 0;
> Or this:
>
> include 'a.inc';
> $a = $b;
> include 'b.inc';
>
> where a.inc has array $a and b.inc has something like $b[1] = 0; but you
> have no way of knowing it since by the time you run the tool a.inc and
> b.inc are not available to it (think config files).
well, the same as above. not pretty, but that's a safe fallback when type inference is not
available.
Attachment: [application/pgp-signature] Message signed with OpenPGP using GPGMail signature.asc