Browse files

Added aop.php delcarations

Added php-declaration-generator.php
  • Loading branch information...
1 parent 2b8bacc commit 96320b0164aee30d282ed8398be3f8d4c0b0c8f3 @ralphschindler ralphschindler committed Feb 11, 2013
Showing with 134 additions and 0 deletions.
  1. +49 −0 doc/aop.php
  2. +85 −0 doc/php-declaration-generator.php
View
49 doc/aop.php
@@ -0,0 +1,49 @@
+<?php
+/**
+ * Generated stub file for code completion purposes
+ */
+
+define('AOP_KIND_BEFORE', 2);
+define('AOP_KIND_AFTER', 4);
+define('AOP_KIND_AROUND', 1);
+define('AOP_KIND_PROPERTY', 32);
+define('AOP_KIND_FUNCTION', 128);
+define('AOP_KIND_METHOD', 64);
+define('AOP_KIND_READ', 8);
+define('AOP_KIND_WRITE', 16);
+define('AOP_KIND_AROUND_WRITE_PROPERTY', 49);
+define('AOP_KIND_AROUND_READ_PROPERTY', 41);
+define('AOP_KIND_BEFORE_WRITE_PROPERTY', 50);
+define('AOP_KIND_BEFORE_READ_PROPERTY', 42);
+define('AOP_KIND_AFTER_WRITE_PROPERTY', 52);
+define('AOP_KIND_AFTER_READ_PROPERTY', 44);
+define('AOP_KIND_BEFORE_METHOD', 66);
+define('AOP_KIND_AFTER_METHOD', 68);
+define('AOP_KIND_AROUND_METHOD', 65);
+define('AOP_KIND_BEFORE_FUNCTION', 130);
+define('AOP_KIND_AFTER_FUNCTION', 132);
+define('AOP_KIND_AROUND_FUNCTION', 129);
+
+function aop_add_before($pointcut, $advice) {}
+function aop_add_after($pointcut, $advice) {}
+function aop_add_around($pointcut, $advice) {}
+
+class AopJoinpoint
+{
+ public function &getArguments() {}
+ public function getPropertyName() {}
+ public function getPropertyValue() {}
+ public function setArguments(array $arguments) {}
+ public function getKindOfAdvice() {}
+ public function &getReturnedValue() {}
+ public function &getAssignedValue() {}
+ public function setReturnedValue($value) {}
+ public function setAssignedValue($value) {}
+ public function getPointcut() {}
+ public function getObject() {}
+ public function getClassName() {}
+ public function getMethodName() {}
+ public function getFunctionName() {}
+ public function getException() {}
+ public function process() {}
+}
View
85 doc/php-declaration-generator.php
@@ -0,0 +1,85 @@
+<?php
+
+define('T', ' ');
+define('N', PHP_EOL);
+
+$functions = array('aop_add_before', 'aop_add_after', 'aop_add_around');
+$classes = array('AopJoinPoint');
+$constant_prefix = 'AOP';
+
+$php = '<?php' . N;
+$php .= '/**' . N . ' * Generated stub file for code completion purposes' . N . ' */';
+$php .= N . N;
+
+//echo ReflectionClass::export('ReflectionMethod');
+foreach (get_defined_constants() as $cname => $cvalue) {
+ if (strpos($cname, $constant_prefix) === 0) {
+ $php .= 'define(\'' . $cname . '\', ' . $cvalue . ');' . N;
+ }
+}
+
+$php .= N;
+
+foreach ($functions as $function) {
+ $refl = new ReflectionFunction($function);
+ $php .= 'function ' . $refl->getName() . '(';
+ foreach ($refl->getParameters() as $i => $parameter) {
+ if ($i >= 1) {
+ $php .= ', ';
+ }
+ if ($typehint = $parameter->getClass()) {
+ $php .= $typehint->getName() . ' ';
+ }
+ $php .= '$' . $parameter->getName();
+ if ($parameter->isDefaultValueAvailable()) {
+ $php .= ' = ' . $parameter->getDefaultValue();
+ }
+ }
+ $php .= ') {}' . N;
+}
+
+$php .= N;
+
+foreach ($classes as $class) {
+ $refl = new ReflectionClass($class);
+ $php .= 'class ' . $refl->getName();
+ if ($parent = $refl->getParentClass()) {
+ $php .= ' extends ' . $parent->getName();
+ }
+ $php .= N . '{' . N;
+ foreach ($refl->getProperties() as $property) {
+ $php .= T . '$' . $property->getName() . ';' . N;
+ }
+ foreach ($refl->getMethods() as $method) {
+ if ($method->isPublic()) {
+ if ($method->getDocComment()) {
+ $php .= T . $method->getDocComment() . N;
+ }
+ $php .= T . 'public function ';
+ if ($method->returnsReference()) {
+ $php .= '&';
+ }
+ $php .= $method->getName() . '(';
+ foreach ($method->getParameters() as $i => $parameter) {
+ if ($i >= 1) {
+ $php .= ', ';
+ }
+ if ($parameter->isArray()) {
+ $php .= 'array ';
+ }
+ if ($typehint = $parameter->getClass()) {
+ $php .= $typehint->getName() . ' ';
+ }
+ $php .= '$' . $parameter->getName();
+ if ($parameter->isDefaultValueAvailable()) {
+ $php .= ' = ' . $parameter->getDefaultValue();
+ }
+ }
+ $php .= ') {}' . N;
+ }
+ }
+ $php .= '}';
+}
+
+echo $php . N;
+

0 comments on commit 96320b0

Please sign in to comment.