{"action":"opened","issue":{"number":83,"created_at":"2011-10-09T14:57:04Z","pull_request":{"diff_url":null,"patch_url":null,"html_url":null},"body":"Scope of Change\n====\nThe ClassLoader's defineClass() method will be changed to use\ninclude() with an own stream wrapper instead of eval().\n\nRationale\n====\nIn case the class brings up a fatal error at runtime, a\nmeaningful error message can be shown instead of a message\nlike \"Fatal error at eval'ed code at line XXX in \nlang/ClassLoader.class.php\".\n\nFunctionality\n====\nThe defineClass() method will prepare a string containing the\nbytes of the new class and store pass it to a class implementing\nthe stream_* functions.\n\nInstead of calling eval() with that string, it will include() the\nnew class with the artificial \"inline://\"-protocol - invoking the \nstream wrapper.\nThe stream_wrapper returns the class bytes. PHP will be able to\nassociate a constructed filename with the inline code and show\nthat in any case of error.\n\nSecurity considerations\n====\nn/a\n\nSpeed impact\n====\nThe new execution model is around 3-4 times slower than the\nprevious!\nThis insight has been made through the following simple benchmark\nscript:\n\nBenchmark script:\n\n```php\n<?php\n  require('lang.base.php');\n  \n  $cl= ClassLoader::getDefault();\n  for ($i= 0; $i < 100000; $i++) {\n    $cl->defineClass(\n      'net.xp_framework.runtime.DefinedClass'.$i,\n      'class DefinedClass'.$i.' extends Object {}'\n    );\n  }\n\n?>\n```\n\nOld execution speed:\nak@boost ~/devel/xp.public/trunk $ time php test.php \n\nreal    0m7.850s\nuser    0m7.300s\nsys     0m0.550s\n\nNew execution speed:\nak@boost ~/devel/xp.public/trunk $ time php test.php \n\nreal    0m25.181s\nuser    0m22.090s\nsys     0m3.080s\n\nThe slow execution is probably due to many additional PHP userland function\ncalls and string manipulations. However, defining a class is usually not\na task that happens nearly that often as in the provided benchmark script.\n\nThe developer community has to decide whether the useful additional debugging\ninformation outweights the speed loss.\n\nDependencies\n====\nn/a\n\nRelated documents\n====\n- http://xp-framework.net/rfc/contrib/rfc0083.diff\n\nComments\n====\n- kiesel, Mon Jan 15 18:48:16 CET 2007\n  Since no objections have been filed, the RFC has been accepted.\n\n\n<EOF>\n","comments":0,"title":"RFC 0083: Define classes through stream wrappers","updated_at":"2011-10-09T14:57:04Z","url":"https://api.github.com/repos/thekid/rfc/issues/83","id":1856412,"assignee":null,"milestone":null,"closed_at":null,"user":{"avatar_url":"https://secure.gravatar.com/avatar/26f07e3b262e9a80436f368cb11bd0c2?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/thekid","id":696742,"login":"thekid"},"html_url":"https://github.com/thekid/rfc/issues/83","labels":[{"name":"rfc","url":"https://api.github.com/repos/thekid/rfc/labels/rfc","color":"02e10c"}],"state":"open"},"legacy":{"number":83,"action":"opened","issue":1856412}}