From f82ba2f8c5d3840cb0fce91dc6a6bd22ee848da0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Bergl=C3=B8v?= Date: Sun, 12 Jun 2022 21:22:16 +0200 Subject: [PATCH] Initial Commit --- README.md | 63 ++ bootstrap.php | 34 + composer.json | 24 + docs/debug-Debugger-addSourceTree.md | 19 + docs/debug-Debugger-compileClassMap.md | 24 + docs/debug-Debugger-prop_E_ERROR.md | 8 + docs/debug-Debugger-prop_E_INTERNAL.md | 8 + docs/debug-Debugger-prop_E_WARNING.md | 8 + docs/debug-Debugger-trialRun.md | 22 + docs/debug-Debugger-validateImports.md | 24 + docs/debug-Debugger-validateSyntax.md | 22 + docs/debug-Debugger.md | 47 + docs/debug-DocumentFile-__construct.md | 17 + docs/debug-DocumentFile-fromCode.md | 16 + docs/debug-DocumentFile-fromResource.md | 16 + docs/debug-DocumentFile-getClass.md | 8 + docs/debug-DocumentFile-getClasses.md | 8 + docs/debug-DocumentFile-getConstant.md | 8 + docs/debug-DocumentFile-getConstants.md | 8 + docs/debug-DocumentFile-getFunction.md | 8 + docs/debug-DocumentFile-getFunctions.md | 8 + docs/debug-DocumentFile-getImport.md | 8 + docs/debug-DocumentFile-getImports.md | 8 + docs/debug-DocumentFile-getNamespace.md | 8 + docs/debug-DocumentFile-getReferences.md | 19 + docs/debug-DocumentFile-hasOpenTag.md | 8 + docs/debug-DocumentFile-isDeclaredEncoding.md | 8 + docs/debug-DocumentFile-isStrict.md | 8 + docs/debug-DocumentFile.md | 63 ++ docs/debug-Lexer-__construct.md | 58 ++ docs/debug-Lexer-getCurrent.md | 11 + docs/debug-Lexer-getIterator.md | 8 + docs/debug-Lexer-getNext.md | Bin 0 -> 628 bytes docs/debug-Lexer-getNextIf.md | 23 + docs/debug-Lexer-getNextUnless.md | 22 + docs/debug-Lexer-getOffset.md | 11 + docs/debug-Lexer-getPrevious.md | Bin 0 -> 644 bytes docs/debug-Lexer-getPreviousIf.md | 23 + docs/debug-Lexer-getPreviousUnless.md | 22 + docs/debug-Lexer-moveTo.md | 23 + docs/debug-Lexer-moveToNext.md | Bin 0 -> 628 bytes docs/debug-Lexer-moveToPrevious.md | Bin 0 -> 640 bytes docs/debug-Lexer-peakNext.md | Bin 0 -> 563 bytes docs/debug-Lexer-peakPrevious.md | Bin 0 -> 576 bytes docs/debug-Lexer-prop_OFFSET_CUR.md | 11 + docs/debug-Lexer-prop_OFFSET_END.md | 11 + docs/debug-Lexer-prop_OFFSET_SET.md | 11 + docs/debug-Lexer.md | Bin 0 -> 6221 bytes docs/debug.md | 17 + docs/entities-Argument-__construct.md | 18 + docs/entities-Argument-getName.md | 11 + docs/entities-Argument-getType.md | 11 + docs/entities-Argument-isByRef.md | 11 + docs/entities-Argument-isNullable.md | 11 + docs/entities-Argument-isOptional.md | 13 + docs/entities-Argument-isVariadic.md | 11 + docs/entities-Argument-prop_T_BYREF.md | 11 + docs/entities-Argument-prop_T_OPTIONAL.md | 11 + docs/entities-Argument-prop_T_VARIADIC.md | 11 + docs/entities-Argument.md | 44 + docs/entities-Clazz-__construct.md | 19 + docs/entities-Clazz-addMethod.md | 18 + docs/entities-Clazz-addProperty.md | 18 + docs/entities-Clazz-addTrait.md | 18 + docs/entities-Clazz-getExtends.md | 11 + docs/entities-Clazz-getImplement.md | 16 + docs/entities-Clazz-getImplements.md | 11 + docs/entities-Clazz-getIterator.md | 11 + docs/entities-Clazz-getMethod.md | 16 + docs/entities-Clazz-getMethods.md | 11 + docs/entities-Clazz-getName.md | 11 + docs/entities-Clazz-getProperties.md | 11 + docs/entities-Clazz-getProperty.md | 16 + docs/entities-Clazz-getTrait.md | 16 + docs/entities-Clazz-getTraits.md | 11 + docs/entities-Clazz-isAbstract.md | 11 + docs/entities-Clazz-isAnonymous.md | 11 + docs/entities-Clazz-isEnum.md | 11 + docs/entities-Clazz-isFinal.md | 11 + docs/entities-Clazz-isInterface.md | 11 + docs/entities-Clazz-isTrait.md | 11 + docs/entities-Clazz-prop_T_ABSTRACT.md | 11 + docs/entities-Clazz-prop_T_ANONYMOUS.md | 11 + docs/entities-Clazz-prop_T_CLASS.md | 11 + docs/entities-Clazz-prop_T_ENUM.md | 11 + docs/entities-Clazz-prop_T_FINAL.md | 11 + docs/entities-Clazz-prop_T_INTERFACE.md | 11 + docs/entities-Clazz-prop_T_TRAIT.md | 11 + docs/entities-Clazz-var_line.md | 11 + docs/entities-Clazz-var_pos.md | 11 + docs/entities-Clazz.md | 90 ++ docs/entities-Document-getClass.md | 16 + docs/entities-Document-getClasses.md | 13 + docs/entities-Document-getConstant.md | 16 + docs/entities-Document-getConstants.md | 11 + docs/entities-Document-getFunction.md | 16 + docs/entities-Document-getFunctions.md | 13 + docs/entities-Document-getImport.md | 16 + docs/entities-Document-getImports.md | 11 + docs/entities-Document-getNamespace.md | 14 + docs/entities-Document-hasOpenTag.md | 14 + docs/entities-Document-isDeclaredEncoding.md | 14 + docs/entities-Document-isStrict.md | 14 + docs/entities-Document.md | 42 + docs/entities-Entity-__toString.md | 8 + docs/entities-Entity-var_line.md | 11 + docs/entities-Entity-var_pos.md | 11 + docs/entities-Entity.md | 33 + docs/entities-Import-__construct.md | 18 + docs/entities-Import-getLabel.md | 15 + docs/entities-Import-getName.md | 14 + docs/entities-Import-getNamespace.md | 11 + docs/entities-Import-getType.md | 11 + docs/entities-Import-var_line.md | 11 + docs/entities-Import-var_pos.md | 11 + docs/entities-Import.md | 43 + docs/entities-IntersectType-__construct.md | 16 + docs/entities-IntersectType-getIterator.md | 11 + docs/entities-IntersectType-getLabel.md | 15 + docs/entities-IntersectType-getName.md | 14 + docs/entities-IntersectType-getNamespace.md | 11 + docs/entities-IntersectType-isNative.md | 11 + docs/entities-IntersectType-var_line.md | 11 + docs/entities-IntersectType-var_pos.md | 11 + docs/entities-IntersectType.md | 42 + docs/entities-Member-__construct.md | 18 + docs/entities-Member-getName.md | 11 + docs/entities-Member-getType.md | 11 + docs/entities-Member-isFinal.md | 11 + docs/entities-Member-isPrivate.md | 11 + docs/entities-Member-isProtected.md | 11 + docs/entities-Member-isPublic.md | 11 + docs/entities-Member-isStatic.md | 11 + docs/entities-Member-prop_T_FINAL.md | 11 + docs/entities-Member-prop_T_META.md | 11 + docs/entities-Member-prop_T_PRIVATE.md | 11 + docs/entities-Member-prop_T_PROTECTED.md | 11 + docs/entities-Member-prop_T_PUBLIC.md | 11 + docs/entities-Member-prop_T_STATIC.md | 11 + docs/entities-Member-var_line.md | 11 + docs/entities-Member-var_pos.md | 11 + docs/entities-Member.md | 65 ++ docs/entities-Name-__construct.md | 17 + docs/entities-Name-getLabel.md | 15 + docs/entities-Name-getName.md | 14 + docs/entities-Name-getNamespace.md | 11 + docs/entities-Name-var_line.md | 11 + docs/entities-Name-var_pos.md | 11 + docs/entities-Name.md | 36 + docs/entities-Property-__construct.md | 18 + docs/entities-Property-getName.md | 11 + docs/entities-Property-getType.md | 11 + docs/entities-Property-isEnumCase.md | 11 + docs/entities-Property-isFinal.md | 11 + docs/entities-Property-isPrivate.md | 11 + docs/entities-Property-isProtected.md | 11 + docs/entities-Property-isPublic.md | 11 + docs/entities-Property-isReadonly.md | 11 + docs/entities-Property-isStatic.md | 11 + docs/entities-Property-prop_T_CASE.md | 11 + docs/entities-Property-prop_T_FINAL.md | 11 + docs/entities-Property-prop_T_META.md | 11 + docs/entities-Property-prop_T_PRIVATE.md | 11 + docs/entities-Property-prop_T_PROTECTED.md | 11 + docs/entities-Property-prop_T_PUBLIC.md | 11 + docs/entities-Property-prop_T_READONLY.md | 11 + docs/entities-Property-prop_T_STATIC.md | 11 + docs/entities-Property-var_line.md | 11 + docs/entities-Property-var_pos.md | 11 + docs/entities-Property.md | 77 ++ docs/entities-Routine-__construct.md | 19 + docs/entities-Routine-addClass.md | 16 + docs/entities-Routine-addFunction.md | 16 + docs/entities-Routine-getArgument.md | 16 + docs/entities-Routine-getClasses.md | 11 + docs/entities-Routine-getFunctions.md | 11 + docs/entities-Routine-getIterator.md | 11 + docs/entities-Routine-getName.md | 11 + docs/entities-Routine-getType.md | 11 + docs/entities-Routine-isAbstract.md | 11 + docs/entities-Routine-isAnonymous.md | 11 + docs/entities-Routine-isByRef.md | 11 + docs/entities-Routine-isFinal.md | 11 + docs/entities-Routine-isPrivate.md | 11 + docs/entities-Routine-isProtected.md | 11 + docs/entities-Routine-isPublic.md | 11 + docs/entities-Routine-isStatic.md | 11 + docs/entities-Routine-prop_T_ABSTRACT.md | 11 + docs/entities-Routine-prop_T_ANONYMOUS.md | 11 + docs/entities-Routine-prop_T_BYREF.md | 11 + docs/entities-Routine-prop_T_FINAL.md | 11 + docs/entities-Routine-prop_T_META.md | 11 + docs/entities-Routine-prop_T_PRIVATE.md | 11 + docs/entities-Routine-prop_T_PROTECTED.md | 11 + docs/entities-Routine-prop_T_PUBLIC.md | 11 + docs/entities-Routine-prop_T_STATIC.md | 11 + docs/entities-Routine-var_line.md | 11 + docs/entities-Routine-var_pos.md | 11 + docs/entities-Routine.md | 93 ++ docs/entities-Type-__construct.md | 18 + docs/entities-Type-getLabel.md | 15 + docs/entities-Type-getName.md | 14 + docs/entities-Type-getNamespace.md | 11 + docs/entities-Type-isNative.md | 11 + docs/entities-Type-var_line.md | 11 + docs/entities-Type-var_pos.md | 11 + docs/entities-Type.md | 43 + docs/entities-UnionType-__construct.md | 16 + docs/entities-UnionType-getIterator.md | 11 + docs/entities-UnionType-getLabel.md | 15 + docs/entities-UnionType-getName.md | 14 + docs/entities-UnionType-getNamespace.md | 11 + docs/entities-UnionType-hasNative.md | 17 + docs/entities-UnionType-hasNativeNull.md | 13 + docs/entities-UnionType-isNative.md | 11 + docs/entities-UnionType-var_line.md | 11 + docs/entities-UnionType-var_pos.md | 11 + docs/entities-UnionType.md | 46 + docs/entities.md | 25 + src/debug/Debugger.php | 288 ++++++ src/debug/DocumentFile.php | 918 ++++++++++++++++++ src/debug/Lexer.php | 776 +++++++++++++++ src/debug/entities/Argument.php | 121 +++ src/debug/entities/Clazz.php | 316 ++++++ src/debug/entities/Document.php | 117 +++ src/debug/entities/Entity.php | 42 + src/debug/entities/Import.php | 72 ++ src/debug/entities/IntersectType.php | 68 ++ src/debug/entities/Member.php | 140 +++ src/debug/entities/Name.php | 100 ++ src/debug/entities/Property.php | 54 ++ src/debug/entities/Routine.php | 177 ++++ src/debug/entities/Type.php | 59 ++ src/debug/entities/UnionType.php | 102 ++ tests/src/LexerTest.php | 131 +++ 235 files changed, 6869 insertions(+) create mode 100644 README.md create mode 100755 bootstrap.php create mode 100644 composer.json create mode 100644 docs/debug-Debugger-addSourceTree.md create mode 100644 docs/debug-Debugger-compileClassMap.md create mode 100644 docs/debug-Debugger-prop_E_ERROR.md create mode 100644 docs/debug-Debugger-prop_E_INTERNAL.md create mode 100644 docs/debug-Debugger-prop_E_WARNING.md create mode 100644 docs/debug-Debugger-trialRun.md create mode 100644 docs/debug-Debugger-validateImports.md create mode 100644 docs/debug-Debugger-validateSyntax.md create mode 100644 docs/debug-Debugger.md create mode 100644 docs/debug-DocumentFile-__construct.md create mode 100644 docs/debug-DocumentFile-fromCode.md create mode 100644 docs/debug-DocumentFile-fromResource.md create mode 100644 docs/debug-DocumentFile-getClass.md create mode 100644 docs/debug-DocumentFile-getClasses.md create mode 100644 docs/debug-DocumentFile-getConstant.md create mode 100644 docs/debug-DocumentFile-getConstants.md create mode 100644 docs/debug-DocumentFile-getFunction.md create mode 100644 docs/debug-DocumentFile-getFunctions.md create mode 100644 docs/debug-DocumentFile-getImport.md create mode 100644 docs/debug-DocumentFile-getImports.md create mode 100644 docs/debug-DocumentFile-getNamespace.md create mode 100644 docs/debug-DocumentFile-getReferences.md create mode 100644 docs/debug-DocumentFile-hasOpenTag.md create mode 100644 docs/debug-DocumentFile-isDeclaredEncoding.md create mode 100644 docs/debug-DocumentFile-isStrict.md create mode 100644 docs/debug-DocumentFile.md create mode 100644 docs/debug-Lexer-__construct.md create mode 100644 docs/debug-Lexer-getCurrent.md create mode 100644 docs/debug-Lexer-getIterator.md create mode 100644 docs/debug-Lexer-getNext.md create mode 100644 docs/debug-Lexer-getNextIf.md create mode 100644 docs/debug-Lexer-getNextUnless.md create mode 100644 docs/debug-Lexer-getOffset.md create mode 100644 docs/debug-Lexer-getPrevious.md create mode 100644 docs/debug-Lexer-getPreviousIf.md create mode 100644 docs/debug-Lexer-getPreviousUnless.md create mode 100644 docs/debug-Lexer-moveTo.md create mode 100644 docs/debug-Lexer-moveToNext.md create mode 100644 docs/debug-Lexer-moveToPrevious.md create mode 100644 docs/debug-Lexer-peakNext.md create mode 100644 docs/debug-Lexer-peakPrevious.md create mode 100644 docs/debug-Lexer-prop_OFFSET_CUR.md create mode 100644 docs/debug-Lexer-prop_OFFSET_END.md create mode 100644 docs/debug-Lexer-prop_OFFSET_SET.md create mode 100644 docs/debug-Lexer.md create mode 100644 docs/debug.md create mode 100644 docs/entities-Argument-__construct.md create mode 100644 docs/entities-Argument-getName.md create mode 100644 docs/entities-Argument-getType.md create mode 100644 docs/entities-Argument-isByRef.md create mode 100644 docs/entities-Argument-isNullable.md create mode 100644 docs/entities-Argument-isOptional.md create mode 100644 docs/entities-Argument-isVariadic.md create mode 100644 docs/entities-Argument-prop_T_BYREF.md create mode 100644 docs/entities-Argument-prop_T_OPTIONAL.md create mode 100644 docs/entities-Argument-prop_T_VARIADIC.md create mode 100644 docs/entities-Argument.md create mode 100644 docs/entities-Clazz-__construct.md create mode 100644 docs/entities-Clazz-addMethod.md create mode 100644 docs/entities-Clazz-addProperty.md create mode 100644 docs/entities-Clazz-addTrait.md create mode 100644 docs/entities-Clazz-getExtends.md create mode 100644 docs/entities-Clazz-getImplement.md create mode 100644 docs/entities-Clazz-getImplements.md create mode 100644 docs/entities-Clazz-getIterator.md create mode 100644 docs/entities-Clazz-getMethod.md create mode 100644 docs/entities-Clazz-getMethods.md create mode 100644 docs/entities-Clazz-getName.md create mode 100644 docs/entities-Clazz-getProperties.md create mode 100644 docs/entities-Clazz-getProperty.md create mode 100644 docs/entities-Clazz-getTrait.md create mode 100644 docs/entities-Clazz-getTraits.md create mode 100644 docs/entities-Clazz-isAbstract.md create mode 100644 docs/entities-Clazz-isAnonymous.md create mode 100644 docs/entities-Clazz-isEnum.md create mode 100644 docs/entities-Clazz-isFinal.md create mode 100644 docs/entities-Clazz-isInterface.md create mode 100644 docs/entities-Clazz-isTrait.md create mode 100644 docs/entities-Clazz-prop_T_ABSTRACT.md create mode 100644 docs/entities-Clazz-prop_T_ANONYMOUS.md create mode 100644 docs/entities-Clazz-prop_T_CLASS.md create mode 100644 docs/entities-Clazz-prop_T_ENUM.md create mode 100644 docs/entities-Clazz-prop_T_FINAL.md create mode 100644 docs/entities-Clazz-prop_T_INTERFACE.md create mode 100644 docs/entities-Clazz-prop_T_TRAIT.md create mode 100644 docs/entities-Clazz-var_line.md create mode 100644 docs/entities-Clazz-var_pos.md create mode 100644 docs/entities-Clazz.md create mode 100644 docs/entities-Document-getClass.md create mode 100644 docs/entities-Document-getClasses.md create mode 100644 docs/entities-Document-getConstant.md create mode 100644 docs/entities-Document-getConstants.md create mode 100644 docs/entities-Document-getFunction.md create mode 100644 docs/entities-Document-getFunctions.md create mode 100644 docs/entities-Document-getImport.md create mode 100644 docs/entities-Document-getImports.md create mode 100644 docs/entities-Document-getNamespace.md create mode 100644 docs/entities-Document-hasOpenTag.md create mode 100644 docs/entities-Document-isDeclaredEncoding.md create mode 100644 docs/entities-Document-isStrict.md create mode 100644 docs/entities-Document.md create mode 100644 docs/entities-Entity-__toString.md create mode 100644 docs/entities-Entity-var_line.md create mode 100644 docs/entities-Entity-var_pos.md create mode 100644 docs/entities-Entity.md create mode 100644 docs/entities-Import-__construct.md create mode 100644 docs/entities-Import-getLabel.md create mode 100644 docs/entities-Import-getName.md create mode 100644 docs/entities-Import-getNamespace.md create mode 100644 docs/entities-Import-getType.md create mode 100644 docs/entities-Import-var_line.md create mode 100644 docs/entities-Import-var_pos.md create mode 100644 docs/entities-Import.md create mode 100644 docs/entities-IntersectType-__construct.md create mode 100644 docs/entities-IntersectType-getIterator.md create mode 100644 docs/entities-IntersectType-getLabel.md create mode 100644 docs/entities-IntersectType-getName.md create mode 100644 docs/entities-IntersectType-getNamespace.md create mode 100644 docs/entities-IntersectType-isNative.md create mode 100644 docs/entities-IntersectType-var_line.md create mode 100644 docs/entities-IntersectType-var_pos.md create mode 100644 docs/entities-IntersectType.md create mode 100644 docs/entities-Member-__construct.md create mode 100644 docs/entities-Member-getName.md create mode 100644 docs/entities-Member-getType.md create mode 100644 docs/entities-Member-isFinal.md create mode 100644 docs/entities-Member-isPrivate.md create mode 100644 docs/entities-Member-isProtected.md create mode 100644 docs/entities-Member-isPublic.md create mode 100644 docs/entities-Member-isStatic.md create mode 100644 docs/entities-Member-prop_T_FINAL.md create mode 100644 docs/entities-Member-prop_T_META.md create mode 100644 docs/entities-Member-prop_T_PRIVATE.md create mode 100644 docs/entities-Member-prop_T_PROTECTED.md create mode 100644 docs/entities-Member-prop_T_PUBLIC.md create mode 100644 docs/entities-Member-prop_T_STATIC.md create mode 100644 docs/entities-Member-var_line.md create mode 100644 docs/entities-Member-var_pos.md create mode 100644 docs/entities-Member.md create mode 100644 docs/entities-Name-__construct.md create mode 100644 docs/entities-Name-getLabel.md create mode 100644 docs/entities-Name-getName.md create mode 100644 docs/entities-Name-getNamespace.md create mode 100644 docs/entities-Name-var_line.md create mode 100644 docs/entities-Name-var_pos.md create mode 100644 docs/entities-Name.md create mode 100644 docs/entities-Property-__construct.md create mode 100644 docs/entities-Property-getName.md create mode 100644 docs/entities-Property-getType.md create mode 100644 docs/entities-Property-isEnumCase.md create mode 100644 docs/entities-Property-isFinal.md create mode 100644 docs/entities-Property-isPrivate.md create mode 100644 docs/entities-Property-isProtected.md create mode 100644 docs/entities-Property-isPublic.md create mode 100644 docs/entities-Property-isReadonly.md create mode 100644 docs/entities-Property-isStatic.md create mode 100644 docs/entities-Property-prop_T_CASE.md create mode 100644 docs/entities-Property-prop_T_FINAL.md create mode 100644 docs/entities-Property-prop_T_META.md create mode 100644 docs/entities-Property-prop_T_PRIVATE.md create mode 100644 docs/entities-Property-prop_T_PROTECTED.md create mode 100644 docs/entities-Property-prop_T_PUBLIC.md create mode 100644 docs/entities-Property-prop_T_READONLY.md create mode 100644 docs/entities-Property-prop_T_STATIC.md create mode 100644 docs/entities-Property-var_line.md create mode 100644 docs/entities-Property-var_pos.md create mode 100644 docs/entities-Property.md create mode 100644 docs/entities-Routine-__construct.md create mode 100644 docs/entities-Routine-addClass.md create mode 100644 docs/entities-Routine-addFunction.md create mode 100644 docs/entities-Routine-getArgument.md create mode 100644 docs/entities-Routine-getClasses.md create mode 100644 docs/entities-Routine-getFunctions.md create mode 100644 docs/entities-Routine-getIterator.md create mode 100644 docs/entities-Routine-getName.md create mode 100644 docs/entities-Routine-getType.md create mode 100644 docs/entities-Routine-isAbstract.md create mode 100644 docs/entities-Routine-isAnonymous.md create mode 100644 docs/entities-Routine-isByRef.md create mode 100644 docs/entities-Routine-isFinal.md create mode 100644 docs/entities-Routine-isPrivate.md create mode 100644 docs/entities-Routine-isProtected.md create mode 100644 docs/entities-Routine-isPublic.md create mode 100644 docs/entities-Routine-isStatic.md create mode 100644 docs/entities-Routine-prop_T_ABSTRACT.md create mode 100644 docs/entities-Routine-prop_T_ANONYMOUS.md create mode 100644 docs/entities-Routine-prop_T_BYREF.md create mode 100644 docs/entities-Routine-prop_T_FINAL.md create mode 100644 docs/entities-Routine-prop_T_META.md create mode 100644 docs/entities-Routine-prop_T_PRIVATE.md create mode 100644 docs/entities-Routine-prop_T_PROTECTED.md create mode 100644 docs/entities-Routine-prop_T_PUBLIC.md create mode 100644 docs/entities-Routine-prop_T_STATIC.md create mode 100644 docs/entities-Routine-var_line.md create mode 100644 docs/entities-Routine-var_pos.md create mode 100644 docs/entities-Routine.md create mode 100644 docs/entities-Type-__construct.md create mode 100644 docs/entities-Type-getLabel.md create mode 100644 docs/entities-Type-getName.md create mode 100644 docs/entities-Type-getNamespace.md create mode 100644 docs/entities-Type-isNative.md create mode 100644 docs/entities-Type-var_line.md create mode 100644 docs/entities-Type-var_pos.md create mode 100644 docs/entities-Type.md create mode 100644 docs/entities-UnionType-__construct.md create mode 100644 docs/entities-UnionType-getIterator.md create mode 100644 docs/entities-UnionType-getLabel.md create mode 100644 docs/entities-UnionType-getName.md create mode 100644 docs/entities-UnionType-getNamespace.md create mode 100644 docs/entities-UnionType-hasNative.md create mode 100644 docs/entities-UnionType-hasNativeNull.md create mode 100644 docs/entities-UnionType-isNative.md create mode 100644 docs/entities-UnionType-var_line.md create mode 100644 docs/entities-UnionType-var_pos.md create mode 100644 docs/entities-UnionType.md create mode 100644 docs/entities.md create mode 100755 src/debug/Debugger.php create mode 100755 src/debug/DocumentFile.php create mode 100755 src/debug/Lexer.php create mode 100755 src/debug/entities/Argument.php create mode 100755 src/debug/entities/Clazz.php create mode 100755 src/debug/entities/Document.php create mode 100755 src/debug/entities/Entity.php create mode 100755 src/debug/entities/Import.php create mode 100755 src/debug/entities/IntersectType.php create mode 100755 src/debug/entities/Member.php create mode 100755 src/debug/entities/Name.php create mode 100755 src/debug/entities/Property.php create mode 100755 src/debug/entities/Routine.php create mode 100755 src/debug/entities/Type.php create mode 100755 src/debug/entities/UnionType.php create mode 100755 tests/src/LexerTest.php diff --git a/README.md b/README.md new file mode 100644 index 0000000..e6db4ad --- /dev/null +++ b/README.md @@ -0,0 +1,63 @@ +# IMPHP - Debug +___ + +Debugging a project in PHP is not very easy, compared to the debugging done in things like a `Java` project. The biggest problem with PHP, which is also some of the performance benefits, is that most errors will be hidden away until the exact moment that you try to execute it. Even though you may have executed that exact file or even method/function a 100 times before, successfully. + +__Example__ + +```php +use namespace\SomeClasss; + +function someTest() { + try { + // Something that cold raise exceptions + + } catch (Exception $e) { + throw new SomeClass( $e->getMessage() ); + } +} +``` + +The code above could perform perfectly 1000 times, so long as an exception is never raised in the code being executed. But, as soon as an exception is raised and the code tries to invoke `SomeClass`, it will fail. Why? Because it will be trying to use `\SomeClass` rather than `\namespace\SomeClass` because of the extra `s` that was added in the `use` clause. We are including `SomeClassS` and not `SomeClass`. However PHP will never know about this small mistake until the exact moment that it tries to use it. This is a feature in PHP and not a mistake, because without allowing this, things like autoloading would either not be available or it would auto-include every single class file that was being used, even if they are not needed. + +But regardless of why PHP is working the way it is, it still raises a lot of problems when building projects. The above example is just one of many small and common mistakes that can linger in code for ages, before finally breaking a system after it has been published. One could test this during Unit Testing, but even such tests can miss a problem or two. The more debugging done, the more issues will be found. + +This package was built for internal use cases when working on IMPHP, to catch the most common issues: + + - General code syntax error. + - Validate enherited datatypes. + - Validate all datatypes being used in a file. + - Check `use` clauses to see if they are even used in the code. + - ... + +This package does not contain the entire test suides used by IMPHP, because those are specific to those projects. But it does include the main tools powering them. + +### Full Documentation + +You can view the [Full Documentation](docs/base.md) to lean more about what this offers. + +### Installation + +__Using .phar library__ + +```sh +wget https://github.com/IMPHP/debug/releases/download//imphp-debug.phar +``` + +```php +require "imphp-debug.phar"; + +... +``` + +__Clone via git__ + +```sh +git clone https://github.com/IMPHP/debug.git imphp/debug/ +``` + +__Composer _(Packagist)___ + +```sh +composer require imphp/debug +``` diff --git a/bootstrap.php b/bootstrap.php new file mode 100755 index 0000000..fc998dd --- /dev/null +++ b/bootstrap.php @@ -0,0 +1,34 @@ +=8.0.0" + }, + + "autoload": { + "psr-4": { + "im\\": "src/" + }, + "files": ["bootstrap.php"] + } +} diff --git a/docs/debug-Debugger-addSourceTree.md b/docs/debug-Debugger-addSourceTree.md new file mode 100644 index 0000000..29b7dff --- /dev/null +++ b/docs/debug-Debugger-addSourceTree.md @@ -0,0 +1,19 @@ +# [Debug](debug.md) / [Debugger](debug-Debugger.md) :: addSourceTree + > im\debug\Debugger +____ + +## Description +Add a source directory + +This will be used to resolve dependencies when doing things +like `trialRun` and such. + +## Synopsis +```php +public addSourceTree(string $path): void +``` + +## Parameters +| Name | Description | +| :--- | :---------- | +| path | Directory path with additional dependencies | diff --git a/docs/debug-Debugger-compileClassMap.md b/docs/debug-Debugger-compileClassMap.md new file mode 100644 index 0000000..dda6e65 --- /dev/null +++ b/docs/debug-Debugger-compileClassMap.md @@ -0,0 +1,24 @@ +# [Debug](debug.md) / [Debugger](debug-Debugger.md) :: compileClassMap + > im\debug\Debugger +____ + +## Description +Scan a directory and build a class map + +This method will build a complete class map from a directory. +It will scan each file and extract any class information from it, +and add it's path to the map. + +## Synopsis +```php +public static compileClassMap(string $path, bool $fullPath = FALSE): array +``` + +## Parameters +| Name | Description | +| :--- | :---------- | +| path | The directory to scan | +| fullPath | Add complete paths to the class map.
Otyherwise the paths will be relative to $path | + +## Return +An assoc array with class names as key and file paths as value diff --git a/docs/debug-Debugger-prop_E_ERROR.md b/docs/debug-Debugger-prop_E_ERROR.md new file mode 100644 index 0000000..0da71a9 --- /dev/null +++ b/docs/debug-Debugger-prop_E_ERROR.md @@ -0,0 +1,8 @@ +# [Debug](debug.md) / [Debugger](debug-Debugger.md) :: E_ERROR + > im\debug\Debugger +____ + +## Synopsis +```php +public E_ERROR = 500 +``` diff --git a/docs/debug-Debugger-prop_E_INTERNAL.md b/docs/debug-Debugger-prop_E_INTERNAL.md new file mode 100644 index 0000000..b4f529d --- /dev/null +++ b/docs/debug-Debugger-prop_E_INTERNAL.md @@ -0,0 +1,8 @@ +# [Debug](debug.md) / [Debugger](debug-Debugger.md) :: E_INTERNAL + > im\debug\Debugger +____ + +## Synopsis +```php +public E_INTERNAL = -1 +``` diff --git a/docs/debug-Debugger-prop_E_WARNING.md b/docs/debug-Debugger-prop_E_WARNING.md new file mode 100644 index 0000000..cb0f58c --- /dev/null +++ b/docs/debug-Debugger-prop_E_WARNING.md @@ -0,0 +1,8 @@ +# [Debug](debug.md) / [Debugger](debug-Debugger.md) :: E_WARNING + > im\debug\Debugger +____ + +## Synopsis +```php +public E_WARNING = 501 +``` diff --git a/docs/debug-Debugger-trialRun.md b/docs/debug-Debugger-trialRun.md new file mode 100644 index 0000000..facc724 --- /dev/null +++ b/docs/debug-Debugger-trialRun.md @@ -0,0 +1,22 @@ +# [Debug](debug.md) / [Debugger](debug-Debugger.md) :: trialRun + > im\debug\Debugger +____ + +## Description +Run a file in a sandboxed process + +This will setup an autoloader using the source trees +within this instance and run a script in a sub-process. + +If no error occure, the method will return the output +as an array where each element represent a line of the output. + +## Synopsis +```php +public trialRun(string $file): array +``` + +## Parameters +| Name | Description | +| :--- | :---------- | +| file | The file to run | diff --git a/docs/debug-Debugger-validateImports.md b/docs/debug-Debugger-validateImports.md new file mode 100644 index 0000000..67b5d8a --- /dev/null +++ b/docs/debug-Debugger-validateImports.md @@ -0,0 +1,24 @@ +# [Debug](debug.md) / [Debugger](debug-Debugger.md) :: validateImports + > im\debug\Debugger +____ + +## Description +Validate class imports + +This method will report any missing or unused imports. +It checks all class references, resolved using the import information +in the file, and looks it up in iether the produced source tree or among +PHP's internal classes. + +It will also look at all the defined imports to see if they are actually +being used within the file. + +## Synopsis +```php +public validateImports(string $file): bool +``` + +## Parameters +| Name | Description | +| :--- | :---------- | +| file | The file to check | diff --git a/docs/debug-Debugger-validateSyntax.md b/docs/debug-Debugger-validateSyntax.md new file mode 100644 index 0000000..86ce2aa --- /dev/null +++ b/docs/debug-Debugger-validateSyntax.md @@ -0,0 +1,22 @@ +# [Debug](debug.md) / [Debugger](debug-Debugger.md) :: validateSyntax + > im\debug\Debugger +____ + +## Description +Run a lint test and validate the code syntax. + +This is a lightweigth version of `trialRun()`. +It's not gonna be as aggressive, but it will catch any +syntax error in the file. + + > This method does not require any additional source tree to work + +## Synopsis +```php +public validateSyntax(string $file, bool $strict = FALSE): bool +``` + +## Parameters +| Name | Description | +| :--- | :---------- | +| file | The file to check | diff --git a/docs/debug-Debugger.md b/docs/debug-Debugger.md new file mode 100644 index 0000000..cfd16ae --- /dev/null +++ b/docs/debug-Debugger.md @@ -0,0 +1,47 @@ +# [Debug](debug.md) / Debugger + > im\debug\Debugger +____ + +## Description +Provides tools to debug code files + +This class has a few tools to do basic debug checks on a file. +This is a great way to catch a lot of the basic errors like missing +imports, type error in class names, syntax error etc. + +This does not replace a proper Unit Testing setup, but it can be useful +for fixing basic issues before running additional tests. + +## Synopsis +```php +final class Debugger { + + // Constants + public E_INTERNAL = -1 + public E_WARNING = 501 + public E_ERROR = 500 + + // Methods + public static compileClassMap(string $path, bool $fullPath = FALSE): array + public addSourceTree(string $path): void + public validateSyntax(string $file, bool $strict = FALSE): bool + public validateImports(string $file): bool + public trialRun(string $file): array +} +``` + +## Constants +| Name | Description | +| :--- | :---------- | +| [__Debugger :: E\_INTERNAL__](debug-Debugger-prop_E_INTERNAL.md) | | +| [__Debugger :: E\_WARNING__](debug-Debugger-prop_E_WARNING.md) | | +| [__Debugger :: E\_ERROR__](debug-Debugger-prop_E_ERROR.md) | | + +## Methods +| Name | Description | +| :--- | :---------- | +| [__Debugger :: compileClassMap__](debug-Debugger-compileClassMap.md) | Scan a directory and build a class map This method will build a complete class map from a directory | +| [__Debugger :: addSourceTree__](debug-Debugger-addSourceTree.md) | Add a source directory This will be used to resolve dependencies when doing things like `trialRun` and such | +| [__Debugger :: validateSyntax__](debug-Debugger-validateSyntax.md) | Run a lint test and validate the code syntax | +| [__Debugger :: validateImports__](debug-Debugger-validateImports.md) | Validate class imports This method will report any missing or unused imports | +| [__Debugger :: trialRun__](debug-Debugger-trialRun.md) | Run a file in a sandboxed process This will setup an autoloader using the source trees within this instance and run a script in a sub-process | diff --git a/docs/debug-DocumentFile-__construct.md b/docs/debug-DocumentFile-__construct.md new file mode 100644 index 0000000..d6ad3af --- /dev/null +++ b/docs/debug-DocumentFile-__construct.md @@ -0,0 +1,17 @@ +# [Debug](debug.md) / [DocumentFile](debug-DocumentFile.md) :: __construct + > im\debug\DocumentFile +____ + +## Description +Create a new DocumentFile + +## Synopsis +```php +public __construct(string $file, bool $onlyHeaders = FALSE) +``` + +## Parameters +| Name | Description | +| :--- | :---------- | +| file | Path to a php file | +| onlyHeaders | Only extract headers like openTag and define information | diff --git a/docs/debug-DocumentFile-fromCode.md b/docs/debug-DocumentFile-fromCode.md new file mode 100644 index 0000000..76953b9 --- /dev/null +++ b/docs/debug-DocumentFile-fromCode.md @@ -0,0 +1,16 @@ +# [Debug](debug.md) / [DocumentFile](debug-DocumentFile.md) :: fromCode + > im\debug\DocumentFile +____ + +## Description +Return an instance from a code string + +## Synopsis +```php +public static fromCode(string $code): self +``` + +## Parameters +| Name | Description | +| :--- | :---------- | +| code | Code to process, incl. PHP open tags | diff --git a/docs/debug-DocumentFile-fromResource.md b/docs/debug-DocumentFile-fromResource.md new file mode 100644 index 0000000..19e5ac7 --- /dev/null +++ b/docs/debug-DocumentFile-fromResource.md @@ -0,0 +1,16 @@ +# [Debug](debug.md) / [DocumentFile](debug-DocumentFile.md) :: fromResource + > im\debug\DocumentFile +____ + +## Description +Return an instance from a code resource + +## Synopsis +```php +public static fromResource($stream): self +``` + +## Parameters +| Name | Description | +| :--- | :---------- | +| stream | A resource with code to process | diff --git a/docs/debug-DocumentFile-getClass.md b/docs/debug-DocumentFile-getClass.md new file mode 100644 index 0000000..d6adbe9 --- /dev/null +++ b/docs/debug-DocumentFile-getClass.md @@ -0,0 +1,8 @@ +# [Debug](debug.md) / [DocumentFile](debug-DocumentFile.md) :: getClass + > im\debug\DocumentFile +____ + +## Synopsis +```php +public getClass(string $name): null|im\debug\entities\Clazz +``` diff --git a/docs/debug-DocumentFile-getClasses.md b/docs/debug-DocumentFile-getClasses.md new file mode 100644 index 0000000..8eaf1df --- /dev/null +++ b/docs/debug-DocumentFile-getClasses.md @@ -0,0 +1,8 @@ +# [Debug](debug.md) / [DocumentFile](debug-DocumentFile.md) :: getClasses + > im\debug\DocumentFile +____ + +## Synopsis +```php +public getClasses(): array +``` diff --git a/docs/debug-DocumentFile-getConstant.md b/docs/debug-DocumentFile-getConstant.md new file mode 100644 index 0000000..0be62af --- /dev/null +++ b/docs/debug-DocumentFile-getConstant.md @@ -0,0 +1,8 @@ +# [Debug](debug.md) / [DocumentFile](debug-DocumentFile.md) :: getConstant + > im\debug\DocumentFile +____ + +## Synopsis +```php +public getConstant(string $name): null|im\debug\entities\Property +``` diff --git a/docs/debug-DocumentFile-getConstants.md b/docs/debug-DocumentFile-getConstants.md new file mode 100644 index 0000000..d3ef2d8 --- /dev/null +++ b/docs/debug-DocumentFile-getConstants.md @@ -0,0 +1,8 @@ +# [Debug](debug.md) / [DocumentFile](debug-DocumentFile.md) :: getConstants + > im\debug\DocumentFile +____ + +## Synopsis +```php +public getConstants(): array +``` diff --git a/docs/debug-DocumentFile-getFunction.md b/docs/debug-DocumentFile-getFunction.md new file mode 100644 index 0000000..f294ce8 --- /dev/null +++ b/docs/debug-DocumentFile-getFunction.md @@ -0,0 +1,8 @@ +# [Debug](debug.md) / [DocumentFile](debug-DocumentFile.md) :: getFunction + > im\debug\DocumentFile +____ + +## Synopsis +```php +public getFunction(string $label): null|im\debug\entities\Routine +``` diff --git a/docs/debug-DocumentFile-getFunctions.md b/docs/debug-DocumentFile-getFunctions.md new file mode 100644 index 0000000..3404bdc --- /dev/null +++ b/docs/debug-DocumentFile-getFunctions.md @@ -0,0 +1,8 @@ +# [Debug](debug.md) / [DocumentFile](debug-DocumentFile.md) :: getFunctions + > im\debug\DocumentFile +____ + +## Synopsis +```php +public getFunctions(): array +``` diff --git a/docs/debug-DocumentFile-getImport.md b/docs/debug-DocumentFile-getImport.md new file mode 100644 index 0000000..331419e --- /dev/null +++ b/docs/debug-DocumentFile-getImport.md @@ -0,0 +1,8 @@ +# [Debug](debug.md) / [DocumentFile](debug-DocumentFile.md) :: getImport + > im\debug\DocumentFile +____ + +## Synopsis +```php +public getImport(string $name): null|im\debug\entities\Import +``` diff --git a/docs/debug-DocumentFile-getImports.md b/docs/debug-DocumentFile-getImports.md new file mode 100644 index 0000000..503a7ca --- /dev/null +++ b/docs/debug-DocumentFile-getImports.md @@ -0,0 +1,8 @@ +# [Debug](debug.md) / [DocumentFile](debug-DocumentFile.md) :: getImports + > im\debug\DocumentFile +____ + +## Synopsis +```php +public getImports(): array +``` diff --git a/docs/debug-DocumentFile-getNamespace.md b/docs/debug-DocumentFile-getNamespace.md new file mode 100644 index 0000000..a67fffd --- /dev/null +++ b/docs/debug-DocumentFile-getNamespace.md @@ -0,0 +1,8 @@ +# [Debug](debug.md) / [DocumentFile](debug-DocumentFile.md) :: getNamespace + > im\debug\DocumentFile +____ + +## Synopsis +```php +public getNamespace(): null|string +``` diff --git a/docs/debug-DocumentFile-getReferences.md b/docs/debug-DocumentFile-getReferences.md new file mode 100644 index 0000000..fe7da5b --- /dev/null +++ b/docs/debug-DocumentFile-getReferences.md @@ -0,0 +1,19 @@ +# [Debug](debug.md) / [DocumentFile](debug-DocumentFile.md) :: getReferences + > im\debug\DocumentFile +____ + +## Description +Get a list of all class references + +A class reference is every single class access made. +For an example accessing a static property or constant, +creating a new class instance, implementing an interface, +extending a base class etc. + +This method returns a list of all classes being used within +this file. + +## Synopsis +```php +public getReferences(): array +``` diff --git a/docs/debug-DocumentFile-hasOpenTag.md b/docs/debug-DocumentFile-hasOpenTag.md new file mode 100644 index 0000000..7c31744 --- /dev/null +++ b/docs/debug-DocumentFile-hasOpenTag.md @@ -0,0 +1,8 @@ +# [Debug](debug.md) / [DocumentFile](debug-DocumentFile.md) :: hasOpenTag + > im\debug\DocumentFile +____ + +## Synopsis +```php +public hasOpenTag(): bool +``` diff --git a/docs/debug-DocumentFile-isDeclaredEncoding.md b/docs/debug-DocumentFile-isDeclaredEncoding.md new file mode 100644 index 0000000..0ce6482 --- /dev/null +++ b/docs/debug-DocumentFile-isDeclaredEncoding.md @@ -0,0 +1,8 @@ +# [Debug](debug.md) / [DocumentFile](debug-DocumentFile.md) :: isDeclaredEncoding + > im\debug\DocumentFile +____ + +## Synopsis +```php +public isDeclaredEncoding(): null|string +``` diff --git a/docs/debug-DocumentFile-isStrict.md b/docs/debug-DocumentFile-isStrict.md new file mode 100644 index 0000000..5be09f7 --- /dev/null +++ b/docs/debug-DocumentFile-isStrict.md @@ -0,0 +1,8 @@ +# [Debug](debug.md) / [DocumentFile](debug-DocumentFile.md) :: isStrict + > im\debug\DocumentFile +____ + +## Synopsis +```php +public isStrict(): bool +``` diff --git a/docs/debug-DocumentFile.md b/docs/debug-DocumentFile.md new file mode 100644 index 0000000..37c5b53 --- /dev/null +++ b/docs/debug-DocumentFile.md @@ -0,0 +1,63 @@ +# [Debug](debug.md) / DocumentFile + > im\debug\DocumentFile +____ + +## Description +Extract information from a PHP file + +This file will extract information like classes, functions, +and so on, from a PHP file. It's similar to what information you can +get from reflection, but without the need to load/include a file. + +The class uses basic tokens to build a complete set of OOP entities of +the file content. Functions, closures, classes, anonymous classes etc. +are nested within one another as they are written in the file. Each type, +e.g. class, function, function parameter, imports and so on, are represented by +it's own object, containing all of it's information. + +All type declarations, implements, extends ... are resolved based on the documents namespace +and it's defined imports. + +## Synopsis +```php +class DocumentFile implements im\debug\entities\Document { + + // Methods + public static fromCode(string $code): self + public static fromResource($stream): self + public __construct(string $file, bool $onlyHeaders = FALSE) + public hasOpenTag(): bool + public isStrict(): bool + public isDeclaredEncoding(): null|string + public getNamespace(): null|string + public getReferences(): array + public getConstant(string $name): null|im\debug\entities\Property + public getConstants(): array + public getImport(string $name): null|im\debug\entities\Import + public getImports(): array + public getClass(string $name): null|im\debug\entities\Clazz + public getClasses(): array + public getFunction(string $label): null|im\debug\entities\Routine + public getFunctions(): array +} +``` + +## Methods +| Name | Description | +| :--- | :---------- | +| [__DocumentFile :: fromCode__](debug-DocumentFile-fromCode.md) | Return an instance from a code string | +| [__DocumentFile :: fromResource__](debug-DocumentFile-fromResource.md) | Return an instance from a code resource | +| [__DocumentFile :: \_\_construct__](debug-DocumentFile-__construct.md) | Create a new DocumentFile | +| [__DocumentFile :: hasOpenTag__](debug-DocumentFile-hasOpenTag.md) | | +| [__DocumentFile :: isStrict__](debug-DocumentFile-isStrict.md) | | +| [__DocumentFile :: isDeclaredEncoding__](debug-DocumentFile-isDeclaredEncoding.md) | | +| [__DocumentFile :: getNamespace__](debug-DocumentFile-getNamespace.md) | | +| [__DocumentFile :: getReferences__](debug-DocumentFile-getReferences.md) | Get a list of all class references A class reference is every single class access made | +| [__DocumentFile :: getConstant__](debug-DocumentFile-getConstant.md) | | +| [__DocumentFile :: getConstants__](debug-DocumentFile-getConstants.md) | | +| [__DocumentFile :: getImport__](debug-DocumentFile-getImport.md) | | +| [__DocumentFile :: getImports__](debug-DocumentFile-getImports.md) | | +| [__DocumentFile :: getClass__](debug-DocumentFile-getClass.md) | | +| [__DocumentFile :: getClasses__](debug-DocumentFile-getClasses.md) | | +| [__DocumentFile :: getFunction__](debug-DocumentFile-getFunction.md) | | +| [__DocumentFile :: getFunctions__](debug-DocumentFile-getFunctions.md) | | diff --git a/docs/debug-Lexer-__construct.md b/docs/debug-Lexer-__construct.md new file mode 100644 index 0000000..069b3f6 --- /dev/null +++ b/docs/debug-Lexer-__construct.md @@ -0,0 +1,58 @@ +# [Debug](debug.md) / [Lexer](debug-Lexer.md) :: __construct + > im\debug\Lexer +____ + +## Description +Create a new Lexer instance + +__Scan__ + +The scan option will do the following alterations: + +| Original Token | New Token | +| ------------------------------------------------------------------ | ------------- | +| T_CLASS (Definition only) | T_CLASSDEF | +| T_INTERFACE (Definition only) | T_CLASSDEF | +| T_TRAIT (Definition only) | T_CLASSDEF | +| T_ENUM (Definition only) | T_CLASSDEF | +| T_STRING (Following T_CONST in class body) | T_PROPERTY | +| T_STRING (Following T_CASE in class body) | T_PROPERTY | +| T_VARIABLE (In class body) | T_PROPERTY | +| T_VARIABLE (In function arguments) | T_PARAM | +| T_NAME_RELATIVE | T_STRING | +| T_NAME_QUALIFIED | T_STRING | +| T_NAME_FULLY_QUALIFIED | T_STRING | +| T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG (PHP 8.1) | & | +| T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG (PHP 8.1) | & | +| Character '}' belonging to T_CURLY_OPEN | T_CURLY_CLOSE | +| ALL typdef tokens, e.g. ?string or int|null ... get's combined | T_TYPEDEF | + +## Synopsis +```php +public __construct(string $code, bool $scan = TRUE) +``` + +## Parameters +| Name | Description | +| :--- | :---------- | +| code | Code to tokenize | +| scan | Whether or not to scan the tokens and make alterations. | + +## Example 1 +```php +function myFunc(?int $arg1): string {} +``` + +Outputs: +``` +T_FUNCTION 'function' +T_STRING 'myFunc' +( +T_TYPEDEF '?int' +T_PARAM 'arg1' +) +: +T_TYPEDEF 'string' +{ +} +``` diff --git a/docs/debug-Lexer-getCurrent.md b/docs/debug-Lexer-getCurrent.md new file mode 100644 index 0000000..05987f0 --- /dev/null +++ b/docs/debug-Lexer-getCurrent.md @@ -0,0 +1,11 @@ +# [Debug](debug.md) / [Lexer](debug-Lexer.md) :: getCurrent + > im\debug\Lexer +____ + +## Description +Get the current token being pointed to + +## Synopsis +```php +public getCurrent(): PhpToken +``` diff --git a/docs/debug-Lexer-getIterator.md b/docs/debug-Lexer-getIterator.md new file mode 100644 index 0000000..b117bb3 --- /dev/null +++ b/docs/debug-Lexer-getIterator.md @@ -0,0 +1,8 @@ +# [Debug](debug.md) / [Lexer](debug-Lexer.md) :: getIterator + > im\debug\Lexer +____ + +## Synopsis +```php +public getIterator(): Traversable +``` diff --git a/docs/debug-Lexer-getNext.md b/docs/debug-Lexer-getNext.md new file mode 100644 index 0000000000000000000000000000000000000000..853e0f27a0226870244233bde8d28a7ce9fb3819 GIT binary patch literal 628 zcmZ9JL2DZ^5QTHruXx}<60kRSLj$2{FEwsRU2=#^B=638MRp}2X_FZC$7e=%L#Yr5 zjo!?B^EAWL9qq>bpUXy$YG|%-ji(j8Q#{2M)?DyHYu%j z=zQST&GEkm=PCPen^|yic5$`DeHS*u zEr_4LLY}u#GcAC1Q1aq_s zgUNL#io#o!{1e)Q$BrBtYOVWJ%-K%%^v&{!<%MlUW80R*GDzz2`w$HqA6af3zWw|z drRC2b%73ckAsl-1EFS3-kauW}?Z-%!`T#=0)QkWC literal 0 HcmV?d00001 diff --git a/docs/debug-Lexer-getNextIf.md b/docs/debug-Lexer-getNextIf.md new file mode 100644 index 0000000..bd94d1e --- /dev/null +++ b/docs/debug-Lexer-getNextIf.md @@ -0,0 +1,23 @@ +# [Debug](debug.md) / [Lexer](debug-Lexer.md) :: getNextIf + > im\debug\Lexer +____ + +## Description +Only advance the pointer and return the next token if it matches. + +This is the same as calling `getNext`, only it will only advance and +return the token if it matches $kind. This is equal to combining +`peakNext` with `getNext`. + +## Synopsis +```php +public getNextIf(array|string|int $kind): PhpToken +``` + +## Parameters +| Name | Description | +| :--- | :---------- | +| kind | Match to compare | + +## Return +Returns a `T_NULL` token on mismatch. diff --git a/docs/debug-Lexer-getNextUnless.md b/docs/debug-Lexer-getNextUnless.md new file mode 100644 index 0000000..76c20aa --- /dev/null +++ b/docs/debug-Lexer-getNextUnless.md @@ -0,0 +1,22 @@ +# [Debug](debug.md) / [Lexer](debug-Lexer.md) :: getNextUnless + > im\debug\Lexer +____ + +## Description +Only advance the pointer and return the next token if it does not match. + +This is the same as calling `getNext`, only it will only advance and +return the token if it's a mismatch with $kind. + +## Synopsis +```php +public getNextUnless(array|string|int $kind): PhpToken +``` + +## Parameters +| Name | Description | +| :--- | :---------- | +| kind | Match to compare | + +## Return +Returns a `T_NULL` token on match. diff --git a/docs/debug-Lexer-getOffset.md b/docs/debug-Lexer-getOffset.md new file mode 100644 index 0000000..63a61a0 --- /dev/null +++ b/docs/debug-Lexer-getOffset.md @@ -0,0 +1,11 @@ +# [Debug](debug.md) / [Lexer](debug-Lexer.md) :: getOffset + > im\debug\Lexer +____ + +## Description +Get the current pointer offset + +## Synopsis +```php +public getOffset(): int +``` diff --git a/docs/debug-Lexer-getPrevious.md b/docs/debug-Lexer-getPrevious.md new file mode 100644 index 0000000000000000000000000000000000000000..7eb61fbc55ac3e79aa65ac9ca32a6116db444ceb GIT binary patch literal 644 zcmZ8e(Q4c<5bU$QV&DQv;Ld$NXrVO8OONzuuk;})kbaiYAB^kV&(6h6WZkEQUjfYcKo zrB*B4P^zO1*?OnGQI2FXaz_Z>x=azqHHehQ=;rX!64^hKTf?55kJg=F`hNbHV^4E7 zRZ1owI-9^(x+XIaOhV0YsnUagp@aWRRHOBM?_a6G@eIupK94by%en#z-S21TL$XO} ztwR@77>~WJ--^95F`Dy~ve24X#N zEyG}P-3g-btxEkuZNkrv92#n^`-fPwt?ccqWr-!j_M)+EOJW1L4%$sQ>@~ literal 0 HcmV?d00001 diff --git a/docs/debug-Lexer-getPreviousIf.md b/docs/debug-Lexer-getPreviousIf.md new file mode 100644 index 0000000..e14b299 --- /dev/null +++ b/docs/debug-Lexer-getPreviousIf.md @@ -0,0 +1,23 @@ +# [Debug](debug.md) / [Lexer](debug-Lexer.md) :: getPreviousIf + > im\debug\Lexer +____ + +## Description +Only retreat the pointer and return the previous token if it matches. + +This is the same as calling `getPrevious`, only it will only retreat and +return the token if it matches $kind. This is equal to combining +`peakPrevious` with `getPrevious`. + +## Synopsis +```php +public getPreviousIf(array|string|int $kind): PhpToken +``` + +## Parameters +| Name | Description | +| :--- | :---------- | +| kind | Match to compare | + +## Return +Returns a `T_NULL` token on mismatch. diff --git a/docs/debug-Lexer-getPreviousUnless.md b/docs/debug-Lexer-getPreviousUnless.md new file mode 100644 index 0000000..1eb13b9 --- /dev/null +++ b/docs/debug-Lexer-getPreviousUnless.md @@ -0,0 +1,22 @@ +# [Debug](debug.md) / [Lexer](debug-Lexer.md) :: getPreviousUnless + > im\debug\Lexer +____ + +## Description +Only retreat the pointer and return the previous token if it does not match. + +This is the same as calling `getPrevious`, only it will only retreat and +return the token if it's a mismatch with $kind. + +## Synopsis +```php +public getPreviousUnless(array|string|int $kind): PhpToken +``` + +## Parameters +| Name | Description | +| :--- | :---------- | +| kind | Match to compare | + +## Return +Returns a `T_NULL` token on match. diff --git a/docs/debug-Lexer-moveTo.md b/docs/debug-Lexer-moveTo.md new file mode 100644 index 0000000..8a4b359 --- /dev/null +++ b/docs/debug-Lexer-moveTo.md @@ -0,0 +1,23 @@ +# [Debug](debug.md) / [Lexer](debug-Lexer.md) :: moveTo + > im\debug\Lexer +____ + +## Description +To a raw move to a specific offset + +Unlike `moveToNext` and `moveToPrevious`, this method +does not take ignorable tokens into consideration. +It will simply move the pointer to the specified offset. + +This method works will when paired with `getOffset`. + +## Synopsis +```php +public moveTo(int $offset, int $whence = im\debug\Lexer::OFFSET_SET): bool +``` + +## Parameters +| Name | Description | +| :--- | :---------- | +| offset | The offset to move to | +| whence | How to apply the offset, based on the `OFFSET_` constants | diff --git a/docs/debug-Lexer-moveToNext.md b/docs/debug-Lexer-moveToNext.md new file mode 100644 index 0000000000000000000000000000000000000000..f094fecfdec5b10dbf19aabef0486c773d2a7df0 GIT binary patch literal 628 zcmZ8eTT8<*6!tm4;)4k)Z1a8SK+u6Wr+C2!6`QtaYgl_ylGF?I$9s}a5%Y4AbNMbg zBRro|-fdnF%NV9jd4yv;FX@xqE;mV!RGH1t*mrucEBXuybC~8O&Ap@^^(IHD(Fo_{ z3uoG3EURmoKx+*LatIcoBCyQMeM>xs*|2qnH_&xGJak^uQ1#OUcmKt<^~S3#%i5|{ zZI{=k_@m`eJEy;TA0kjMR6Tcsw!bx8;uNdL<#LSwJ=pibwr4>a4)zX?X2`9rBSqr8 z)lN4gn!W0=k}LYZw$Mv@HknK$9mDRVbYkssMbt)((ObvCh`Rtsx~RxQ4+hcbP*kxa zX`P&X)HV*)SA3N98n$*?H{o zR1u@3wc%g72rDEBFI5BzrCG1Z5eLN4VRLX=)+Xz#G)HL>I_~+7go)J<{I3Sf$fPTS Sb;us>9z~X1DA%W4H8Z?;LH7?YzPXO!Jy%UsIoYm!s5V zf^+hPGi@-I)wN8awT1&Z1dC8fI$}uvK|F=ouyuwv&~-f|Ian#t115XVAluRo(5^y+u1uP|4JKd0I_o~N@T+#ovhhEBy*=#1|7{-&ziM7WSQ5$tee;o%S4g(zNq9PAHm_(yP zQN@m=b$*mP9G+aRadx|e@nd^A9e!{8%ugfU*aqlwtGOU(ahWYoR}UB2FcdmRqNtjp-!T)No Wj7$tfkAm(;@Jy$1l4RKYa0<_$47|40Osg& ztBhBg#5?-d68H*%mE%9O1BC0?Y>s|P2N~qD=(e%p-jhRJ8HSs@TjPO2UvbC7E}0-fuZx-Jb4C; z?naXttSYk(dP9@gbtSEAkTp8d!IGcQ{hby%PS27g;dHqA6VtJC2d{_*8hr}Wwd57g z=fR@PD|8@xdm8EUDj=fXH1d0C9eh=6V1cEg8)C}#DaWqzi17!xRH4ceEs}>og=j8V m$(yhYmjusmFQIhU*mX<&vVx9my$c>?y&z3cN>#TOQ}GLmYrgCN literal 0 HcmV?d00001 diff --git a/docs/debug-Lexer-peakPrevious.md b/docs/debug-Lexer-peakPrevious.md new file mode 100644 index 0000000000000000000000000000000000000000..9226757a72b246a20bb490520fc41fef6cf007a9 GIT binary patch literal 576 zcmZ8eO-lnY5cQm2G0;LSbk}=9L8x9VwP?jdE8TQ=wmWn;3HhiN^5adii>SFIGkI_3 z&6^Qy7kF^TkLxO4c~?#02DVH5LOtZN6r`W|92D}?TH~3dGYsy4x?N)K5{m7^VQe&l z1)5TmvLpq2LF=>t+aRcc3Ra#_z$e*8Itv=DMs7(Qdz2($QO|&mLh6|1ZQBR@&|*(E zd1~}}5mFg4tSAcAD5l(@rSgx?YpylFcw=KJA4+@SLcQ^cLnWon#2!c7AzzatPLZk9}J}`s%z9JEJP}( pXfS9VR-yx(3wU^bjHTo1`gILki#m$UK6+FPf~0_&Q|mP5>>IS`#IOJW literal 0 HcmV?d00001 diff --git a/docs/debug-Lexer-prop_OFFSET_CUR.md b/docs/debug-Lexer-prop_OFFSET_CUR.md new file mode 100644 index 0000000..85da160 --- /dev/null +++ b/docs/debug-Lexer-prop_OFFSET_CUR.md @@ -0,0 +1,11 @@ +# [Debug](debug.md) / [Lexer](debug-Lexer.md) :: OFFSET_CUR + > im\debug\Lexer +____ + +## Description +Set position to current location plus offset + +## Synopsis +```php +public OFFSET_CUR = 2 +``` diff --git a/docs/debug-Lexer-prop_OFFSET_END.md b/docs/debug-Lexer-prop_OFFSET_END.md new file mode 100644 index 0000000..b9fb102 --- /dev/null +++ b/docs/debug-Lexer-prop_OFFSET_END.md @@ -0,0 +1,11 @@ +# [Debug](debug.md) / [Lexer](debug-Lexer.md) :: OFFSET_END + > im\debug\Lexer +____ + +## Description +Set position to end-of-file plus offset + +## Synopsis +```php +public OFFSET_END = 3 +``` diff --git a/docs/debug-Lexer-prop_OFFSET_SET.md b/docs/debug-Lexer-prop_OFFSET_SET.md new file mode 100644 index 0000000..d7326ca --- /dev/null +++ b/docs/debug-Lexer-prop_OFFSET_SET.md @@ -0,0 +1,11 @@ +# [Debug](debug.md) / [Lexer](debug-Lexer.md) :: OFFSET_SET + > im\debug\Lexer +____ + +## Description +Set position equal to offset bytes + +## Synopsis +```php +public OFFSET_SET = 1 +``` diff --git a/docs/debug-Lexer.md b/docs/debug-Lexer.md new file mode 100644 index 0000000000000000000000000000000000000000..cc200a071101b5e3273f6282385a88cdfd36afb0 GIT binary patch literal 6221 zcmcIoU2hsk6zwy=;!25%Eya%7zErMKX=CFQ34;skL{VI=huvA&dfC~|EXJtxzxUjk zU05&>+i`d>cs|ZO_jB&dEBbOKhtttt2N8cAPohJ5OC5PHb%TDVWO8lCuiZ$1Poweb z6`e^F>Lf1`l{Gv{c{vTINm`J~=<<)trlCUJ%8bn16mrsNvQd7H@c1W5Up#)N@LcB9&l}nFRc^aE>j! z#DI~dc-&~T?!_ceSyGIxcsqNOiHS712<7#~ z{4^ED+&CnWMKo7aEKgG!$pWZNKj?ZFt>DiquhTwnx6Yc7Z^d@ij6@XinkmRVz-+Ri zSmi?H#K_@TWF!2Gp&C~QhNaDtOY@l8FwZoNNZ#i%EUf*CagvQ-9H?4SYLe1ql1Y*Z z{RSaWz)-N5h#cZft~40<{dV^Q16SV66dAZ1b_1~tnqYY*WyG9g1QT4RfGDj?3`D2W z!9sY6=9XeRD`a3%{J_G>JfEEW<>XL~#a*JNx^f2Ano=QCh$0D_bZ4k(WE#W9bU=>S)=r04-^s9kWtZ5!@ps6 zM@MKa=1nBbo%5Vkbg2uJ^~Z=@mxgh2Uq(Aq1uX2FWUEk4FzX14)F`@@GH0iTYLY|$ zVS><~H-@s9Nu=+c(6E-xD^3i9Fh-);3|27`gNDe#TeH3!d^}F`${~sK3RZEHS7zYc z&yvtNKTM@Sf}j+rxB)xmVgxdvRgAToj>a}ZI9qval}A-7q9P6EnaYu^jhmaBe4IC& zEL*lv#gL~HnH2`HC$%V)_C_d1kRjiYuVGeg#1KCF*SX{ETRMfNg}@f;zr-DfQFqc;2V7-et2j0iMbG{-8>7HU0IwJOlarOU zKxGOK;kqc#2R1qvj`0GJi)@N$e+^$nKEe1{Dcm@{XE6G#InI3!sJfO|@p3Be5zvkwXy^>MpVw8EO7qY-d$;CD*zc~>%ld7H z;VL1|FkZFwxdyEEKk(YKVtfC6ykkyF}*{s z%%UR|AE7Zp&$%X&JL0OIzl=++gX`5{ut~RePLxznT_=nKRnA=VZrd=yb)AA>fP*6l zhieHp zw%rQr4O)*ywQL{4e)Rfn?|lazYd?-1Gpc{Kvt5H--tL4RO>K|)^+>a@Uf;VYWw`*e zH@tqUgFD2>R-MITe=}@pNxP*6ySz9)7OS>y59~R5yU(jzX>HTje{P5ME)W_64>kI{ z*Xi^=wa$X~p95Gt==J%_>wlmFemwYf&k<8=h&O9zZK|xDdvILKyb0k(%iX@hHAagW z@hG2yf()+9NsQYW2JX=!Q@BX+%R(~B zl(ttC_x`{w0ggg`poq$9{Z&O+@^)o-rc~&H^~e?A-6IQM<1$P`H}uB1GB6Q$Or#H4 z?LK~;@|CXJX;ia&sO05^;9KdeTK`QdtC^C<2Xs4Zg{tqchM=KjBRE6Z2aDaR196+_ z%i&Ur7v0(8nk7}{=jVm$k>-WmPzr6wThwNf?YQLA!m!eHJ)p$vyU%u|GIm5n3@H>^W7KcU6iO im\debug\entities\Argument +____ + +## Description +Construct a new Argument + +## Synopsis +```php +public __construct(string $name, im\debug\entities\Type $type, int $flags = 0) +``` + +## Parameters +| Name | Description | +| :--- | :---------- | +| name | Name of the argument | +| type | The argument type | +| flags | Argument flags | diff --git a/docs/entities-Argument-getName.md b/docs/entities-Argument-getName.md new file mode 100644 index 0000000..398006e --- /dev/null +++ b/docs/entities-Argument-getName.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Argument](entities-Argument.md) :: getName + > im\debug\entities\Argument +____ + +## Description +Get the argument name + +## Synopsis +```php +public getName(): string +``` diff --git a/docs/entities-Argument-getType.md b/docs/entities-Argument-getType.md new file mode 100644 index 0000000..7446a9c --- /dev/null +++ b/docs/entities-Argument-getType.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Argument](entities-Argument.md) :: getType + > im\debug\entities\Argument +____ + +## Description +Get the argument type + +## Synopsis +```php +public getType(): im\debug\entities\Type +``` diff --git a/docs/entities-Argument-isByRef.md b/docs/entities-Argument-isByRef.md new file mode 100644 index 0000000..5d43243 --- /dev/null +++ b/docs/entities-Argument-isByRef.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Argument](entities-Argument.md) :: isByRef + > im\debug\entities\Argument +____ + +## Description +Whether this argument is passed by reference + +## Synopsis +```php +public isByRef(): bool +``` diff --git a/docs/entities-Argument-isNullable.md b/docs/entities-Argument-isNullable.md new file mode 100644 index 0000000..e40805e --- /dev/null +++ b/docs/entities-Argument-isNullable.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Argument](entities-Argument.md) :: isNullable + > im\debug\entities\Argument +____ + +## Description +Whether this is a nullable argument + +## Synopsis +```php +public isNullable(): bool +``` diff --git a/docs/entities-Argument-isOptional.md b/docs/entities-Argument-isOptional.md new file mode 100644 index 0000000..e9f9419 --- /dev/null +++ b/docs/entities-Argument-isOptional.md @@ -0,0 +1,13 @@ +# [Entities](entities.md) / [Argument](entities-Argument.md) :: isOptional + > im\debug\entities\Argument +____ + +## Description +Whether this is an optional argument + +An optional argument is one that provides a default value + +## Synopsis +```php +public isOptional(): bool +``` diff --git a/docs/entities-Argument-isVariadic.md b/docs/entities-Argument-isVariadic.md new file mode 100644 index 0000000..9224998 --- /dev/null +++ b/docs/entities-Argument-isVariadic.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Argument](entities-Argument.md) :: isVariadic + > im\debug\entities\Argument +____ + +## Description +Whether this is a variable length argument + +## Synopsis +```php +public isVariadic(): bool +``` diff --git a/docs/entities-Argument-prop_T_BYREF.md b/docs/entities-Argument-prop_T_BYREF.md new file mode 100644 index 0000000..6b4dca5 --- /dev/null +++ b/docs/entities-Argument-prop_T_BYREF.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Argument](entities-Argument.md) :: T_BYREF + > im\debug\entities\Argument +____ + +## Description +This is a byref argument + +## Synopsis +```php +public T_BYREF = 32 +``` diff --git a/docs/entities-Argument-prop_T_OPTIONAL.md b/docs/entities-Argument-prop_T_OPTIONAL.md new file mode 100644 index 0000000..4992bb7 --- /dev/null +++ b/docs/entities-Argument-prop_T_OPTIONAL.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Argument](entities-Argument.md) :: T_OPTIONAL + > im\debug\entities\Argument +____ + +## Description +This is an optional (has a default value) argument + +## Synopsis +```php +public T_OPTIONAL = 128 +``` diff --git a/docs/entities-Argument-prop_T_VARIADIC.md b/docs/entities-Argument-prop_T_VARIADIC.md new file mode 100644 index 0000000..84a561a --- /dev/null +++ b/docs/entities-Argument-prop_T_VARIADIC.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Argument](entities-Argument.md) :: T_VARIADIC + > im\debug\entities\Argument +____ + +## Description +This is a variable length argument + +## Synopsis +```php +public T_VARIADIC = 64 +``` diff --git a/docs/entities-Argument.md b/docs/entities-Argument.md new file mode 100644 index 0000000..488b3be --- /dev/null +++ b/docs/entities-Argument.md @@ -0,0 +1,44 @@ +# [Debug](debug.md) / [Entities](entities.md) / Argument + > im\debug\entities\Argument +____ + +## Description +Defines a function argument + +## Synopsis +```php +class Argument implements Stringable { + + // Constants + public T_BYREF = 32 + public T_VARIADIC = 64 + public T_OPTIONAL = 128 + + // Methods + public __construct(string $name, im\debug\entities\Type $type, int $flags = 0) + public getName(): string + public getType(): im\debug\entities\Type + public isNullable(): bool + public isOptional(): bool + public isByRef(): bool + public isVariadic(): bool +} +``` + +## Constants +| Name | Description | +| :--- | :---------- | +| [__Argument :: T\_BYREF__](entities-Argument-prop_T_BYREF.md) | This is a byref argument | +| [__Argument :: T\_VARIADIC__](entities-Argument-prop_T_VARIADIC.md) | This is a variable length argument | +| [__Argument :: T\_OPTIONAL__](entities-Argument-prop_T_OPTIONAL.md) | This is an optional (has a default value) argument | + +## Methods +| Name | Description | +| :--- | :---------- | +| [__Argument :: \_\_construct__](entities-Argument-__construct.md) | Construct a new Argument | +| [__Argument :: getName__](entities-Argument-getName.md) | Get the argument name | +| [__Argument :: getType__](entities-Argument-getType.md) | Get the argument type | +| [__Argument :: isNullable__](entities-Argument-isNullable.md) | Whether this is a nullable argument | +| [__Argument :: isOptional__](entities-Argument-isOptional.md) | Whether this is an optional argument | +| [__Argument :: isByRef__](entities-Argument-isByRef.md) | Whether this argument is passed by reference | +| [__Argument :: isVariadic__](entities-Argument-isVariadic.md) | Whether this is a variable length argument | diff --git a/docs/entities-Clazz-__construct.md b/docs/entities-Clazz-__construct.md new file mode 100644 index 0000000..67e74f3 --- /dev/null +++ b/docs/entities-Clazz-__construct.md @@ -0,0 +1,19 @@ +# [Entities](entities.md) / [Clazz](entities-Clazz.md) :: __construct + > im\debug\entities\Clazz +____ + +## Description +Construct a new Class + +## Synopsis +```php +public __construct(im\debug\entities\Name $name, int $flags = im\debug\entities\Clazz::T_CLASS, null|im\debug\entities\Name $extends = NULL, array $implements = Array) +``` + +## Parameters +| Name | Description | +| :--- | :---------- | +| name | The name of the clas | +| flags | Class flags | +| extends | A parent class name | +| implements | An array of interface names being used by this class | diff --git a/docs/entities-Clazz-addMethod.md b/docs/entities-Clazz-addMethod.md new file mode 100644 index 0000000..0124dc9 --- /dev/null +++ b/docs/entities-Clazz-addMethod.md @@ -0,0 +1,18 @@ +# [Entities](entities.md) / [Clazz](entities-Clazz.md) :: addMethod + > im\debug\entities\Clazz +____ + +## Description +Add a method to this class + + > Trying to add an already existing method will result in an exception + +## Synopsis +```php +public addMethod(im\debug\entities\Routine $func): void +``` + +## Parameters +| Name | Description | +| :--- | :---------- | +| func | A method to add | diff --git a/docs/entities-Clazz-addProperty.md b/docs/entities-Clazz-addProperty.md new file mode 100644 index 0000000..478c5e4 --- /dev/null +++ b/docs/entities-Clazz-addProperty.md @@ -0,0 +1,18 @@ +# [Entities](entities.md) / [Clazz](entities-Clazz.md) :: addProperty + > im\debug\entities\Clazz +____ + +## Description +Add a property to this class + + > Trying to add an already existing property will result in an exception + +## Synopsis +```php +public addProperty(im\debug\entities\Property $prop): void +``` + +## Parameters +| Name | Description | +| :--- | :---------- | +| prop | A property to add | diff --git a/docs/entities-Clazz-addTrait.md b/docs/entities-Clazz-addTrait.md new file mode 100644 index 0000000..064d72e --- /dev/null +++ b/docs/entities-Clazz-addTrait.md @@ -0,0 +1,18 @@ +# [Entities](entities.md) / [Clazz](entities-Clazz.md) :: addTrait + > im\debug\entities\Clazz +____ + +## Description +Add a trait name to this class + + > Trying to add an already existing trait will result in an exception + +## Synopsis +```php +public addTrait(im\debug\entities\Name $name): void +``` + +## Parameters +| Name | Description | +| :--- | :---------- | +| name | A trait name to add | diff --git a/docs/entities-Clazz-getExtends.md b/docs/entities-Clazz-getExtends.md new file mode 100644 index 0000000..87a22ff --- /dev/null +++ b/docs/entities-Clazz-getExtends.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Clazz](entities-Clazz.md) :: getExtends + > im\debug\entities\Clazz +____ + +## Description +Get the parent class name + +## Synopsis +```php +public getExtends(): null|im\debug\entities\Name +``` diff --git a/docs/entities-Clazz-getImplement.md b/docs/entities-Clazz-getImplement.md new file mode 100644 index 0000000..7f9c6fb --- /dev/null +++ b/docs/entities-Clazz-getImplement.md @@ -0,0 +1,16 @@ +# [Entities](entities.md) / [Clazz](entities-Clazz.md) :: getImplement + > im\debug\entities\Clazz +____ + +## Description +Get a specified interface name + +## Synopsis +```php +public getImplement(string $label): null|im\debug\entities\Name +``` + +## Parameters +| Name | Description | +| :--- | :---------- | +| label | Name of the interface to return | diff --git a/docs/entities-Clazz-getImplements.md b/docs/entities-Clazz-getImplements.md new file mode 100644 index 0000000..cc33fbb --- /dev/null +++ b/docs/entities-Clazz-getImplements.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Clazz](entities-Clazz.md) :: getImplements + > im\debug\entities\Clazz +____ + +## Description +Return all interface names used by this class + +## Synopsis +```php +public getImplements(): array +``` diff --git a/docs/entities-Clazz-getIterator.md b/docs/entities-Clazz-getIterator.md new file mode 100644 index 0000000..9958e1c --- /dev/null +++ b/docs/entities-Clazz-getIterator.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Clazz](entities-Clazz.md) :: getIterator + > im\debug\entities\Clazz +____ + +## Description +Provides a Traversable to iterate through all members + +## Synopsis +```php +public getIterator(): Traversable +``` diff --git a/docs/entities-Clazz-getMethod.md b/docs/entities-Clazz-getMethod.md new file mode 100644 index 0000000..51ced02 --- /dev/null +++ b/docs/entities-Clazz-getMethod.md @@ -0,0 +1,16 @@ +# [Entities](entities.md) / [Clazz](entities-Clazz.md) :: getMethod + > im\debug\entities\Clazz +____ + +## Description +Get a specified method + +## Synopsis +```php +public getMethod(string $name): null|im\debug\entities\Routine +``` + +## Parameters +| Name | Description | +| :--- | :---------- | +| name | Name of the method to return | diff --git a/docs/entities-Clazz-getMethods.md b/docs/entities-Clazz-getMethods.md new file mode 100644 index 0000000..c65619e --- /dev/null +++ b/docs/entities-Clazz-getMethods.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Clazz](entities-Clazz.md) :: getMethods + > im\debug\entities\Clazz +____ + +## Description +Return all methods within by this class + +## Synopsis +```php +public getMethods(): array +``` diff --git a/docs/entities-Clazz-getName.md b/docs/entities-Clazz-getName.md new file mode 100644 index 0000000..6bbe3e3 --- /dev/null +++ b/docs/entities-Clazz-getName.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Clazz](entities-Clazz.md) :: getName + > im\debug\entities\Clazz +____ + +## Description +Get the class name + +## Synopsis +```php +public getName(): im\debug\entities\Name +``` diff --git a/docs/entities-Clazz-getProperties.md b/docs/entities-Clazz-getProperties.md new file mode 100644 index 0000000..bed357e --- /dev/null +++ b/docs/entities-Clazz-getProperties.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Clazz](entities-Clazz.md) :: getProperties + > im\debug\entities\Clazz +____ + +## Description +Return all properties within by this class + +## Synopsis +```php +public getProperties(): array +``` diff --git a/docs/entities-Clazz-getProperty.md b/docs/entities-Clazz-getProperty.md new file mode 100644 index 0000000..077866a --- /dev/null +++ b/docs/entities-Clazz-getProperty.md @@ -0,0 +1,16 @@ +# [Entities](entities.md) / [Clazz](entities-Clazz.md) :: getProperty + > im\debug\entities\Clazz +____ + +## Description +Get a specified property + +## Synopsis +```php +public getProperty(string $name): null|im\debug\entities\Property +``` + +## Parameters +| Name | Description | +| :--- | :---------- | +| name | Name of the property to return | diff --git a/docs/entities-Clazz-getTrait.md b/docs/entities-Clazz-getTrait.md new file mode 100644 index 0000000..ee8af8a --- /dev/null +++ b/docs/entities-Clazz-getTrait.md @@ -0,0 +1,16 @@ +# [Entities](entities.md) / [Clazz](entities-Clazz.md) :: getTrait + > im\debug\entities\Clazz +____ + +## Description +Get a specified trait name + +## Synopsis +```php +public getTrait(string $label): null|im\debug\entities\Name +``` + +## Parameters +| Name | Description | +| :--- | :---------- | +| label | Name of the trait to return | diff --git a/docs/entities-Clazz-getTraits.md b/docs/entities-Clazz-getTraits.md new file mode 100644 index 0000000..50c2999 --- /dev/null +++ b/docs/entities-Clazz-getTraits.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Clazz](entities-Clazz.md) :: getTraits + > im\debug\entities\Clazz +____ + +## Description +Return all trait names used by this class + +## Synopsis +```php +public getTraits(): array +``` diff --git a/docs/entities-Clazz-isAbstract.md b/docs/entities-Clazz-isAbstract.md new file mode 100644 index 0000000..cf84e24 --- /dev/null +++ b/docs/entities-Clazz-isAbstract.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Clazz](entities-Clazz.md) :: isAbstract + > im\debug\entities\Clazz +____ + +## Description +Whether this class is abstract + +## Synopsis +```php +public isAbstract(): bool +``` diff --git a/docs/entities-Clazz-isAnonymous.md b/docs/entities-Clazz-isAnonymous.md new file mode 100644 index 0000000..0c0547b --- /dev/null +++ b/docs/entities-Clazz-isAnonymous.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Clazz](entities-Clazz.md) :: isAnonymous + > im\debug\entities\Clazz +____ + +## Description +Whether this class is anonymous + +## Synopsis +```php +public isAnonymous(): bool +``` diff --git a/docs/entities-Clazz-isEnum.md b/docs/entities-Clazz-isEnum.md new file mode 100644 index 0000000..09da2a9 --- /dev/null +++ b/docs/entities-Clazz-isEnum.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Clazz](entities-Clazz.md) :: isEnum + > im\debug\entities\Clazz +____ + +## Description +Whether this class is an enum class + +## Synopsis +```php +public isEnum(): bool +``` diff --git a/docs/entities-Clazz-isFinal.md b/docs/entities-Clazz-isFinal.md new file mode 100644 index 0000000..56ea7b2 --- /dev/null +++ b/docs/entities-Clazz-isFinal.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Clazz](entities-Clazz.md) :: isFinal + > im\debug\entities\Clazz +____ + +## Description +Whether this class is final + +## Synopsis +```php +public isFinal(): bool +``` diff --git a/docs/entities-Clazz-isInterface.md b/docs/entities-Clazz-isInterface.md new file mode 100644 index 0000000..4b4a16f --- /dev/null +++ b/docs/entities-Clazz-isInterface.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Clazz](entities-Clazz.md) :: isInterface + > im\debug\entities\Clazz +____ + +## Description +Whether this class is an interface + +## Synopsis +```php +public isInterface(): bool +``` diff --git a/docs/entities-Clazz-isTrait.md b/docs/entities-Clazz-isTrait.md new file mode 100644 index 0000000..7a39c63 --- /dev/null +++ b/docs/entities-Clazz-isTrait.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Clazz](entities-Clazz.md) :: isTrait + > im\debug\entities\Clazz +____ + +## Description +Whether this class is a trait class + +## Synopsis +```php +public isTrait(): bool +``` diff --git a/docs/entities-Clazz-prop_T_ABSTRACT.md b/docs/entities-Clazz-prop_T_ABSTRACT.md new file mode 100644 index 0000000..8eb487d --- /dev/null +++ b/docs/entities-Clazz-prop_T_ABSTRACT.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Clazz](entities-Clazz.md) :: T_ABSTRACT + > im\debug\entities\Clazz +____ + +## Description +This class is Abstract + +## Synopsis +```php +public T_ABSTRACT = 512 +``` diff --git a/docs/entities-Clazz-prop_T_ANONYMOUS.md b/docs/entities-Clazz-prop_T_ANONYMOUS.md new file mode 100644 index 0000000..e0feda3 --- /dev/null +++ b/docs/entities-Clazz-prop_T_ANONYMOUS.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Clazz](entities-Clazz.md) :: T_ANONYMOUS + > im\debug\entities\Clazz +____ + +## Description +This class is Anonymous + +## Synopsis +```php +public T_ANONYMOUS = 4096 +``` diff --git a/docs/entities-Clazz-prop_T_CLASS.md b/docs/entities-Clazz-prop_T_CLASS.md new file mode 100644 index 0000000..ee0ac69 --- /dev/null +++ b/docs/entities-Clazz-prop_T_CLASS.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Clazz](entities-Clazz.md) :: T_CLASS + > im\debug\entities\Clazz +____ + +## Description +This is a Class + +## Synopsis +```php +public T_CLASS = 1 +``` diff --git a/docs/entities-Clazz-prop_T_ENUM.md b/docs/entities-Clazz-prop_T_ENUM.md new file mode 100644 index 0000000..9f20568 --- /dev/null +++ b/docs/entities-Clazz-prop_T_ENUM.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Clazz](entities-Clazz.md) :: T_ENUM + > im\debug\entities\Clazz +____ + +## Description +This is an Enum class + +## Synopsis +```php +public T_ENUM = 9 +``` diff --git a/docs/entities-Clazz-prop_T_FINAL.md b/docs/entities-Clazz-prop_T_FINAL.md new file mode 100644 index 0000000..c91ee82 --- /dev/null +++ b/docs/entities-Clazz-prop_T_FINAL.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Clazz](entities-Clazz.md) :: T_FINAL + > im\debug\entities\Clazz +____ + +## Description +This class is Final + +## Synopsis +```php +public T_FINAL = 256 +``` diff --git a/docs/entities-Clazz-prop_T_INTERFACE.md b/docs/entities-Clazz-prop_T_INTERFACE.md new file mode 100644 index 0000000..8bd4e01 --- /dev/null +++ b/docs/entities-Clazz-prop_T_INTERFACE.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Clazz](entities-Clazz.md) :: T_INTERFACE + > im\debug\entities\Clazz +____ + +## Description +This is an Interface + +## Synopsis +```php +public T_INTERFACE = 5 +``` diff --git a/docs/entities-Clazz-prop_T_TRAIT.md b/docs/entities-Clazz-prop_T_TRAIT.md new file mode 100644 index 0000000..23a419a --- /dev/null +++ b/docs/entities-Clazz-prop_T_TRAIT.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Clazz](entities-Clazz.md) :: T_TRAIT + > im\debug\entities\Clazz +____ + +## Description +This is a Trait class + +## Synopsis +```php +public T_TRAIT = 3 +``` diff --git a/docs/entities-Clazz-var_line.md b/docs/entities-Clazz-var_line.md new file mode 100644 index 0000000..4f338c3 --- /dev/null +++ b/docs/entities-Clazz-var_line.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Clazz](entities-Clazz.md) :: $line + > im\debug\entities\Clazz +____ + +## Description +The line number of where this entity begins + +## Synopsis +```php +public int $line = -1 +``` diff --git a/docs/entities-Clazz-var_pos.md b/docs/entities-Clazz-var_pos.md new file mode 100644 index 0000000..635a32e --- /dev/null +++ b/docs/entities-Clazz-var_pos.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Clazz](entities-Clazz.md) :: $pos + > im\debug\entities\Clazz +____ + +## Description +The position of where this entity begins + +## Synopsis +```php +public int $pos = -1 +``` diff --git a/docs/entities-Clazz.md b/docs/entities-Clazz.md new file mode 100644 index 0000000..0226075 --- /dev/null +++ b/docs/entities-Clazz.md @@ -0,0 +1,90 @@ +# [Debug](debug.md) / [Entities](entities.md) / Clazz + > im\debug\entities\Clazz +____ + +## Description +Defines a Class _(class, interface, trait or interface)_ + +## Synopsis +```php +class Clazz extends im\debug\entities\Entity implements Stringable, IteratorAggregate, Traversable { + + // Constants + public T_CLASS = 1 + public T_INTERFACE = 5 + public T_TRAIT = 3 + public T_ENUM = 9 + public T_FINAL = 256 + public T_ABSTRACT = 512 + public T_ANONYMOUS = 4096 + + // Inherited Properties + public int $line = -1 + public int $pos = -1 + + // Methods + public __construct(im\debug\entities\Name $name, int $flags = im\debug\entities\Clazz::T_CLASS, null|im\debug\entities\Name $extends = NULL, array $implements = Array) + public isAnonymous(): bool + public isFinal(): bool + public isAbstract(): bool + public isTrait(): bool + public isInterface(): bool + public isEnum(): bool + public getName(): im\debug\entities\Name + public getExtends(): null|im\debug\entities\Name + public getImplement(string $label): null|im\debug\entities\Name + public getImplements(): array + public addTrait(im\debug\entities\Name $name): void + public getTrait(string $label): null|im\debug\entities\Name + public getTraits(): array + public addProperty(im\debug\entities\Property $prop): void + public getProperty(string $name): null|im\debug\entities\Property + public getProperties(): array + public addMethod(im\debug\entities\Routine $func): void + public getMethod(string $name): null|im\debug\entities\Routine + public getMethods(): array + public getIterator(): Traversable +} +``` + +## Constants +| Name | Description | +| :--- | :---------- | +| [__Clazz :: T\_CLASS__](entities-Clazz-prop_T_CLASS.md) | This is a Class | +| [__Clazz :: T\_INTERFACE__](entities-Clazz-prop_T_INTERFACE.md) | This is an Interface | +| [__Clazz :: T\_TRAIT__](entities-Clazz-prop_T_TRAIT.md) | This is a Trait class | +| [__Clazz :: T\_ENUM__](entities-Clazz-prop_T_ENUM.md) | This is an Enum class | +| [__Clazz :: T\_FINAL__](entities-Clazz-prop_T_FINAL.md) | This class is Final | +| [__Clazz :: T\_ABSTRACT__](entities-Clazz-prop_T_ABSTRACT.md) | This class is Abstract | +| [__Clazz :: T\_ANONYMOUS__](entities-Clazz-prop_T_ANONYMOUS.md) | This class is Anonymous | + +## Properties +| Name | Description | +| :--- | :---------- | +| [__Clazz :: $line__](entities-Clazz-var_line.md) | The line number of where this entity begins | +| [__Clazz :: $pos__](entities-Clazz-var_pos.md) | The position of where this entity begins | + +## Methods +| Name | Description | +| :--- | :---------- | +| [__Clazz :: \_\_construct__](entities-Clazz-__construct.md) | Construct a new Class | +| [__Clazz :: isAnonymous__](entities-Clazz-isAnonymous.md) | Whether this class is anonymous | +| [__Clazz :: isFinal__](entities-Clazz-isFinal.md) | Whether this class is final | +| [__Clazz :: isAbstract__](entities-Clazz-isAbstract.md) | Whether this class is abstract | +| [__Clazz :: isTrait__](entities-Clazz-isTrait.md) | Whether this class is a trait class | +| [__Clazz :: isInterface__](entities-Clazz-isInterface.md) | Whether this class is an interface | +| [__Clazz :: isEnum__](entities-Clazz-isEnum.md) | Whether this class is an enum class | +| [__Clazz :: getName__](entities-Clazz-getName.md) | Get the class name | +| [__Clazz :: getExtends__](entities-Clazz-getExtends.md) | Get the parent class name | +| [__Clazz :: getImplement__](entities-Clazz-getImplement.md) | Get a specified interface name | +| [__Clazz :: getImplements__](entities-Clazz-getImplements.md) | Return all interface names used by this class | +| [__Clazz :: addTrait__](entities-Clazz-addTrait.md) | Add a trait name to this class | +| [__Clazz :: getTrait__](entities-Clazz-getTrait.md) | Get a specified trait name | +| [__Clazz :: getTraits__](entities-Clazz-getTraits.md) | Return all trait names used by this class | +| [__Clazz :: addProperty__](entities-Clazz-addProperty.md) | Add a property to this class | +| [__Clazz :: getProperty__](entities-Clazz-getProperty.md) | Get a specified property | +| [__Clazz :: getProperties__](entities-Clazz-getProperties.md) | Return all properties within by this class | +| [__Clazz :: addMethod__](entities-Clazz-addMethod.md) | Add a method to this class | +| [__Clazz :: getMethod__](entities-Clazz-getMethod.md) | Get a specified method | +| [__Clazz :: getMethods__](entities-Clazz-getMethods.md) | Return all methods within by this class | +| [__Clazz :: getIterator__](entities-Clazz-getIterator.md) | Provides a Traversable to iterate through all members | diff --git a/docs/entities-Document-getClass.md b/docs/entities-Document-getClass.md new file mode 100644 index 0000000..94a6c44 --- /dev/null +++ b/docs/entities-Document-getClass.md @@ -0,0 +1,16 @@ +# [Entities](entities.md) / [Document](entities-Document.md) :: getClass + > im\debug\entities\Document +____ + +## Description +Find and return a specific class + +## Synopsis +```php +getClass(string $label): null|im\debug\entities\Clazz +``` + +## Parameters +| Name | Description | +| :--- | :---------- | +| label | Name of the class to find | diff --git a/docs/entities-Document-getClasses.md b/docs/entities-Document-getClasses.md new file mode 100644 index 0000000..11eb49c --- /dev/null +++ b/docs/entities-Document-getClasses.md @@ -0,0 +1,13 @@ +# [Entities](entities.md) / [Document](entities-Document.md) :: getClasses + > im\debug\entities\Document +____ + +## Description +Returns all classes in this document + + > This includes all anonymous classes within this scope + +## Synopsis +```php +getClasses(): array +``` diff --git a/docs/entities-Document-getConstant.md b/docs/entities-Document-getConstant.md new file mode 100644 index 0000000..a3ffc68 --- /dev/null +++ b/docs/entities-Document-getConstant.md @@ -0,0 +1,16 @@ +# [Entities](entities.md) / [Document](entities-Document.md) :: getConstant + > im\debug\entities\Document +____ + +## Description +Find and return a specific constant + +## Synopsis +```php +getConstant(string $label): null|im\debug\entities\Property +``` + +## Parameters +| Name | Description | +| :--- | :---------- | +| label | Name of the constant to find | diff --git a/docs/entities-Document-getConstants.md b/docs/entities-Document-getConstants.md new file mode 100644 index 0000000..8cfc832 --- /dev/null +++ b/docs/entities-Document-getConstants.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Document](entities-Document.md) :: getConstants + > im\debug\entities\Document +____ + +## Description +Returns all constants in this document + +## Synopsis +```php +getConstants(): array +``` diff --git a/docs/entities-Document-getFunction.md b/docs/entities-Document-getFunction.md new file mode 100644 index 0000000..08c4fd3 --- /dev/null +++ b/docs/entities-Document-getFunction.md @@ -0,0 +1,16 @@ +# [Entities](entities.md) / [Document](entities-Document.md) :: getFunction + > im\debug\entities\Document +____ + +## Description +Find and return a specific function + +## Synopsis +```php +getFunction(string $label): null|im\debug\entities\Routine +``` + +## Parameters +| Name | Description | +| :--- | :---------- | +| label | Name of the function to find | diff --git a/docs/entities-Document-getFunctions.md b/docs/entities-Document-getFunctions.md new file mode 100644 index 0000000..8c3ff28 --- /dev/null +++ b/docs/entities-Document-getFunctions.md @@ -0,0 +1,13 @@ +# [Entities](entities.md) / [Document](entities-Document.md) :: getFunctions + > im\debug\entities\Document +____ + +## Description +Returns all functions in this document + + > This includes all anonymous functions/closures within this scope + +## Synopsis +```php +getFunctions(): array +``` diff --git a/docs/entities-Document-getImport.md b/docs/entities-Document-getImport.md new file mode 100644 index 0000000..3caf456 --- /dev/null +++ b/docs/entities-Document-getImport.md @@ -0,0 +1,16 @@ +# [Entities](entities.md) / [Document](entities-Document.md) :: getImport + > im\debug\entities\Document +____ + +## Description +Find and return a specific import + +## Synopsis +```php +getImport(string $label): null|im\debug\entities\Import +``` + +## Parameters +| Name | Description | +| :--- | :---------- | +| label | Name of the import to find | diff --git a/docs/entities-Document-getImports.md b/docs/entities-Document-getImports.md new file mode 100644 index 0000000..62ef281 --- /dev/null +++ b/docs/entities-Document-getImports.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Document](entities-Document.md) :: getImports + > im\debug\entities\Document +____ + +## Description +Returns all imports in this document + +## Synopsis +```php +getImports(): array +``` diff --git a/docs/entities-Document-getNamespace.md b/docs/entities-Document-getNamespace.md new file mode 100644 index 0000000..3c6a4e6 --- /dev/null +++ b/docs/entities-Document-getNamespace.md @@ -0,0 +1,14 @@ +# [Entities](entities.md) / [Document](entities-Document.md) :: getNamespace + > im\debug\entities\Document +____ + +## Description +Returns the namespace of this document + +If this file has a namespace set, it will be returned. +Otherwise `NULL` is returned. + +## Synopsis +```php +getNamespace(): null|string +``` diff --git a/docs/entities-Document-hasOpenTag.md b/docs/entities-Document-hasOpenTag.md new file mode 100644 index 0000000..9faa13f --- /dev/null +++ b/docs/entities-Document-hasOpenTag.md @@ -0,0 +1,14 @@ +# [Entities](entities.md) / [Document](entities-Document.md) :: hasOpenTag + > im\debug\entities\Document +____ + +## Description +Whether or not this document has an PHP open tag + +This is a way to check if a file is actually +a PHP file. + +## Synopsis +```php +hasOpenTag(): bool +``` diff --git a/docs/entities-Document-isDeclaredEncoding.md b/docs/entities-Document-isDeclaredEncoding.md new file mode 100644 index 0000000..fc75dce --- /dev/null +++ b/docs/entities-Document-isDeclaredEncoding.md @@ -0,0 +1,14 @@ +# [Entities](entities.md) / [Document](entities-Document.md) :: isDeclaredEncoding + > im\debug\entities\Document +____ + +## Description +Returns the specified encoding, if any + +This will return the encoding defined in the beginning, +or `NULL` if this is not defined. + +## Synopsis +```php +isDeclaredEncoding(): null|string +``` diff --git a/docs/entities-Document-isStrict.md b/docs/entities-Document-isStrict.md new file mode 100644 index 0000000..cf42e5a --- /dev/null +++ b/docs/entities-Document-isStrict.md @@ -0,0 +1,14 @@ +# [Entities](entities.md) / [Document](entities-Document.md) :: isStrict + > im\debug\entities\Document +____ + +## Description +Whether or not this is a `strict_types` document + +This will return `TRUE` if it has `strict_types` set +in the beginning. + +## Synopsis +```php +isStrict(): bool +``` diff --git a/docs/entities-Document.md b/docs/entities-Document.md new file mode 100644 index 0000000..7637aaa --- /dev/null +++ b/docs/entities-Document.md @@ -0,0 +1,42 @@ +# [Debug](debug.md) / [Entities](entities.md) / Document + > im\debug\entities\Document +____ + +## Description +Defines a document (global scope) of a php file + +## Synopsis +```php +interface Document { + + // Methods + hasOpenTag(): bool + isStrict(): bool + isDeclaredEncoding(): null|string + getNamespace(): null|string + getClass(string $label): null|im\debug\entities\Clazz + getClasses(): array + getFunction(string $label): null|im\debug\entities\Routine + getFunctions(): array + getImport(string $label): null|im\debug\entities\Import + getImports(): array + getConstant(string $label): null|im\debug\entities\Property + getConstants(): array +} +``` + +## Methods +| Name | Description | +| :--- | :---------- | +| [__Document :: hasOpenTag__](entities-Document-hasOpenTag.md) | Whether or not this document has an PHP open tag This is a way to check if a file is actually a PHP file | +| [__Document :: isStrict__](entities-Document-isStrict.md) | Whether or not this is a `strict_types` document This will return `TRUE` if it has `strict_types` set in the beginning | +| [__Document :: isDeclaredEncoding__](entities-Document-isDeclaredEncoding.md) | Returns the specified encoding, if any This will return the encoding defined in the beginning, or `NULL` if this is not defined | +| [__Document :: getNamespace__](entities-Document-getNamespace.md) | Returns the namespace of this document If this file has a namespace set, it will be returned | +| [__Document :: getClass__](entities-Document-getClass.md) | Find and return a specific class | +| [__Document :: getClasses__](entities-Document-getClasses.md) | Returns all classes in this document | +| [__Document :: getFunction__](entities-Document-getFunction.md) | Find and return a specific function | +| [__Document :: getFunctions__](entities-Document-getFunctions.md) | Returns all functions in this document | +| [__Document :: getImport__](entities-Document-getImport.md) | Find and return a specific import | +| [__Document :: getImports__](entities-Document-getImports.md) | Returns all imports in this document | +| [__Document :: getConstant__](entities-Document-getConstant.md) | Find and return a specific constant | +| [__Document :: getConstants__](entities-Document-getConstants.md) | Returns all constants in this document | diff --git a/docs/entities-Entity-__toString.md b/docs/entities-Entity-__toString.md new file mode 100644 index 0000000..a25df2d --- /dev/null +++ b/docs/entities-Entity-__toString.md @@ -0,0 +1,8 @@ +# [Entities](entities.md) / [Entity](entities-Entity.md) :: __toString + > im\debug\entities\Entity +____ + +## Synopsis +```php +abstract public __toString(): string +``` diff --git a/docs/entities-Entity-var_line.md b/docs/entities-Entity-var_line.md new file mode 100644 index 0000000..c88777b --- /dev/null +++ b/docs/entities-Entity-var_line.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Entity](entities-Entity.md) :: $line + > im\debug\entities\Entity +____ + +## Description +The line number of where this entity begins + +## Synopsis +```php +public int $line = -1 +``` diff --git a/docs/entities-Entity-var_pos.md b/docs/entities-Entity-var_pos.md new file mode 100644 index 0000000..e5bf954 --- /dev/null +++ b/docs/entities-Entity-var_pos.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Entity](entities-Entity.md) :: $pos + > im\debug\entities\Entity +____ + +## Description +The position of where this entity begins + +## Synopsis +```php +public int $pos = -1 +``` diff --git a/docs/entities-Entity.md b/docs/entities-Entity.md new file mode 100644 index 0000000..d457f74 --- /dev/null +++ b/docs/entities-Entity.md @@ -0,0 +1,33 @@ +# [Debug](debug.md) / [Entities](entities.md) / Entity + > im\debug\entities\Entity +____ + +## Description +Defines an Entity + +This interface is shared across all entities like +Argument, Clazz, Routine, Name, Type and more... + +## Synopsis +```php +abstract class Entity implements Stringable { + + // Properties + public int $line = -1 + public int $pos = -1 + + // Inherited Methods + abstract public __toString(): string +} +``` + +## Properties +| Name | Description | +| :--- | :---------- | +| [__Entity :: $line__](entities-Entity-var_line.md) | The line number of where this entity begins | +| [__Entity :: $pos__](entities-Entity-var_pos.md) | The position of where this entity begins | + +## Methods +| Name | Description | +| :--- | :---------- | +| [__Entity :: \_\_toString__](entities-Entity-__toString.md) | | diff --git a/docs/entities-Import-__construct.md b/docs/entities-Import-__construct.md new file mode 100644 index 0000000..03994f7 --- /dev/null +++ b/docs/entities-Import-__construct.md @@ -0,0 +1,18 @@ +# [Entities](entities.md) / [Import](entities-Import.md) :: __construct + > im\debug\entities\Import +____ + +## Description +Construct a new Import + +## Synopsis +```php +public __construct(string $path, null|string $alias = NULL, null|string $type = NULL) +``` + +## Parameters +| Name | Description | +| :--- | :---------- | +| path | Complete name path, including possible namespace | +| alias | An alias for this name | +| type | Import type like `function` or `const`.
This defaults to `class`. | diff --git a/docs/entities-Import-getLabel.md b/docs/entities-Import-getLabel.md new file mode 100644 index 0000000..5a61c88 --- /dev/null +++ b/docs/entities-Import-getLabel.md @@ -0,0 +1,15 @@ +# [Entities](entities.md) / [Import](entities-Import.md) :: getLabel + > im\debug\entities\Import +____ + +## Description +Get the label for this name + +This returns a basename without any namespace part. +If an alias is defined, this is what get's returned. +Otherwise it will return the name, with namespace stripped. + +## Synopsis +```php +public getLabel(): string +``` diff --git a/docs/entities-Import-getName.md b/docs/entities-Import-getName.md new file mode 100644 index 0000000..711c005 --- /dev/null +++ b/docs/entities-Import-getName.md @@ -0,0 +1,14 @@ +# [Entities](entities.md) / [Import](entities-Import.md) :: getName + > im\debug\entities\Import +____ + +## Description +Get the string representation of this name path + +This will always return the complete named path +with any namespace. + +## Synopsis +```php +public getName(): string +``` diff --git a/docs/entities-Import-getNamespace.md b/docs/entities-Import-getNamespace.md new file mode 100644 index 0000000..690946d --- /dev/null +++ b/docs/entities-Import-getNamespace.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Import](entities-Import.md) :: getNamespace + > im\debug\entities\Import +____ + +## Description +Get the namespace of this name path + +## Synopsis +```php +public getNamespace(): null|string +``` diff --git a/docs/entities-Import-getType.md b/docs/entities-Import-getType.md new file mode 100644 index 0000000..90ba352 --- /dev/null +++ b/docs/entities-Import-getType.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Import](entities-Import.md) :: getType + > im\debug\entities\Import +____ + +## Description +Get the import type + +## Synopsis +```php +public getType(): string +``` diff --git a/docs/entities-Import-var_line.md b/docs/entities-Import-var_line.md new file mode 100644 index 0000000..2d2c439 --- /dev/null +++ b/docs/entities-Import-var_line.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Import](entities-Import.md) :: $line + > im\debug\entities\Import +____ + +## Description +The line number of where this entity begins + +## Synopsis +```php +public int $line = -1 +``` diff --git a/docs/entities-Import-var_pos.md b/docs/entities-Import-var_pos.md new file mode 100644 index 0000000..d16d228 --- /dev/null +++ b/docs/entities-Import-var_pos.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Import](entities-Import.md) :: $pos + > im\debug\entities\Import +____ + +## Description +The position of where this entity begins + +## Synopsis +```php +public int $pos = -1 +``` diff --git a/docs/entities-Import.md b/docs/entities-Import.md new file mode 100644 index 0000000..6a6671f --- /dev/null +++ b/docs/entities-Import.md @@ -0,0 +1,43 @@ +# [Debug](debug.md) / [Entities](entities.md) / Import + > im\debug\entities\Import +____ + +## Description +Defines an import + +Imports are references added to a document +like `use namespace\MyClass as MyAlias`. + +## Synopsis +```php +class Import extends im\debug\entities\Name implements Stringable { + + // Inherited Properties + public int $line = -1 + public int $pos = -1 + + // Methods + public __construct(string $path, null|string $alias = NULL, null|string $type = NULL) + public getType(): string + + // Inherited Methods + public getLabel(): string + public getName(): string + public getNamespace(): null|string +} +``` + +## Properties +| Name | Description | +| :--- | :---------- | +| [__Import :: $line__](entities-Import-var_line.md) | The line number of where this entity begins | +| [__Import :: $pos__](entities-Import-var_pos.md) | The position of where this entity begins | + +## Methods +| Name | Description | +| :--- | :---------- | +| [__Import :: \_\_construct__](entities-Import-__construct.md) | Construct a new Import | +| [__Import :: getType__](entities-Import-getType.md) | Get the import type | +| [__Import :: getLabel__](entities-Import-getLabel.md) | Get the label for this name This returns a basename without any namespace part | +| [__Import :: getName__](entities-Import-getName.md) | Get the string representation of this name path This will always return the complete named path with any namespace | +| [__Import :: getNamespace__](entities-Import-getNamespace.md) | Get the namespace of this name path | diff --git a/docs/entities-IntersectType-__construct.md b/docs/entities-IntersectType-__construct.md new file mode 100644 index 0000000..601a049 --- /dev/null +++ b/docs/entities-IntersectType-__construct.md @@ -0,0 +1,16 @@ +# [Entities](entities.md) / [IntersectType](entities-IntersectType.md) :: __construct + > im\debug\entities\IntersectType +____ + +## Description +Construct a new IntersectType + +## Synopsis +```php +public __construct(im\debug\entities\Type ...$types) +``` + +## Parameters +| Name | Description | +| :--- | :---------- | +| types | Types to add to this intersection | diff --git a/docs/entities-IntersectType-getIterator.md b/docs/entities-IntersectType-getIterator.md new file mode 100644 index 0000000..30bdbc2 --- /dev/null +++ b/docs/entities-IntersectType-getIterator.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [IntersectType](entities-IntersectType.md) :: getIterator + > im\debug\entities\IntersectType +____ + +## Description +Provides a Traversable to iterate through the types within + +## Synopsis +```php +public getIterator(): Traversable +``` diff --git a/docs/entities-IntersectType-getLabel.md b/docs/entities-IntersectType-getLabel.md new file mode 100644 index 0000000..da7100d --- /dev/null +++ b/docs/entities-IntersectType-getLabel.md @@ -0,0 +1,15 @@ +# [Entities](entities.md) / [IntersectType](entities-IntersectType.md) :: getLabel + > im\debug\entities\IntersectType +____ + +## Description +Get the label for this name + +This returns a basename without any namespace part. +If an alias is defined, this is what get's returned. +Otherwise it will return the name, with namespace stripped. + +## Synopsis +```php +public getLabel(): string +``` diff --git a/docs/entities-IntersectType-getName.md b/docs/entities-IntersectType-getName.md new file mode 100644 index 0000000..58a0cca --- /dev/null +++ b/docs/entities-IntersectType-getName.md @@ -0,0 +1,14 @@ +# [Entities](entities.md) / [IntersectType](entities-IntersectType.md) :: getName + > im\debug\entities\IntersectType +____ + +## Description +Get the string representation of this name path + +This will always return the complete named path +with any namespace. + +## Synopsis +```php +public getName(): string +``` diff --git a/docs/entities-IntersectType-getNamespace.md b/docs/entities-IntersectType-getNamespace.md new file mode 100644 index 0000000..6211a06 --- /dev/null +++ b/docs/entities-IntersectType-getNamespace.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [IntersectType](entities-IntersectType.md) :: getNamespace + > im\debug\entities\IntersectType +____ + +## Description +Get the namespace of this name path + +## Synopsis +```php +public getNamespace(): null|string +``` diff --git a/docs/entities-IntersectType-isNative.md b/docs/entities-IntersectType-isNative.md new file mode 100644 index 0000000..529665b --- /dev/null +++ b/docs/entities-IntersectType-isNative.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [IntersectType](entities-IntersectType.md) :: isNative + > im\debug\entities\IntersectType +____ + +## Description +Whether this type is a native type + +## Synopsis +```php +public isNative(): bool +``` diff --git a/docs/entities-IntersectType-var_line.md b/docs/entities-IntersectType-var_line.md new file mode 100644 index 0000000..c046c84 --- /dev/null +++ b/docs/entities-IntersectType-var_line.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [IntersectType](entities-IntersectType.md) :: $line + > im\debug\entities\IntersectType +____ + +## Description +The line number of where this entity begins + +## Synopsis +```php +public int $line = -1 +``` diff --git a/docs/entities-IntersectType-var_pos.md b/docs/entities-IntersectType-var_pos.md new file mode 100644 index 0000000..fc19fc7 --- /dev/null +++ b/docs/entities-IntersectType-var_pos.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [IntersectType](entities-IntersectType.md) :: $pos + > im\debug\entities\IntersectType +____ + +## Description +The position of where this entity begins + +## Synopsis +```php +public int $pos = -1 +``` diff --git a/docs/entities-IntersectType.md b/docs/entities-IntersectType.md new file mode 100644 index 0000000..3b6c143 --- /dev/null +++ b/docs/entities-IntersectType.md @@ -0,0 +1,42 @@ +# [Debug](debug.md) / [Entities](entities.md) / IntersectType + > im\debug\entities\IntersectType +____ + +## Description +Defines a Type container for use with intersection types + +## Synopsis +```php +class IntersectType extends im\debug\entities\Type implements Stringable, IteratorAggregate, Traversable { + + // Inherited Properties + public int $line = -1 + public int $pos = -1 + + // Methods + public __construct(im\debug\entities\Type ...$types) + public getIterator(): Traversable + + // Inherited Methods + public isNative(): bool + public getLabel(): string + public getName(): string + public getNamespace(): null|string +} +``` + +## Properties +| Name | Description | +| :--- | :---------- | +| [__IntersectType :: $line__](entities-IntersectType-var_line.md) | The line number of where this entity begins | +| [__IntersectType :: $pos__](entities-IntersectType-var_pos.md) | The position of where this entity begins | + +## Methods +| Name | Description | +| :--- | :---------- | +| [__IntersectType :: \_\_construct__](entities-IntersectType-__construct.md) | Construct a new IntersectType | +| [__IntersectType :: getIterator__](entities-IntersectType-getIterator.md) | Provides a Traversable to iterate through the types within | +| [__IntersectType :: isNative__](entities-IntersectType-isNative.md) | Whether this type is a native type | +| [__IntersectType :: getLabel__](entities-IntersectType-getLabel.md) | Get the label for this name This returns a basename without any namespace part | +| [__IntersectType :: getName__](entities-IntersectType-getName.md) | Get the string representation of this name path This will always return the complete named path with any namespace | +| [__IntersectType :: getNamespace__](entities-IntersectType-getNamespace.md) | Get the namespace of this name path | diff --git a/docs/entities-Member-__construct.md b/docs/entities-Member-__construct.md new file mode 100644 index 0000000..07ac7af --- /dev/null +++ b/docs/entities-Member-__construct.md @@ -0,0 +1,18 @@ +# [Entities](entities.md) / [Member](entities-Member.md) :: __construct + > im\debug\entities\Member +____ + +## Description +Construct a new Member + +## Synopsis +```php +public __construct(im\debug\entities\Name $name, im\debug\entities\Type $type, int $flags = im\debug\entities\Member::T_PUBLIC) +``` + +## Parameters +| Name | Description | +| :--- | :---------- | +| name | Name of the member | +| type | The member type | +| flags | Member flags | diff --git a/docs/entities-Member-getName.md b/docs/entities-Member-getName.md new file mode 100644 index 0000000..3376229 --- /dev/null +++ b/docs/entities-Member-getName.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Member](entities-Member.md) :: getName + > im\debug\entities\Member +____ + +## Description +Get the name of this member + +## Synopsis +```php +public getName(): im\debug\entities\Name +``` diff --git a/docs/entities-Member-getType.md b/docs/entities-Member-getType.md new file mode 100644 index 0000000..cf11c9c --- /dev/null +++ b/docs/entities-Member-getType.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Member](entities-Member.md) :: getType + > im\debug\entities\Member +____ + +## Description +Get the type of this member + +## Synopsis +```php +public getType(): im\debug\entities\Type +``` diff --git a/docs/entities-Member-isFinal.md b/docs/entities-Member-isFinal.md new file mode 100644 index 0000000..f67603d --- /dev/null +++ b/docs/entities-Member-isFinal.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Member](entities-Member.md) :: isFinal + > im\debug\entities\Member +____ + +## Description +Whether this member is final + +## Synopsis +```php +public isFinal(): bool +``` diff --git a/docs/entities-Member-isPrivate.md b/docs/entities-Member-isPrivate.md new file mode 100644 index 0000000..20db1e0 --- /dev/null +++ b/docs/entities-Member-isPrivate.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Member](entities-Member.md) :: isPrivate + > im\debug\entities\Member +____ + +## Description +Whether this member is private + +## Synopsis +```php +public isPrivate(): bool +``` diff --git a/docs/entities-Member-isProtected.md b/docs/entities-Member-isProtected.md new file mode 100644 index 0000000..6091729 --- /dev/null +++ b/docs/entities-Member-isProtected.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Member](entities-Member.md) :: isProtected + > im\debug\entities\Member +____ + +## Description +Whether this member is protected + +## Synopsis +```php +public isProtected(): bool +``` diff --git a/docs/entities-Member-isPublic.md b/docs/entities-Member-isPublic.md new file mode 100644 index 0000000..823f2c8 --- /dev/null +++ b/docs/entities-Member-isPublic.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Member](entities-Member.md) :: isPublic + > im\debug\entities\Member +____ + +## Description +Whether this member is public + +## Synopsis +```php +public isPublic(): bool +``` diff --git a/docs/entities-Member-isStatic.md b/docs/entities-Member-isStatic.md new file mode 100644 index 0000000..d9bcaaf --- /dev/null +++ b/docs/entities-Member-isStatic.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Member](entities-Member.md) :: isStatic + > im\debug\entities\Member +____ + +## Description +Whether this member is static + +## Synopsis +```php +public isStatic(): bool +``` diff --git a/docs/entities-Member-prop_T_FINAL.md b/docs/entities-Member-prop_T_FINAL.md new file mode 100644 index 0000000..a603767 --- /dev/null +++ b/docs/entities-Member-prop_T_FINAL.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Member](entities-Member.md) :: T_FINAL + > im\debug\entities\Member +____ + +## Description +This is a final member + +## Synopsis +```php +public T_FINAL = 256 +``` diff --git a/docs/entities-Member-prop_T_META.md b/docs/entities-Member-prop_T_META.md new file mode 100644 index 0000000..ccefa50 --- /dev/null +++ b/docs/entities-Member-prop_T_META.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Member](entities-Member.md) :: T_META + > im\debug\entities\Member +____ + +## Description +Meta that defines all member modifier flags + +## Synopsis +```php +public T_META = 1048320 +``` diff --git a/docs/entities-Member-prop_T_PRIVATE.md b/docs/entities-Member-prop_T_PRIVATE.md new file mode 100644 index 0000000..0335bf4 --- /dev/null +++ b/docs/entities-Member-prop_T_PRIVATE.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Member](entities-Member.md) :: T_PRIVATE + > im\debug\entities\Member +____ + +## Description +This is a private member + +## Synopsis +```php +public T_PRIVATE = 32768 +``` diff --git a/docs/entities-Member-prop_T_PROTECTED.md b/docs/entities-Member-prop_T_PROTECTED.md new file mode 100644 index 0000000..8a4882f --- /dev/null +++ b/docs/entities-Member-prop_T_PROTECTED.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Member](entities-Member.md) :: T_PROTECTED + > im\debug\entities\Member +____ + +## Description +This is a protected member + +## Synopsis +```php +public T_PROTECTED = 16384 +``` diff --git a/docs/entities-Member-prop_T_PUBLIC.md b/docs/entities-Member-prop_T_PUBLIC.md new file mode 100644 index 0000000..e658f2f --- /dev/null +++ b/docs/entities-Member-prop_T_PUBLIC.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Member](entities-Member.md) :: T_PUBLIC + > im\debug\entities\Member +____ + +## Description +This is a public member + +## Synopsis +```php +public T_PUBLIC = 8192 +``` diff --git a/docs/entities-Member-prop_T_STATIC.md b/docs/entities-Member-prop_T_STATIC.md new file mode 100644 index 0000000..a0e9837 --- /dev/null +++ b/docs/entities-Member-prop_T_STATIC.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Member](entities-Member.md) :: T_STATIC + > im\debug\entities\Member +____ + +## Description +This is a static member + +## Synopsis +```php +public T_STATIC = 1024 +``` diff --git a/docs/entities-Member-var_line.md b/docs/entities-Member-var_line.md new file mode 100644 index 0000000..40220b9 --- /dev/null +++ b/docs/entities-Member-var_line.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Member](entities-Member.md) :: $line + > im\debug\entities\Member +____ + +## Description +The line number of where this entity begins + +## Synopsis +```php +public int $line = -1 +``` diff --git a/docs/entities-Member-var_pos.md b/docs/entities-Member-var_pos.md new file mode 100644 index 0000000..8a2220d --- /dev/null +++ b/docs/entities-Member-var_pos.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Member](entities-Member.md) :: $pos + > im\debug\entities\Member +____ + +## Description +The position of where this entity begins + +## Synopsis +```php +public int $pos = -1 +``` diff --git a/docs/entities-Member.md b/docs/entities-Member.md new file mode 100644 index 0000000..8341377 --- /dev/null +++ b/docs/entities-Member.md @@ -0,0 +1,65 @@ +# [Debug](debug.md) / [Entities](entities.md) / Member + > im\debug\entities\Member +____ + +## Description +Defines a class member + +This is used for things like a method, +property, enum case etc. + +## Synopsis +```php +abstract class Member extends im\debug\entities\Entity implements Stringable { + + // Constants + public T_PUBLIC = 8192 + public T_PROTECTED = 16384 + public T_PRIVATE = 32768 + public T_STATIC = 1024 + public T_FINAL = 256 + public T_META = 1048320 + + // Inherited Properties + public int $line = -1 + public int $pos = -1 + + // Methods + public __construct(im\debug\entities\Name $name, im\debug\entities\Type $type, int $flags = im\debug\entities\Member::T_PUBLIC) + public getType(): im\debug\entities\Type + public getName(): im\debug\entities\Name + public isPublic(): bool + public isProtected(): bool + public isPrivate(): bool + public isStatic(): bool + public isFinal(): bool +} +``` + +## Constants +| Name | Description | +| :--- | :---------- | +| [__Member :: T\_PUBLIC__](entities-Member-prop_T_PUBLIC.md) | This is a public member | +| [__Member :: T\_PROTECTED__](entities-Member-prop_T_PROTECTED.md) | This is a protected member | +| [__Member :: T\_PRIVATE__](entities-Member-prop_T_PRIVATE.md) | This is a private member | +| [__Member :: T\_STATIC__](entities-Member-prop_T_STATIC.md) | This is a static member | +| [__Member :: T\_FINAL__](entities-Member-prop_T_FINAL.md) | This is a final member | +| [__Member :: T\_META__](entities-Member-prop_T_META.md) | Meta that defines all member modifier flags | + +## Properties +| Name | Description | +| :--- | :---------- | +| [__Member :: $line__](entities-Member-var_line.md) | The line number of where this entity begins | +| [__Member :: $pos__](entities-Member-var_pos.md) | The position of where this entity begins | + +## Methods +| Name | Description | +| :--- | :---------- | +| [__Member :: \_\_construct__](entities-Member-__construct.md) | Construct a new Member | +| [__Member :: getType__](entities-Member-getType.md) | Get the type of this member | +| [__Member :: getName__](entities-Member-getName.md) | Get the name of this member | +| [__Member :: isPublic__](entities-Member-isPublic.md) | Whether this member is public | +| [__Member :: isProtected__](entities-Member-isProtected.md) | Whether this member is protected | +| [__Member :: isPrivate__](entities-Member-isPrivate.md) | Whether this member is private | +| [__Member :: isStatic__](entities-Member-isStatic.md) | Whether this member is static | +| [__Member :: isFinal__](entities-Member-isFinal.md) | Whether this member is final | diff --git a/docs/entities-Name-__construct.md b/docs/entities-Name-__construct.md new file mode 100644 index 0000000..5c79377 --- /dev/null +++ b/docs/entities-Name-__construct.md @@ -0,0 +1,17 @@ +# [Entities](entities.md) / [Name](entities-Name.md) :: __construct + > im\debug\entities\Name +____ + +## Description +Construct a new Name + +## Synopsis +```php +public __construct(string $path, null|string $alias = NULL) +``` + +## Parameters +| Name | Description | +| :--- | :---------- | +| path | Complete name path, including possible namespace | +| alias | An alias for this name | diff --git a/docs/entities-Name-getLabel.md b/docs/entities-Name-getLabel.md new file mode 100644 index 0000000..cfab824 --- /dev/null +++ b/docs/entities-Name-getLabel.md @@ -0,0 +1,15 @@ +# [Entities](entities.md) / [Name](entities-Name.md) :: getLabel + > im\debug\entities\Name +____ + +## Description +Get the label for this name + +This returns a basename without any namespace part. +If an alias is defined, this is what get's returned. +Otherwise it will return the name, with namespace stripped. + +## Synopsis +```php +public getLabel(): string +``` diff --git a/docs/entities-Name-getName.md b/docs/entities-Name-getName.md new file mode 100644 index 0000000..74430a3 --- /dev/null +++ b/docs/entities-Name-getName.md @@ -0,0 +1,14 @@ +# [Entities](entities.md) / [Name](entities-Name.md) :: getName + > im\debug\entities\Name +____ + +## Description +Get the string representation of this name path + +This will always return the complete named path +with any namespace. + +## Synopsis +```php +public getName(): string +``` diff --git a/docs/entities-Name-getNamespace.md b/docs/entities-Name-getNamespace.md new file mode 100644 index 0000000..6aedb44 --- /dev/null +++ b/docs/entities-Name-getNamespace.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Name](entities-Name.md) :: getNamespace + > im\debug\entities\Name +____ + +## Description +Get the namespace of this name path + +## Synopsis +```php +public getNamespace(): null|string +``` diff --git a/docs/entities-Name-var_line.md b/docs/entities-Name-var_line.md new file mode 100644 index 0000000..72d92a1 --- /dev/null +++ b/docs/entities-Name-var_line.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Name](entities-Name.md) :: $line + > im\debug\entities\Name +____ + +## Description +The line number of where this entity begins + +## Synopsis +```php +public int $line = -1 +``` diff --git a/docs/entities-Name-var_pos.md b/docs/entities-Name-var_pos.md new file mode 100644 index 0000000..d1f1215 --- /dev/null +++ b/docs/entities-Name-var_pos.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Name](entities-Name.md) :: $pos + > im\debug\entities\Name +____ + +## Description +The position of where this entity begins + +## Synopsis +```php +public int $pos = -1 +``` diff --git a/docs/entities-Name.md b/docs/entities-Name.md new file mode 100644 index 0000000..7e6f66e --- /dev/null +++ b/docs/entities-Name.md @@ -0,0 +1,36 @@ +# [Debug](debug.md) / [Entities](entities.md) / Name + > im\debug\entities\Name +____ + +## Description +Defines a name with support for alias and namespace + +## Synopsis +```php +class Name extends im\debug\entities\Entity implements Stringable { + + // Inherited Properties + public int $line = -1 + public int $pos = -1 + + // Methods + public __construct(string $path, null|string $alias = NULL) + public getLabel(): string + public getName(): string + public getNamespace(): null|string +} +``` + +## Properties +| Name | Description | +| :--- | :---------- | +| [__Name :: $line__](entities-Name-var_line.md) | The line number of where this entity begins | +| [__Name :: $pos__](entities-Name-var_pos.md) | The position of where this entity begins | + +## Methods +| Name | Description | +| :--- | :---------- | +| [__Name :: \_\_construct__](entities-Name-__construct.md) | Construct a new Name | +| [__Name :: getLabel__](entities-Name-getLabel.md) | Get the label for this name This returns a basename without any namespace part | +| [__Name :: getName__](entities-Name-getName.md) | Get the string representation of this name path This will always return the complete named path with any namespace | +| [__Name :: getNamespace__](entities-Name-getNamespace.md) | Get the namespace of this name path | diff --git a/docs/entities-Property-__construct.md b/docs/entities-Property-__construct.md new file mode 100644 index 0000000..f60bed8 --- /dev/null +++ b/docs/entities-Property-__construct.md @@ -0,0 +1,18 @@ +# [Entities](entities.md) / [Property](entities-Property.md) :: __construct + > im\debug\entities\Property +____ + +## Description +Construct a new Member + +## Synopsis +```php +public __construct(im\debug\entities\Name $name, im\debug\entities\Type $type, int $flags = im\debug\entities\Member::T_PUBLIC) +``` + +## Parameters +| Name | Description | +| :--- | :---------- | +| name | Name of the member | +| type | The member type | +| flags | Member flags | diff --git a/docs/entities-Property-getName.md b/docs/entities-Property-getName.md new file mode 100644 index 0000000..0ff9225 --- /dev/null +++ b/docs/entities-Property-getName.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Property](entities-Property.md) :: getName + > im\debug\entities\Property +____ + +## Description +Get the name of this member + +## Synopsis +```php +public getName(): im\debug\entities\Name +``` diff --git a/docs/entities-Property-getType.md b/docs/entities-Property-getType.md new file mode 100644 index 0000000..c3e09a7 --- /dev/null +++ b/docs/entities-Property-getType.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Property](entities-Property.md) :: getType + > im\debug\entities\Property +____ + +## Description +Get the type of this member + +## Synopsis +```php +public getType(): im\debug\entities\Type +``` diff --git a/docs/entities-Property-isEnumCase.md b/docs/entities-Property-isEnumCase.md new file mode 100644 index 0000000..bb54292 --- /dev/null +++ b/docs/entities-Property-isEnumCase.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Property](entities-Property.md) :: isEnumCase + > im\debug\entities\Property +____ + +## Description +Whether this member is an enum case + +## Synopsis +```php +public isEnumCase(): bool +``` diff --git a/docs/entities-Property-isFinal.md b/docs/entities-Property-isFinal.md new file mode 100644 index 0000000..ac4abf1 --- /dev/null +++ b/docs/entities-Property-isFinal.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Property](entities-Property.md) :: isFinal + > im\debug\entities\Property +____ + +## Description +Whether this member is final + +## Synopsis +```php +public isFinal(): bool +``` diff --git a/docs/entities-Property-isPrivate.md b/docs/entities-Property-isPrivate.md new file mode 100644 index 0000000..397f6ed --- /dev/null +++ b/docs/entities-Property-isPrivate.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Property](entities-Property.md) :: isPrivate + > im\debug\entities\Property +____ + +## Description +Whether this member is private + +## Synopsis +```php +public isPrivate(): bool +``` diff --git a/docs/entities-Property-isProtected.md b/docs/entities-Property-isProtected.md new file mode 100644 index 0000000..72ed27b --- /dev/null +++ b/docs/entities-Property-isProtected.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Property](entities-Property.md) :: isProtected + > im\debug\entities\Property +____ + +## Description +Whether this member is protected + +## Synopsis +```php +public isProtected(): bool +``` diff --git a/docs/entities-Property-isPublic.md b/docs/entities-Property-isPublic.md new file mode 100644 index 0000000..8889ed4 --- /dev/null +++ b/docs/entities-Property-isPublic.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Property](entities-Property.md) :: isPublic + > im\debug\entities\Property +____ + +## Description +Whether this member is public + +## Synopsis +```php +public isPublic(): bool +``` diff --git a/docs/entities-Property-isReadonly.md b/docs/entities-Property-isReadonly.md new file mode 100644 index 0000000..b462653 --- /dev/null +++ b/docs/entities-Property-isReadonly.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Property](entities-Property.md) :: isReadonly + > im\debug\entities\Property +____ + +## Description +Whether this member is readonly + +## Synopsis +```php +public isReadonly(): bool +``` diff --git a/docs/entities-Property-isStatic.md b/docs/entities-Property-isStatic.md new file mode 100644 index 0000000..09d1cc7 --- /dev/null +++ b/docs/entities-Property-isStatic.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Property](entities-Property.md) :: isStatic + > im\debug\entities\Property +____ + +## Description +Whether this member is static + +## Synopsis +```php +public isStatic(): bool +``` diff --git a/docs/entities-Property-prop_T_CASE.md b/docs/entities-Property-prop_T_CASE.md new file mode 100644 index 0000000..46787d2 --- /dev/null +++ b/docs/entities-Property-prop_T_CASE.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Property](entities-Property.md) :: T_CASE + > im\debug\entities\Property +____ + +## Description +This is an enum case member + +## Synopsis +```php +public T_CASE = 65536 +``` diff --git a/docs/entities-Property-prop_T_FINAL.md b/docs/entities-Property-prop_T_FINAL.md new file mode 100644 index 0000000..d473de5 --- /dev/null +++ b/docs/entities-Property-prop_T_FINAL.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Property](entities-Property.md) :: T_FINAL + > im\debug\entities\Property +____ + +## Description +This is a final member + +## Synopsis +```php +public T_FINAL = 256 +``` diff --git a/docs/entities-Property-prop_T_META.md b/docs/entities-Property-prop_T_META.md new file mode 100644 index 0000000..e5adaf1 --- /dev/null +++ b/docs/entities-Property-prop_T_META.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Property](entities-Property.md) :: T_META + > im\debug\entities\Property +____ + +## Description +Meta that defines all member modifier flags + +## Synopsis +```php +public T_META = 1048320 +``` diff --git a/docs/entities-Property-prop_T_PRIVATE.md b/docs/entities-Property-prop_T_PRIVATE.md new file mode 100644 index 0000000..27dcf59 --- /dev/null +++ b/docs/entities-Property-prop_T_PRIVATE.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Property](entities-Property.md) :: T_PRIVATE + > im\debug\entities\Property +____ + +## Description +This is a private member + +## Synopsis +```php +public T_PRIVATE = 32768 +``` diff --git a/docs/entities-Property-prop_T_PROTECTED.md b/docs/entities-Property-prop_T_PROTECTED.md new file mode 100644 index 0000000..6b5f48e --- /dev/null +++ b/docs/entities-Property-prop_T_PROTECTED.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Property](entities-Property.md) :: T_PROTECTED + > im\debug\entities\Property +____ + +## Description +This is a protected member + +## Synopsis +```php +public T_PROTECTED = 16384 +``` diff --git a/docs/entities-Property-prop_T_PUBLIC.md b/docs/entities-Property-prop_T_PUBLIC.md new file mode 100644 index 0000000..cbef4ce --- /dev/null +++ b/docs/entities-Property-prop_T_PUBLIC.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Property](entities-Property.md) :: T_PUBLIC + > im\debug\entities\Property +____ + +## Description +This is a public member + +## Synopsis +```php +public T_PUBLIC = 8192 +``` diff --git a/docs/entities-Property-prop_T_READONLY.md b/docs/entities-Property-prop_T_READONLY.md new file mode 100644 index 0000000..ecea21d --- /dev/null +++ b/docs/entities-Property-prop_T_READONLY.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Property](entities-Property.md) :: T_READONLY + > im\debug\entities\Property +____ + +## Description +This is a readonly member + +## Synopsis +```php +public T_READONLY = 2048 +``` diff --git a/docs/entities-Property-prop_T_STATIC.md b/docs/entities-Property-prop_T_STATIC.md new file mode 100644 index 0000000..43d985e --- /dev/null +++ b/docs/entities-Property-prop_T_STATIC.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Property](entities-Property.md) :: T_STATIC + > im\debug\entities\Property +____ + +## Description +This is a static member + +## Synopsis +```php +public T_STATIC = 1024 +``` diff --git a/docs/entities-Property-var_line.md b/docs/entities-Property-var_line.md new file mode 100644 index 0000000..62706e4 --- /dev/null +++ b/docs/entities-Property-var_line.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Property](entities-Property.md) :: $line + > im\debug\entities\Property +____ + +## Description +The line number of where this entity begins + +## Synopsis +```php +public int $line = -1 +``` diff --git a/docs/entities-Property-var_pos.md b/docs/entities-Property-var_pos.md new file mode 100644 index 0000000..17c20ef --- /dev/null +++ b/docs/entities-Property-var_pos.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Property](entities-Property.md) :: $pos + > im\debug\entities\Property +____ + +## Description +The position of where this entity begins + +## Synopsis +```php +public int $pos = -1 +``` diff --git a/docs/entities-Property.md b/docs/entities-Property.md new file mode 100644 index 0000000..23968d4 --- /dev/null +++ b/docs/entities-Property.md @@ -0,0 +1,77 @@ +# [Debug](debug.md) / [Entities](entities.md) / Property + > im\debug\entities\Property +____ + +## Description +Defines a property + +This can be class variable or constant as well as +a global constant. + +## Synopsis +```php +class Property extends im\debug\entities\Member implements Stringable { + + // Constants + public T_READONLY = 2048 + public T_CASE = 65536 + + // Inherited Constants + public T_PUBLIC = 8192 + public T_PROTECTED = 16384 + public T_PRIVATE = 32768 + public T_STATIC = 1024 + public T_FINAL = 256 + public T_META = 1048320 + + // Inherited Properties + public int $line = -1 + public int $pos = -1 + + // Methods + public isReadonly(): bool + public isEnumCase(): bool + + // Inherited Methods + public __construct(im\debug\entities\Name $name, im\debug\entities\Type $type, int $flags = im\debug\entities\Member::T_PUBLIC) + public getType(): im\debug\entities\Type + public getName(): im\debug\entities\Name + public isPublic(): bool + public isProtected(): bool + public isPrivate(): bool + public isStatic(): bool + public isFinal(): bool +} +``` + +## Constants +| Name | Description | +| :--- | :---------- | +| [__Property :: T\_READONLY__](entities-Property-prop_T_READONLY.md) | This is a readonly member | +| [__Property :: T\_CASE__](entities-Property-prop_T_CASE.md) | This is an enum case member | +| [__Property :: T\_PUBLIC__](entities-Property-prop_T_PUBLIC.md) | This is a public member | +| [__Property :: T\_PROTECTED__](entities-Property-prop_T_PROTECTED.md) | This is a protected member | +| [__Property :: T\_PRIVATE__](entities-Property-prop_T_PRIVATE.md) | This is a private member | +| [__Property :: T\_STATIC__](entities-Property-prop_T_STATIC.md) | This is a static member | +| [__Property :: T\_FINAL__](entities-Property-prop_T_FINAL.md) | This is a final member | +| [__Property :: T\_META__](entities-Property-prop_T_META.md) | Meta that defines all member modifier flags | + +## Properties +| Name | Description | +| :--- | :---------- | +| [__Property :: $line__](entities-Property-var_line.md) | The line number of where this entity begins | +| [__Property :: $pos__](entities-Property-var_pos.md) | The position of where this entity begins | + +## Methods +| Name | Description | +| :--- | :---------- | +| [__Property :: isReadonly__](entities-Property-isReadonly.md) | Whether this member is readonly | +| [__Property :: isEnumCase__](entities-Property-isEnumCase.md) | Whether this member is an enum case | +| [__Property :: \_\_construct__](entities-Property-__construct.md) | Construct a new Member | +| [__Property :: getType__](entities-Property-getType.md) | Get the type of this member | +| [__Property :: getName__](entities-Property-getName.md) | Get the name of this member | +| [__Property :: isPublic__](entities-Property-isPublic.md) | Whether this member is public | +| [__Property :: isProtected__](entities-Property-isProtected.md) | Whether this member is protected | +| [__Property :: isPrivate__](entities-Property-isPrivate.md) | Whether this member is private | +| [__Property :: isStatic__](entities-Property-isStatic.md) | Whether this member is static | +| [__Property :: isFinal__](entities-Property-isFinal.md) | Whether this member is final | diff --git a/docs/entities-Routine-__construct.md b/docs/entities-Routine-__construct.md new file mode 100644 index 0000000..7d09d60 --- /dev/null +++ b/docs/entities-Routine-__construct.md @@ -0,0 +1,19 @@ +# [Entities](entities.md) / [Routine](entities-Routine.md) :: __construct + > im\debug\entities\Routine +____ + +## Description +Construct a new Routine + +## Synopsis +```php +public __construct(im\debug\entities\Name $name, im\debug\entities\Type $type, int $flags = im\debug\entities\Member::T_PUBLIC, array $params = Array) +``` + +## Parameters +| Name | Description | +| :--- | :---------- | +| name | The name of the routine | +| type | The routine return type | +| flags | Routine flags | +| params | Routine parameters | diff --git a/docs/entities-Routine-addClass.md b/docs/entities-Routine-addClass.md new file mode 100644 index 0000000..c134801 --- /dev/null +++ b/docs/entities-Routine-addClass.md @@ -0,0 +1,16 @@ +# [Entities](entities.md) / [Routine](entities-Routine.md) :: addClass + > im\debug\entities\Routine +____ + +## Description +Add an anonymous class + +## Synopsis +```php +public addClass(im\debug\entities\Clazz $class): void +``` + +## Parameters +| Name | Description | +| :--- | :---------- | +| class | The class to add | diff --git a/docs/entities-Routine-addFunction.md b/docs/entities-Routine-addFunction.md new file mode 100644 index 0000000..3f4daaf --- /dev/null +++ b/docs/entities-Routine-addFunction.md @@ -0,0 +1,16 @@ +# [Entities](entities.md) / [Routine](entities-Routine.md) :: addFunction + > im\debug\entities\Routine +____ + +## Description +Add a closure + +## Synopsis +```php +public addFunction(im\debug\entities\Routine $func): void +``` + +## Parameters +| Name | Description | +| :--- | :---------- | +| func | The closure to add | diff --git a/docs/entities-Routine-getArgument.md b/docs/entities-Routine-getArgument.md new file mode 100644 index 0000000..6304486 --- /dev/null +++ b/docs/entities-Routine-getArgument.md @@ -0,0 +1,16 @@ +# [Entities](entities.md) / [Routine](entities-Routine.md) :: getArgument + > im\debug\entities\Routine +____ + +## Description +Get a specified argument + +## Synopsis +```php +public getArgument(string $name): null|im\debug\entities\Argument +``` + +## Parameters +| Name | Description | +| :--- | :---------- | +| name | Name of the argument | diff --git a/docs/entities-Routine-getClasses.md b/docs/entities-Routine-getClasses.md new file mode 100644 index 0000000..c8786cf --- /dev/null +++ b/docs/entities-Routine-getClasses.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Routine](entities-Routine.md) :: getClasses + > im\debug\entities\Routine +____ + +## Description +Return all of the anonymous classes within this routine + +## Synopsis +```php +public getClasses(): array +``` diff --git a/docs/entities-Routine-getFunctions.md b/docs/entities-Routine-getFunctions.md new file mode 100644 index 0000000..82fa3fe --- /dev/null +++ b/docs/entities-Routine-getFunctions.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Routine](entities-Routine.md) :: getFunctions + > im\debug\entities\Routine +____ + +## Description +Return all of the closures within this routine + +## Synopsis +```php +public getFunctions(): array +``` diff --git a/docs/entities-Routine-getIterator.md b/docs/entities-Routine-getIterator.md new file mode 100644 index 0000000..7e112dc --- /dev/null +++ b/docs/entities-Routine-getIterator.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Routine](entities-Routine.md) :: getIterator + > im\debug\entities\Routine +____ + +## Description +Provides a Traversable to iterate through all arguments + +## Synopsis +```php +public getIterator(): Traversable +``` diff --git a/docs/entities-Routine-getName.md b/docs/entities-Routine-getName.md new file mode 100644 index 0000000..b32ea65 --- /dev/null +++ b/docs/entities-Routine-getName.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Routine](entities-Routine.md) :: getName + > im\debug\entities\Routine +____ + +## Description +Get the name of this member + +## Synopsis +```php +public getName(): im\debug\entities\Name +``` diff --git a/docs/entities-Routine-getType.md b/docs/entities-Routine-getType.md new file mode 100644 index 0000000..d432fd6 --- /dev/null +++ b/docs/entities-Routine-getType.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Routine](entities-Routine.md) :: getType + > im\debug\entities\Routine +____ + +## Description +Get the type of this member + +## Synopsis +```php +public getType(): im\debug\entities\Type +``` diff --git a/docs/entities-Routine-isAbstract.md b/docs/entities-Routine-isAbstract.md new file mode 100644 index 0000000..9025be1 --- /dev/null +++ b/docs/entities-Routine-isAbstract.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Routine](entities-Routine.md) :: isAbstract + > im\debug\entities\Routine +____ + +## Description +Whether this member is abstract + +## Synopsis +```php +public isAbstract(): bool +``` diff --git a/docs/entities-Routine-isAnonymous.md b/docs/entities-Routine-isAnonymous.md new file mode 100644 index 0000000..f837fe2 --- /dev/null +++ b/docs/entities-Routine-isAnonymous.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Routine](entities-Routine.md) :: isAnonymous + > im\debug\entities\Routine +____ + +## Description +Whether this member is anonymous + +## Synopsis +```php +public isAnonymous(): bool +``` diff --git a/docs/entities-Routine-isByRef.md b/docs/entities-Routine-isByRef.md new file mode 100644 index 0000000..1ad7a16 --- /dev/null +++ b/docs/entities-Routine-isByRef.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Routine](entities-Routine.md) :: isByRef + > im\debug\entities\Routine +____ + +## Description +Whether this routine returns by reference + +## Synopsis +```php +public isByRef(): bool +``` diff --git a/docs/entities-Routine-isFinal.md b/docs/entities-Routine-isFinal.md new file mode 100644 index 0000000..32ce4ea --- /dev/null +++ b/docs/entities-Routine-isFinal.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Routine](entities-Routine.md) :: isFinal + > im\debug\entities\Routine +____ + +## Description +Whether this member is final + +## Synopsis +```php +public isFinal(): bool +``` diff --git a/docs/entities-Routine-isPrivate.md b/docs/entities-Routine-isPrivate.md new file mode 100644 index 0000000..d525ccc --- /dev/null +++ b/docs/entities-Routine-isPrivate.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Routine](entities-Routine.md) :: isPrivate + > im\debug\entities\Routine +____ + +## Description +Whether this member is private + +## Synopsis +```php +public isPrivate(): bool +``` diff --git a/docs/entities-Routine-isProtected.md b/docs/entities-Routine-isProtected.md new file mode 100644 index 0000000..c1a664a --- /dev/null +++ b/docs/entities-Routine-isProtected.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Routine](entities-Routine.md) :: isProtected + > im\debug\entities\Routine +____ + +## Description +Whether this member is protected + +## Synopsis +```php +public isProtected(): bool +``` diff --git a/docs/entities-Routine-isPublic.md b/docs/entities-Routine-isPublic.md new file mode 100644 index 0000000..4e8f225 --- /dev/null +++ b/docs/entities-Routine-isPublic.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Routine](entities-Routine.md) :: isPublic + > im\debug\entities\Routine +____ + +## Description +Whether this member is public + +## Synopsis +```php +public isPublic(): bool +``` diff --git a/docs/entities-Routine-isStatic.md b/docs/entities-Routine-isStatic.md new file mode 100644 index 0000000..6dae0e3 --- /dev/null +++ b/docs/entities-Routine-isStatic.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Routine](entities-Routine.md) :: isStatic + > im\debug\entities\Routine +____ + +## Description +Whether this member is static + +## Synopsis +```php +public isStatic(): bool +``` diff --git a/docs/entities-Routine-prop_T_ABSTRACT.md b/docs/entities-Routine-prop_T_ABSTRACT.md new file mode 100644 index 0000000..d999d13 --- /dev/null +++ b/docs/entities-Routine-prop_T_ABSTRACT.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Routine](entities-Routine.md) :: T_ABSTRACT + > im\debug\entities\Routine +____ + +## Description +This is an abstract member + +## Synopsis +```php +public T_ABSTRACT = 512 +``` diff --git a/docs/entities-Routine-prop_T_ANONYMOUS.md b/docs/entities-Routine-prop_T_ANONYMOUS.md new file mode 100644 index 0000000..150867a --- /dev/null +++ b/docs/entities-Routine-prop_T_ANONYMOUS.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Routine](entities-Routine.md) :: T_ANONYMOUS + > im\debug\entities\Routine +____ + +## Description +This is anonymous member + +## Synopsis +```php +public T_ANONYMOUS = 4096 +``` diff --git a/docs/entities-Routine-prop_T_BYREF.md b/docs/entities-Routine-prop_T_BYREF.md new file mode 100644 index 0000000..f1f1439 --- /dev/null +++ b/docs/entities-Routine-prop_T_BYREF.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Routine](entities-Routine.md) :: T_BYREF + > im\debug\entities\Routine +____ + +## Description +This is a byref function return + +## Synopsis +```php +public T_BYREF = 32 +``` diff --git a/docs/entities-Routine-prop_T_FINAL.md b/docs/entities-Routine-prop_T_FINAL.md new file mode 100644 index 0000000..505f5b0 --- /dev/null +++ b/docs/entities-Routine-prop_T_FINAL.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Routine](entities-Routine.md) :: T_FINAL + > im\debug\entities\Routine +____ + +## Description +This is a final member + +## Synopsis +```php +public T_FINAL = 256 +``` diff --git a/docs/entities-Routine-prop_T_META.md b/docs/entities-Routine-prop_T_META.md new file mode 100644 index 0000000..fd74ce8 --- /dev/null +++ b/docs/entities-Routine-prop_T_META.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Routine](entities-Routine.md) :: T_META + > im\debug\entities\Routine +____ + +## Description +Meta that defines all member modifier flags + +## Synopsis +```php +public T_META = 1048320 +``` diff --git a/docs/entities-Routine-prop_T_PRIVATE.md b/docs/entities-Routine-prop_T_PRIVATE.md new file mode 100644 index 0000000..3ef8b71 --- /dev/null +++ b/docs/entities-Routine-prop_T_PRIVATE.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Routine](entities-Routine.md) :: T_PRIVATE + > im\debug\entities\Routine +____ + +## Description +This is a private member + +## Synopsis +```php +public T_PRIVATE = 32768 +``` diff --git a/docs/entities-Routine-prop_T_PROTECTED.md b/docs/entities-Routine-prop_T_PROTECTED.md new file mode 100644 index 0000000..f427acd --- /dev/null +++ b/docs/entities-Routine-prop_T_PROTECTED.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Routine](entities-Routine.md) :: T_PROTECTED + > im\debug\entities\Routine +____ + +## Description +This is a protected member + +## Synopsis +```php +public T_PROTECTED = 16384 +``` diff --git a/docs/entities-Routine-prop_T_PUBLIC.md b/docs/entities-Routine-prop_T_PUBLIC.md new file mode 100644 index 0000000..ce2b9ca --- /dev/null +++ b/docs/entities-Routine-prop_T_PUBLIC.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Routine](entities-Routine.md) :: T_PUBLIC + > im\debug\entities\Routine +____ + +## Description +This is a public member + +## Synopsis +```php +public T_PUBLIC = 8192 +``` diff --git a/docs/entities-Routine-prop_T_STATIC.md b/docs/entities-Routine-prop_T_STATIC.md new file mode 100644 index 0000000..4e40983 --- /dev/null +++ b/docs/entities-Routine-prop_T_STATIC.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Routine](entities-Routine.md) :: T_STATIC + > im\debug\entities\Routine +____ + +## Description +This is a static member + +## Synopsis +```php +public T_STATIC = 1024 +``` diff --git a/docs/entities-Routine-var_line.md b/docs/entities-Routine-var_line.md new file mode 100644 index 0000000..1f914ec --- /dev/null +++ b/docs/entities-Routine-var_line.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Routine](entities-Routine.md) :: $line + > im\debug\entities\Routine +____ + +## Description +The line number of where this entity begins + +## Synopsis +```php +public int $line = -1 +``` diff --git a/docs/entities-Routine-var_pos.md b/docs/entities-Routine-var_pos.md new file mode 100644 index 0000000..731eb1e --- /dev/null +++ b/docs/entities-Routine-var_pos.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Routine](entities-Routine.md) :: $pos + > im\debug\entities\Routine +____ + +## Description +The position of where this entity begins + +## Synopsis +```php +public int $pos = -1 +``` diff --git a/docs/entities-Routine.md b/docs/entities-Routine.md new file mode 100644 index 0000000..e8ef1b9 --- /dev/null +++ b/docs/entities-Routine.md @@ -0,0 +1,93 @@ +# [Debug](debug.md) / [Entities](entities.md) / Routine + > im\debug\entities\Routine +____ + +## Description +Defines a Routine (function) + +This can be anything from a closure to a class method +or a regular function. + +## Synopsis +```php +class Routine extends im\debug\entities\Member implements Stringable, IteratorAggregate, Traversable { + + // Constants + public T_BYREF = 32 + public T_ABSTRACT = 512 + public T_ANONYMOUS = 4096 + + // Inherited Constants + public T_PUBLIC = 8192 + public T_PROTECTED = 16384 + public T_PRIVATE = 32768 + public T_STATIC = 1024 + public T_FINAL = 256 + public T_META = 1048320 + + // Inherited Properties + public int $line = -1 + public int $pos = -1 + + // Methods + public __construct(im\debug\entities\Name $name, im\debug\entities\Type $type, int $flags = im\debug\entities\Member::T_PUBLIC, array $params = Array) + public isByRef(): bool + public isAbstract(): bool + public isAnonymous(): bool + public getArgument(string $name): null|im\debug\entities\Argument + public getIterator(): Traversable + public addClass(im\debug\entities\Clazz $class): void + public getClasses(): array + public addFunction(im\debug\entities\Routine $func): void + public getFunctions(): array + + // Inherited Methods + public getType(): im\debug\entities\Type + public getName(): im\debug\entities\Name + public isPublic(): bool + public isProtected(): bool + public isPrivate(): bool + public isStatic(): bool + public isFinal(): bool +} +``` + +## Constants +| Name | Description | +| :--- | :---------- | +| [__Routine :: T\_BYREF__](entities-Routine-prop_T_BYREF.md) | This is a byref function return | +| [__Routine :: T\_ABSTRACT__](entities-Routine-prop_T_ABSTRACT.md) | This is an abstract member | +| [__Routine :: T\_ANONYMOUS__](entities-Routine-prop_T_ANONYMOUS.md) | This is anonymous member | +| [__Routine :: T\_PUBLIC__](entities-Routine-prop_T_PUBLIC.md) | This is a public member | +| [__Routine :: T\_PROTECTED__](entities-Routine-prop_T_PROTECTED.md) | This is a protected member | +| [__Routine :: T\_PRIVATE__](entities-Routine-prop_T_PRIVATE.md) | This is a private member | +| [__Routine :: T\_STATIC__](entities-Routine-prop_T_STATIC.md) | This is a static member | +| [__Routine :: T\_FINAL__](entities-Routine-prop_T_FINAL.md) | This is a final member | +| [__Routine :: T\_META__](entities-Routine-prop_T_META.md) | Meta that defines all member modifier flags | + +## Properties +| Name | Description | +| :--- | :---------- | +| [__Routine :: $line__](entities-Routine-var_line.md) | The line number of where this entity begins | +| [__Routine :: $pos__](entities-Routine-var_pos.md) | The position of where this entity begins | + +## Methods +| Name | Description | +| :--- | :---------- | +| [__Routine :: \_\_construct__](entities-Routine-__construct.md) | Construct a new Routine | +| [__Routine :: isByRef__](entities-Routine-isByRef.md) | Whether this routine returns by reference | +| [__Routine :: isAbstract__](entities-Routine-isAbstract.md) | Whether this member is abstract | +| [__Routine :: isAnonymous__](entities-Routine-isAnonymous.md) | Whether this member is anonymous | +| [__Routine :: getArgument__](entities-Routine-getArgument.md) | Get a specified argument | +| [__Routine :: getIterator__](entities-Routine-getIterator.md) | Provides a Traversable to iterate through all arguments | +| [__Routine :: addClass__](entities-Routine-addClass.md) | Add an anonymous class | +| [__Routine :: getClasses__](entities-Routine-getClasses.md) | Return all of the anonymous classes within this routine | +| [__Routine :: addFunction__](entities-Routine-addFunction.md) | Add a closure | +| [__Routine :: getFunctions__](entities-Routine-getFunctions.md) | Return all of the closures within this routine | +| [__Routine :: getType__](entities-Routine-getType.md) | Get the type of this member | +| [__Routine :: getName__](entities-Routine-getName.md) | Get the name of this member | +| [__Routine :: isPublic__](entities-Routine-isPublic.md) | Whether this member is public | +| [__Routine :: isProtected__](entities-Routine-isProtected.md) | Whether this member is protected | +| [__Routine :: isPrivate__](entities-Routine-isPrivate.md) | Whether this member is private | +| [__Routine :: isStatic__](entities-Routine-isStatic.md) | Whether this member is static | +| [__Routine :: isFinal__](entities-Routine-isFinal.md) | Whether this member is final | diff --git a/docs/entities-Type-__construct.md b/docs/entities-Type-__construct.md new file mode 100644 index 0000000..035e856 --- /dev/null +++ b/docs/entities-Type-__construct.md @@ -0,0 +1,18 @@ +# [Entities](entities.md) / [Type](entities-Type.md) :: __construct + > im\debug\entities\Type +____ + +## Description +Construct a new Name + +## Synopsis +```php +public __construct(string $path, null|string $alias = NULL, bool $native = FALSE) +``` + +## Parameters +| Name | Description | +| :--- | :---------- | +| path | Complete name path, including possible namespace | +| alias | An alias for this name | +| native | Whether this type is a native type | diff --git a/docs/entities-Type-getLabel.md b/docs/entities-Type-getLabel.md new file mode 100644 index 0000000..6f57226 --- /dev/null +++ b/docs/entities-Type-getLabel.md @@ -0,0 +1,15 @@ +# [Entities](entities.md) / [Type](entities-Type.md) :: getLabel + > im\debug\entities\Type +____ + +## Description +Get the label for this name + +This returns a basename without any namespace part. +If an alias is defined, this is what get's returned. +Otherwise it will return the name, with namespace stripped. + +## Synopsis +```php +public getLabel(): string +``` diff --git a/docs/entities-Type-getName.md b/docs/entities-Type-getName.md new file mode 100644 index 0000000..9fa4e34 --- /dev/null +++ b/docs/entities-Type-getName.md @@ -0,0 +1,14 @@ +# [Entities](entities.md) / [Type](entities-Type.md) :: getName + > im\debug\entities\Type +____ + +## Description +Get the string representation of this name path + +This will always return the complete named path +with any namespace. + +## Synopsis +```php +public getName(): string +``` diff --git a/docs/entities-Type-getNamespace.md b/docs/entities-Type-getNamespace.md new file mode 100644 index 0000000..0d7f63f --- /dev/null +++ b/docs/entities-Type-getNamespace.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Type](entities-Type.md) :: getNamespace + > im\debug\entities\Type +____ + +## Description +Get the namespace of this name path + +## Synopsis +```php +public getNamespace(): null|string +``` diff --git a/docs/entities-Type-isNative.md b/docs/entities-Type-isNative.md new file mode 100644 index 0000000..575c6b1 --- /dev/null +++ b/docs/entities-Type-isNative.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Type](entities-Type.md) :: isNative + > im\debug\entities\Type +____ + +## Description +Whether this type is a native type + +## Synopsis +```php +public isNative(): bool +``` diff --git a/docs/entities-Type-var_line.md b/docs/entities-Type-var_line.md new file mode 100644 index 0000000..5b64e14 --- /dev/null +++ b/docs/entities-Type-var_line.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Type](entities-Type.md) :: $line + > im\debug\entities\Type +____ + +## Description +The line number of where this entity begins + +## Synopsis +```php +public int $line = -1 +``` diff --git a/docs/entities-Type-var_pos.md b/docs/entities-Type-var_pos.md new file mode 100644 index 0000000..bf603a3 --- /dev/null +++ b/docs/entities-Type-var_pos.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [Type](entities-Type.md) :: $pos + > im\debug\entities\Type +____ + +## Description +The position of where this entity begins + +## Synopsis +```php +public int $pos = -1 +``` diff --git a/docs/entities-Type.md b/docs/entities-Type.md new file mode 100644 index 0000000..4e2e542 --- /dev/null +++ b/docs/entities-Type.md @@ -0,0 +1,43 @@ +# [Debug](debug.md) / [Entities](entities.md) / Type + > im\debug\entities\Type +____ + +## Description +Defines a type + +This is an extension to `im\debug\entities\Name` +which also supports native (builtin) types. + +## Synopsis +```php +class Type extends im\debug\entities\Name implements Stringable { + + // Inherited Properties + public int $line = -1 + public int $pos = -1 + + // Methods + public __construct(string $path, null|string $alias = NULL, bool $native = FALSE) + public isNative(): bool + + // Inherited Methods + public getLabel(): string + public getName(): string + public getNamespace(): null|string +} +``` + +## Properties +| Name | Description | +| :--- | :---------- | +| [__Type :: $line__](entities-Type-var_line.md) | The line number of where this entity begins | +| [__Type :: $pos__](entities-Type-var_pos.md) | The position of where this entity begins | + +## Methods +| Name | Description | +| :--- | :---------- | +| [__Type :: \_\_construct__](entities-Type-__construct.md) | Construct a new Name | +| [__Type :: isNative__](entities-Type-isNative.md) | Whether this type is a native type | +| [__Type :: getLabel__](entities-Type-getLabel.md) | Get the label for this name This returns a basename without any namespace part | +| [__Type :: getName__](entities-Type-getName.md) | Get the string representation of this name path This will always return the complete named path with any namespace | +| [__Type :: getNamespace__](entities-Type-getNamespace.md) | Get the namespace of this name path | diff --git a/docs/entities-UnionType-__construct.md b/docs/entities-UnionType-__construct.md new file mode 100644 index 0000000..220c7ff --- /dev/null +++ b/docs/entities-UnionType-__construct.md @@ -0,0 +1,16 @@ +# [Entities](entities.md) / [UnionType](entities-UnionType.md) :: __construct + > im\debug\entities\UnionType +____ + +## Description +Construct a new UnionType + +## Synopsis +```php +public __construct(im\debug\entities\Type ...$types) +``` + +## Parameters +| Name | Description | +| :--- | :---------- | +| types | Types to add to this union | diff --git a/docs/entities-UnionType-getIterator.md b/docs/entities-UnionType-getIterator.md new file mode 100644 index 0000000..3471dd1 --- /dev/null +++ b/docs/entities-UnionType-getIterator.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [UnionType](entities-UnionType.md) :: getIterator + > im\debug\entities\UnionType +____ + +## Description +Provides a Traversable to iterate through the types within + +## Synopsis +```php +public getIterator(): Traversable +``` diff --git a/docs/entities-UnionType-getLabel.md b/docs/entities-UnionType-getLabel.md new file mode 100644 index 0000000..8eb0b48 --- /dev/null +++ b/docs/entities-UnionType-getLabel.md @@ -0,0 +1,15 @@ +# [Entities](entities.md) / [UnionType](entities-UnionType.md) :: getLabel + > im\debug\entities\UnionType +____ + +## Description +Get the label for this name + +This returns a basename without any namespace part. +If an alias is defined, this is what get's returned. +Otherwise it will return the name, with namespace stripped. + +## Synopsis +```php +public getLabel(): string +``` diff --git a/docs/entities-UnionType-getName.md b/docs/entities-UnionType-getName.md new file mode 100644 index 0000000..dad0d76 --- /dev/null +++ b/docs/entities-UnionType-getName.md @@ -0,0 +1,14 @@ +# [Entities](entities.md) / [UnionType](entities-UnionType.md) :: getName + > im\debug\entities\UnionType +____ + +## Description +Get the string representation of this name path + +This will always return the complete named path +with any namespace. + +## Synopsis +```php +public getName(): string +``` diff --git a/docs/entities-UnionType-getNamespace.md b/docs/entities-UnionType-getNamespace.md new file mode 100644 index 0000000..4341233 --- /dev/null +++ b/docs/entities-UnionType-getNamespace.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [UnionType](entities-UnionType.md) :: getNamespace + > im\debug\entities\UnionType +____ + +## Description +Get the namespace of this name path + +## Synopsis +```php +public getNamespace(): null|string +``` diff --git a/docs/entities-UnionType-hasNative.md b/docs/entities-UnionType-hasNative.md new file mode 100644 index 0000000..90d59ea --- /dev/null +++ b/docs/entities-UnionType-hasNative.md @@ -0,0 +1,17 @@ +# [Entities](entities.md) / [UnionType](entities-UnionType.md) :: hasNative + > im\debug\entities\UnionType +____ + +## Description +Check to see if a specific or any native types exists +within this union + +## Synopsis +```php +public hasNative(null|string $type = NULL): bool +``` + +## Parameters +| Name | Description | +| :--- | :---------- | +| type | Optional native type to check for.
If this is not provided, any native type will return `TRUE` | diff --git a/docs/entities-UnionType-hasNativeNull.md b/docs/entities-UnionType-hasNativeNull.md new file mode 100644 index 0000000..7646061 --- /dev/null +++ b/docs/entities-UnionType-hasNativeNull.md @@ -0,0 +1,13 @@ +# [Entities](entities.md) / [UnionType](entities-UnionType.md) :: hasNativeNull + > im\debug\entities\UnionType +____ + +## Description +Check to see if this union is nullable + + > This is the same as `hasNative("null")` + +## Synopsis +```php +public hasNativeNull(): bool +``` diff --git a/docs/entities-UnionType-isNative.md b/docs/entities-UnionType-isNative.md new file mode 100644 index 0000000..9bc94c6 --- /dev/null +++ b/docs/entities-UnionType-isNative.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [UnionType](entities-UnionType.md) :: isNative + > im\debug\entities\UnionType +____ + +## Description +Whether this type is a native type + +## Synopsis +```php +public isNative(): bool +``` diff --git a/docs/entities-UnionType-var_line.md b/docs/entities-UnionType-var_line.md new file mode 100644 index 0000000..e0cad5d --- /dev/null +++ b/docs/entities-UnionType-var_line.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [UnionType](entities-UnionType.md) :: $line + > im\debug\entities\UnionType +____ + +## Description +The line number of where this entity begins + +## Synopsis +```php +public int $line = -1 +``` diff --git a/docs/entities-UnionType-var_pos.md b/docs/entities-UnionType-var_pos.md new file mode 100644 index 0000000..120f1b3 --- /dev/null +++ b/docs/entities-UnionType-var_pos.md @@ -0,0 +1,11 @@ +# [Entities](entities.md) / [UnionType](entities-UnionType.md) :: $pos + > im\debug\entities\UnionType +____ + +## Description +The position of where this entity begins + +## Synopsis +```php +public int $pos = -1 +``` diff --git a/docs/entities-UnionType.md b/docs/entities-UnionType.md new file mode 100644 index 0000000..88b7e6a --- /dev/null +++ b/docs/entities-UnionType.md @@ -0,0 +1,46 @@ +# [Debug](debug.md) / [Entities](entities.md) / UnionType + > im\debug\entities\UnionType +____ + +## Description +Defines a Type container for use with union types + +## Synopsis +```php +class UnionType extends im\debug\entities\Type implements Stringable, IteratorAggregate, Traversable { + + // Inherited Properties + public int $line = -1 + public int $pos = -1 + + // Methods + public __construct(im\debug\entities\Type ...$types) + public hasNative(null|string $type = NULL): bool + public hasNativeNull(): bool + public getIterator(): Traversable + + // Inherited Methods + public isNative(): bool + public getLabel(): string + public getName(): string + public getNamespace(): null|string +} +``` + +## Properties +| Name | Description | +| :--- | :---------- | +| [__UnionType :: $line__](entities-UnionType-var_line.md) | The line number of where this entity begins | +| [__UnionType :: $pos__](entities-UnionType-var_pos.md) | The position of where this entity begins | + +## Methods +| Name | Description | +| :--- | :---------- | +| [__UnionType :: \_\_construct__](entities-UnionType-__construct.md) | Construct a new UnionType | +| [__UnionType :: hasNative__](entities-UnionType-hasNative.md) | Check to see if a specific or any native types exists | +| [__UnionType :: hasNativeNull__](entities-UnionType-hasNativeNull.md) | Check to see if this union is nullable | +| [__UnionType :: getIterator__](entities-UnionType-getIterator.md) | Provides a Traversable to iterate through the types within | +| [__UnionType :: isNative__](entities-UnionType-isNative.md) | Whether this type is a native type | +| [__UnionType :: getLabel__](entities-UnionType-getLabel.md) | Get the label for this name This returns a basename without any namespace part | +| [__UnionType :: getName__](entities-UnionType-getName.md) | Get the string representation of this name path This will always return the complete named path with any namespace | +| [__UnionType :: getNamespace__](entities-UnionType-getNamespace.md) | Get the namespace of this name path | diff --git a/docs/entities.md b/docs/entities.md new file mode 100644 index 0000000..d49431f --- /dev/null +++ b/docs/entities.md @@ -0,0 +1,25 @@ +# [Debug](debug.md) / Entities +____ + +## Description +Reflection-like package for debugging purposes. + +## Interfaces +| Name | Description | +| :--- | :---------- | +| [Document](entities-Document.md) | Defines a document (global scope) of a php file | + +## Classes +| Name | Description | +| :--- | :---------- | +| [Argument](entities-Argument.md) | Defines a function argument | +| [Clazz](entities-Clazz.md) | Defines a Class _(class, interface, trait or interface)_ | +| [Entity](entities-Entity.md) | Defines an Entity This interface is shared across all entities like Argument, Clazz, Routine, Name, Type and more | +| [Import](entities-Import.md) | Defines an import Imports are references added to a document like `use namespace\MyClass as MyAlias` | +| [IntersectType](entities-IntersectType.md) | Defines a Type container for use with intersection types | +| [Member](entities-Member.md) | Defines a class member This is used for things like a method, property, enum case etc | +| [Name](entities-Name.md) | Defines a name with support for alias and namespace | +| [Property](entities-Property.md) | Defines a property This can be class variable or constant as well as a global constant | +| [Routine](entities-Routine.md) | Defines a Routine (function) This can be anything from a closure to a class method or a regular function | +| [Type](entities-Type.md) | Defines a type This is an extension to `im\debug\entities\Name` which also supports native (builtin) types | +| [UnionType](entities-UnionType.md) | Defines a Type container for use with union types | diff --git a/src/debug/Debugger.php b/src/debug/Debugger.php new file mode 100755 index 0000000..f698d15 --- /dev/null +++ b/src/debug/Debugger.php @@ -0,0 +1,288 @@ +isDir()) { + // Directories are not class files + continue; + } + + $doc = new DocumentFile("$file"); + $classes = $doc->getClasses(); + $filePath = $fullPath ? $file->getPathName() : substr($file->getPathName(), strlen($path)+1); + + foreach ($classes as $class) { + if (!$class->isAnonymous()) { + $map["$class"] = $filePath; + } + } + } + + return $map; + } + + /** + * Add a source directory + * + * This will be used to resolve dependencies when doing things + * like `trialRun` and such. + * + * @param $path + * Directory path with additional dependencies + */ + public function addSourceTree(string $path): void { + $map = Debugger::compileClassMap($path, true); + + foreach ($map as $class => $file) { + $this->classmap[$class] = $file; + } + } + + /** + * Run a lint test and validate the code syntax. + * + * This is a lightweigth version of `trialRun()`. + * It's not gonna be as aggressive, but it will catch any + * syntax error in the file. + * + * @note + * This method does not require any additional source tree to work + * + * @param $file + * The file to check + */ + public function validateSyntax(string $file, bool $strict = false): bool { + if (!is_file($file)) { + throw new Exception("Failed to validate syntax, the file $file does not exist", Debugger::E_INTERNAL); + } + + $output = []; + $result = 0; + + exec("php -l '$file' 2>&1", $output, $result); + + if ($result != 0) { + $msg = trim(substr($output[0], strpos($output[0], ":")+1)); + + if (preg_match("/ in (?.+) on line (?[0-9]+)$/", $msg, $match)) { + $msg = preg_replace("/ in .+ on line [0-9]+$/", "", $msg); + $file = $match["file"]; + $line = (int) $match["line"]; + + throw new ErrorException($msg, Debugger::E_ERROR, E_ERROR, $file, $line); + } + + throw new Exception(implode("\n", $output), Debugger::E_ERROR); + + } else if ($strict) { + $doc = new DocumentFile($file, true); + + if (!$doc->isStrict()) { + throw new ErrorException("File does not declare strict types", Debugger::E_WARNING, E_WARNING, $file, 1); + } + } + + return true; + } + + /** + * Validate class imports + * + * This method will report any missing or unused imports. + * It checks all class references, resolved using the import information + * in the file, and looks it up in iether the produced source tree or among + * PHP's internal classes. + * + * It will also look at all the defined imports to see if they are actually + * being used within the file. + * + * @param $file + * The file to check + */ + public function validateImports(string $file): bool { + if (!is_file($file)) { + throw new Exception("Failed to validate imports, the file $file does not exist", Debugger::E_INTERNAL); + } + + $doc = new DocumentFile($file); + + if ($doc->hasOpenTag()) { + $refs = $doc->getReferences(); + + foreach ($refs as $ref) { + if (!isset($this->classmap["$ref"]) && !class_exists("$ref", true) && !interface_exists("$ref", true) && !trait_exists("$ref", true) && !enum_exists("$ref", true)) { + throw new ErrorException("Cannot locate class $ref", Debugger::E_ERROR, E_WARNING, $file, $ref->line); + } + } + + $imports = $doc->getImports(); + + foreach ($imports as $label => $import) { + if ($import->getType() == "class" && !isset($refs[$label])) { + throw new ErrorException("The import $import is never used", Debugger::E_WARNING, E_WARNING, $file, $import->line); + } + } + } + + return true; + } + + /** + * Run a file in a sandboxed process + * + * This will setup an autoloader using the source trees + * within this instance and run a script in a sub-process. + * + * If no error occure, the method will return the output + * as an array where each element represent a line of the output. + * + * @param $file + * The file to run + */ + public function trialRun(string $file): array { + if (!is_file($file)) { + throw new Exception("Failed to do a trial run, the file $file does not exist", Debugger::E_INTERNAL); + } + + $output = []; + $result = 0; + + exec("php -r '{$this->createBootstrap($file)}' 2>&1", $output, $result); + + if ($result != 0) { + foreach ($output as $line) { + $msg = trim(substr($line, strpos($line, ":")+1)); + + if (preg_match("/ in (?.+)(?:\:| on line )(?[0-9]+)$/", $msg, $match)) { + $msg = preg_replace("/ in .+(\:| on line )[0-9]+$/", "", $msg); + $file = $match["file"]; + $lineno = (int) $match["line"] ?? -1; + + throw new ErrorException($msg, Debugger::E_ERROR, E_ERROR, $file, $lineno); + } + } + + throw new Exception(implode("\n", $output), Debugger::E_ERROR); + } + + return $output; + } + + /** + * Create a bootstrap for trial runs + * + * @internal + */ + private function createBootstrap(string $file): string { + $bootstrap = "declare(strict_types=1);"; + $bootstrap .= "class __SPL_Callbacks {"; + $bootstrap .= "private static \$map = ["; + + foreach ($this->classmap as $class => $path) { + $bootstrap .= "\"".str_replace("\\", "\\\\", $class)."\" => \"{$path}\","; + } + + $bootstrap .= "];"; + $bootstrap .= "public static function class_autoload(\$class){"; + $bootstrap .= "if (isset(static::\$map[\$class])){"; + $bootstrap .= "require static::\$map[\$class];"; + $bootstrap .= "}}"; + $bootstrap .= "public static function error_handler(\$severity,\$message,\$file,\$line){"; + $bootstrap .= "throw new ErrorException(\$message,0,\$severity,\$file,\$line);"; + $bootstrap .= "}}"; + $bootstrap .= "spl_autoload_register([\"__SPL_Callbacks\", \"class_autoload\"]);"; + $bootstrap .= "set_error_handler([\"__SPL_Callbacks\", \"error_handler\"]);"; + $bootstrap .= "require \"$file\";"; + + return $bootstrap; + } +} diff --git a/src/debug/DocumentFile.php b/src/debug/DocumentFile.php new file mode 100755 index 0000000..76d3821 --- /dev/null +++ b/src/debug/DocumentFile.php @@ -0,0 +1,918 @@ + Import::class, ...] + + /** @ignore */ + protected array $classes = []; // ['label' => Clazz::class, ...] + + /** @ignore */ + protected array $routines = []; + + /** @ignore */ + protected array $consts = []; // ['label' => Property::class, ...] + + /** @ignore */ + protected array $references = []; // ['label' => Name::class, ...] + + /** + * Return an instance from a code string + * + * @param $code + * Code to process, incl. PHP open tags + */ + public static function fromCode(string $code): self { + $lexer = new Lexer($code, true); + $doc = new class() extends DocumentFile { + public function __construct() {} + }; + $doc->compile($lexer); + + return $doc; + } + + /** + * Return an instance from a code resource + * + * @param $stream + * A resource with code to process + */ + public static function fromResource(/*resource*/ $stream): self { + if (!is_resource($stream) || get_resource_type($stream) != "stream") { + throw new Exception("You must supply a valid resource of type 'stream'"); + } + + $lexer = new Lexer(stream_get_contents($stream), true); + $doc = new class() extends DocumentFile { + public function __construct() {} + }; + $doc->compile($lexer); + + return $doc; + } + + /** + * @internal + */ + public static function __static_construct() { + $types = [ + "self", "static", "parent", "class", // Non-real class words that can be seen as an object instantiation or static call + "string", "scalar", "int", "bool", "float", "array", // Current and possible future native declaration types + "number", "callable", "object", "resource", "numeric", + "void", "iterable", "mixed", "null" + ]; + + foreach ($types as $type) { + static::$TYPE_RESERVED[$type] = new Type($type, null, true); + } + } + + /** + * Create a new DocumentFile + * + * @param $file + * Path to a php file + * + * @param $onlyHeaders + * Only extract headers like openTag and define information + */ + public function __construct(string $file, bool $onlyHeaders = false) { + if (!is_file($file)) { + throw new Exception("The file '$file' does not exist"); + } + + $this->compile( + new Lexer(file_get_contents($file), true), + $onlyHeaders + ); + } + + /** + * @inheritDoc + */ + #[Override("im\debug\entities\Document")] + public function hasOpenTag(): bool { + return $this->hasOpenTag; + } + + /** + * @inheritDoc + */ + #[Override("im\debug\entities\Document")] + public function isStrict(): bool { + return $this->strict; + } + + /** + * @inheritDoc + */ + #[Override("im\debug\entities\Document")] + public function isDeclaredEncoding(): ?string { + return empty($this->encoding) ? null : $this->encoding; + } + + /** + * @inheritDoc + */ + #[Override("im\debug\entities\Document")] + public function getNamespace(): ?string { + return $this->namespace; + } + + /** + * Get a list of all class references + * + * A class reference is every single class access made. + * For an example accessing a static property or constant, + * creating a new class instance, implementing an interface, + * extending a base class etc. + * + * This method returns a list of all classes being used within + * this file. + */ + public function getReferences(): array { + /* + * TODO: + * Extend this to global constants and functions + */ + return $this->references; + } + + /** + * @internal + */ + public function addConstant(Property $prop): void { + $name = (string) $prop->getName(); + + if (!isset($this->consts[$name])) { + $this->consts[$name] = $prop; + + } else { + throw new Exception("Trying to re-add constant " . $prop); + } + } + + /** + * @inheritDoc + */ + #[Override("im\debug\entities\Document")] + public function getConstant(string $name): ?Property { + return $this->consts[$name] ?? null; + } + + /** + * @inheritDoc + */ + #[Override("im\debug\entities\Document")] + public function getConstants(): array { + return $this->consts; + } + + /** + * @inheritDoc + */ + #[Override("im\debug\entities\Document")] + public function getImport(string $name): ?Import { + return $this->imports[$name] ?? null; + } + + /** + * @inheritDoc + */ + #[Override("im\debug\entities\Document")] + public function getImports(): array { + return $this->imports; + } + + /** + * @internal + */ + public function addClass(Clazz $class): void { + $label = $class->getName()->getLabel(); + + if (!isset($this->classes[$label])) { + $this->classes[$label] = $class; + + } else { + throw new Exception("Trying to re-add inner class " . $class->getName()); + } + } + + /** + * @inheritDoc + */ + #[Override("im\debug\entities\Document")] + public function getClass(string $name): ?Clazz { + return $this->classes[$name] ?? null; + } + + /** + * @inheritDoc + */ + #[Override("im\debug\entities\Document")] + public function getClasses(): array { + return $this->classes; + } + + /** + * @internal + */ + public function addFunction(Routine $func): void { + $label = $func->getName()->getLabel(); + + if (!isset($this->routines[$label])) { + $this->routines[$label] = $func; + + } else { + throw new Exception("Trying to re-add function " . $func->getName()); + } + } + + /** + * @inheritDoc + */ + #[Override("im\debug\entities\Document")] + public function getFunction(string $label): ?Routine { + return $this->routines[$name] ?? null; + } + + /** + * @inheritDoc + */ + #[Override("im\debug\entities\Document")] + public function getFunctions(): array { + return $this->routines; + } + + /** + * @internal + */ + protected function randomId(): string { + $i = 2; + + while (true) { + $id = bin2hex(random_bytes($i)); + + /* Make sure we don't get conflict. + * We start with 2 bytes and move up if we + * encounter conflicts. + */ + if (!isset(static::$RADOM_IDS[$id])) { + static::$RADOM_IDS[$id] = true; + return $id; + } + + $i++; + } + } + + /** + * @internal + */ + protected function resolvePathName(string $class, int $line = -1, int $pos = -1): Type { + if (!isset(static::$TYPE_RESERVED[$class])) { + switch (true) { + default: + if (strpos($class, "\\") !== false) { + $type = new Type(trim($class, "\\")); break; + } + + foreach ($this->imports as $import) { + if ($import->getLabel() == $class) { + $type = new Type($import->getName(), $class); break 2; + } + } + + if (!empty($this->namespace)) { + $type = new Type("{$this->namespace}\\{$class}"); break; + } + + $type = new Type($class); + } + + $this->references[ $type->getLabel() ] = $type; + + } else { + $type = clone static::$TYPE_RESERVED[$class]; + } + + $type->line = $line; + $type->pos = $pos; + + return $type; + } + + /** + * @internal + */ + protected function resolveType(string $type, int $line = -1, int $pos = -1): Type { + if ($type[0] == "?") { + return new UnionType( + $this->resolvePathName(substr($type, 1), $line, $pos), + $this->resolvePathName("null", $line, $pos) + ); + + } else if (strpos($type, "|") !== false) { + $types = []; + + foreach (explode("|", $type) as $type) { + $types[] = $this->resolvePathName($type, $line, $pos); + } + + $type = new UnionType(...$types); + $type->line = $line; + $type->pos = $pos; + + return $type; + + } else if (strpos($type, "&") !== false) { + $types = []; + + foreach (explode("&", $type) as $type) { + $types[] = $this->resolvePathName($type, $line, $pos); + } + + $type = new IntersectType(...$types); + $type->line = $line; + $type->pos = $pos; + + return $type; + + } else { + return $this->resolvePathName($type, $line, $pos); + } + } + + /** + * @internal + */ + protected function resolveModifierFlags(array|string $modifiers): int { + $flags = 0; + + if (is_string($modifiers)) { + $modifiers = [$modifiers]; + } + + foreach ($modifiers as $modifier) { + switch ($modifier) { + case "var": + case "public": $flags |= Member::T_PUBLIC; break; + case "protected": $flags |= Member::T_PROTECTED; break; + case "private": $flags |= Member::T_PRIVATE; break; + case "static": $flags |= Member::T_STATIC; break; + case "final": $flags |= Member::T_FINAL; break; + case "readonly": $flags |= Property::T_READONLY; break; + case "abstract": $flags |= Routine::T_ABSTRACT; break; + + /* A class constant is just a final property, although PHP treats them as different entities + */ + case "case": $flags |= (Member::T_FINAL|Member::T_STATIC|Property::T_READONLY|Property::T_CASE); break; + case "const": $flags |= (Member::T_FINAL|Member::T_STATIC|Property::T_READONLY); + } + } + + return $flags; + } + + /** + * @internal + */ + protected function getLeadingModifiers(Lexer $lexer): array { + $offset = $lexer->getOffset(); + $modifiers = []; + + while (($token = $lexer->getPrevious())->is(static::$MODIFIERS)) { + $modifiers[] = $token->text; + } + + $lexer->moveTo($offset); + + return array_reverse($modifiers); + } + + /** + * @internal + */ + protected function compile(Lexer $lexer, bool $headers = false): void { + $parents = [$this]; + $blocks = []; + $pending = null; + + /* + * Make sure that this has PHP code + */ + while ($lexer->moveTo(1, Lexer::OFFSET_CUR)) { + $token = $lexer->getCurrent(); + + if ($token->getTokenName() == "T_OPEN_TAG") { + $this->hasOpenTag = true; break; + } + } + + /* + * Only detect declare statements that affects the entire document + */ + if ($lexer->peakNext()->is(T_DECLARE)) { + while (!($token = $lexer->getNext())->is([";", "\0"])) { + switch ($token->getTokenName()) { + case "T_STRING": + if ($token->is("strict_types") && $lexer->getNext(T_LNUMBER)->is("1")) { + $this->strict = true; + + } else if ($token->is("encoding")) { + $this->encoding = $lexer->getNext(T_CONSTANT_ENCAPSED_STRING)->text; + } + } + } + } + + // Only extract headers + if ($headers || !$this->hasOpenTag) { + return; + } + + while (!($token = $lexer->getNext())->is("\0")) { + switch ($token->getTokenName()) { + case "{": + if ($pending !== null) { + $blocks[] = $pending; + $pending = null; + + } else { + $blocks[] = $token; + } + + break; + + case "}": + $block = array_pop($blocks); + + if (!empty($block) && !$block->is("{")) { + array_pop($parents); + } + + break; + + case ";": + if ($pending !== null) { + $pending = null; + } + + break; + + case "T_FUNCTION": + /* + * TODO: + * Add support for arrow functions + */ + + $pending = $token; + $byref = false; + $anon = false; + $typedef = null; + $flags = 0; + $args = []; + $modifiers = $this->getLeadingModifiers($lexer); + $parent = end($parents); + + if (!$lexer->getNextIf("&")->is("\0")) { + $byref = true; + } + + if (($subToken = $lexer->getNext())->is(T_STRING)) { // Anonymous functions would be '(' here + $name = $subToken->text; + + } else { + $name = "closure#{$this->randomId()}"; + $anon = true; + } + + if ($parent instanceof self) { + if (($ns = $parent->getNamespace()) != null) { + $name = new Name("{$ns}\\{$name}"); + + } else { + $name = new Name($name); + } + + } else { + $name = new Name("{$parent->getName()}::{$name}", $name); + } + + while (!($subToken = $lexer->getNextUnless([";", "{"]))->is("\0")) { + switch ($subToken->getTokenName()) { + case "T_PUBLIC": + case "T_PROTECTED": + case "T_PRIVATE": + case "T_READONLY": + if ($parent instanceof Clazz) { + $flags |= $this->resolveModifierFlags($subToken->text); + } + + break; + + case "&": + $flags |= Argument::T_BYREF; + + break; + + case "T_ELLIPSIS": + $flags |= Argument::T_VARIADIC; + + break; + + case "T_TYPEDEF": // This will at some point be the return type + $typedef = $subToken->text; + + break; + + case "T_PARAM": + $flags |= $lexer->peakNext()->is("=") ? Argument::T_OPTIONAL : 0; + + if (!empty($typedef)) { + $typedef = $this->resolveType($typedef, $token->line, $token->pos); + + } else { + $typedef = $this->resolveType("mixed", $token->line, $token->pos); + } + + if (($flags & Member::T_META) > 0) { + $pname = new Name("{$parent->getName()}::{$subToken->text}", $subToken->text); + $prop = new Property( + $pname, + $typedef, + $flags & Member::T_META + ); + + $prop->line = $token->line; + $prop->pos = $token->pos; + + $parent->addProperty($prop); + } + + $args[] = new Argument($subToken->text, $typedef, $flags & ~Member::T_META); + $typedef = null; + $flags = 0; + } + } + + if (!empty($typedef)) { + $typedef = $this->resolveType($typedef, $token->line, $token->pos); + + } else { + $typedef = $this->resolveType("mixed", $token->line, $token->pos); + } + + $flags = $this->resolveModifierFlags($modifiers); + + if ($byref) { + $flags |= Routine::T_BYREF; + } + + if ($anon) { + $flags |= Routine::T_ANONYMOUS; + } + + if ($parent instanceof Clazz && $parent->isInterface()) { + $flags |= Routine::T_ABSTRACT; + } + + $func = new Routine($name, $typedef, $flags, $args); + $func->line = $token->line; + $func->pos = $token->pos; + + if ($parent instanceof Clazz) { + $parent->addMethod($func); + + } else { + $parent->addFunction($func); + } + + $parents[] = $func; + + break; + + case "T_CLASSDEF": + $pending = $token; + $name = null; + $extends = null; + $implements = []; + $modifiers = $this->getLeadingModifiers($lexer); + $flags = $this->resolveModifierFlags($modifiers); + $flags |= Clazz::T_CLASS; + + if ($lexer->peakPrevious()->is(T_NEW) && $lexer->peakNext()->is("(")) { + // Skip arguments passed to anonymous class + while (!$lexer->getNext()->is(")")) {} + } + + while (!($subToken = $lexer->getNextUnless([";", "{"]))->is("\0")) { + switch (($tname = $subToken->getTokenName())) { + case "T_STRING": + $name = $subToken->text; + + break; + + case "T_IMPLEMENTS": + case "T_EXTENDS": + do { + $class = $this->resolvePathName($lexer->getNext()->text, $token->line, $token->pos); + + if ($tname == "T_IMPLEMENTS" || $token->text == "interface") { + $implements[] = $class; + + } else { + $extends = $class; + } + + } while (!($subToken = $lexer->getNextIf(","))->is("\0")); + } + } + + if (empty($name)) { + $name = "class#{$this->randomId()}"; + $flags |= Clazz::T_ANONYMOUS; + } + + if (!empty($this->namespace)) { + $name = "{$this->namespace}\\{$name}"; + } + + if ($token->text == "interface") { + $flags |= Clazz::T_INTERFACE; + + } else if ($token->text == "trait") { + $flags |= Clazz::T_TRAIT; + } + + $class = new Clazz(new Name($name), $flags, $extends, $implements); + $class->line = $token->line; + $class->pos = $token->pos; + + $parent = end($parents); + $parent->addClass($class); + + $parents[] = $class; + + break; + + case "T_NAMESPACE": + if ($this->namespace !== null) { + /* ClassFile represents a single namespace + * so we break out here. + */ + break 2; + } + + $this->namespace = $lexer->getNext()->text; + + break; + + case "T_USE": + if (count($blocks) == 0) { + $namespace = ""; + $alias = ""; + + while (!($subToken = $lexer->getNextUnless(";"))->is("\0")) { + switch ($subToken->getTokenName()) { + case "T_CONST": + case "T_FUNCTION": + $type = $subToken->text; // E.g. 'use ...' + + break; + + case "T_STRING": + $namespace = $subToken->text; + + break; + + case "T_AS": + $alias = $lexer->getNext(T_STRING)->text; + + break; + + case "{": + while (!($subToken = $lexer->getNextUnless("}"))->is("\0")) { + switch ($subToken->getTokenName()) { + case "T_STRING": + $subNamespace = $subToken->text; + $subAlias = null; + + if ($lexer->peakNext()->is(T_AS)) { + $subAlias = $lexer->getNext(T_STRING)->text; + } + + $import = new Import("{$namespace}\\{$subNamespace}", $subAlias, $type ?? null); + $import->line = $token->line; + $import->pos = $token->pos; + + $this->imports[ $import->getLabel() . ($type ?? null !== null ? ":{$type}" : "") ] = $import; + } + } + + $namespace = null; + + break; + } + } + + if (!empty($namespace)) { + $import = new Import($namespace, $alias, $type ?? null); + $import->line = $token->line; + $import->pos = $token->pos; + + $this->imports[ $import->getLabel() . ($type ?? null !== null ? ":{$type}" : "") ] = $import; + } + + } else { + $parent = end($parents); + + if ($parent instanceof Clazz) { + while (!($subToken = $lexer->getNextUnless(["{", ";"]))->is("\0")) { + switch ($subToken->getTokenName()) { + /* + * TODO: + * Add support for Conflict Resolution and Method Visibility + */ + case "T_STRING": + $parent->addTrait( + $this->resolvePathName($subToken->text, $token->line, $token->pos) + ); + } + } + } + } + + break; + + case "T_PROPERTY": + $typedef = "mixed"; + + if ($lexer->peakPrevious()->is(T_TYPEDEF)) { + $offset = $lexer->getOffset(); + $typedef = $lexer->getPrevious()->text; + $modifiers = $this->getLeadingModifiers($lexer); + $lexer->moveTo($offset); + + } else { + if ($lexer->peakPrevious()->is(T_CASE)) { + $typedef = "object"; + } + + $modifiers = $this->getLeadingModifiers($lexer); + } + + $flags = $this->resolveModifierFlags($modifiers); + $parent = end($parents); + $name = "{$parent->getName()}::{$token->text}"; + $label = $token->text; + + $prop = new Property( + new Name($name, $label), + $this->resolveType($typedef, $token->line, $token->pos), + $flags + ); + + $prop->line = $token->line; + $prop->pos = $token->pos; + + $parent->addProperty($prop); + + break; + + case "T_CONST": + $parent = end($parents); + + if ($parent instanceof self) { + $name = $lexer->getNext()->text; + $modifiers = $this->getLeadingModifiers($lexer); + $flags = $this->resolveModifierFlags($modifiers); + + if (($ns = $parent->getNamespace()) != null) { + $name = "{$ns}\\{$name}"; + } + + $prop = new Property( + new Name($name), + $this->resolveType("mixed", $token->line, $token->pos), + $flags + ); + + $prop->line = $token->line; + $prop->pos = $token->pos; + + $parent->addConstant($prop); + } + + break; + + /* + * Find remaining references. + * This is not a complex search, but will catch + * most if not all of the common stuff. + */ + case "T_INSTANCEOF": + case "T_CATCH": + case "T_NEW": + if (!($subToken = $lexer->peakNext(T_STRING, ["(", ";"]))->is("\0")) { + $this->resolvePathName($subToken->text, $token->line, $token->pos); + } + + break; + + case "T_DOUBLE_COLON": + if (($subToken = $lexer->peakPrevious())->is(T_STRING)) { + $this->resolvePathName($subToken->text, $token->line, $token->pos); + } + } + } + } +} + +DocumentFile::__static_construct(); diff --git a/src/debug/Lexer.php b/src/debug/Lexer.php new file mode 100755 index 0000000..779f572 --- /dev/null +++ b/src/debug/Lexer.php @@ -0,0 +1,776 @@ +tokens = PhpToken::tokenize($code); + $this->length = count($this->tokens); + $this->scan = $scan; + } + + /** + * Scan and modify the token array + * + * This method scans the tokens and modifies it. + * It provides compatibility between PHP version as well as + * fixing some of the inconsistencies that the token system has. + * + * @internal + */ + protected function scan(int $minOffset = -1): void { + if ($minOffset <= $this->scanned) { + return; + } + + $offset = $this->scanned; + $break = false; + + while (!$break && ($token = $this->tokens[++$offset] ?? null) !== null) { + if (!$token->isIgnorable()) { + switch ($tokenName = $token->getTokenName()) { + case "T_CLASS": + case "T_INTERFACE": + case "T_TRAIT": + case "T_ENUM": + if (($subToken = $this->tokens[$offset-1] ?? null) === null + || $subToken->getTokenName() != "T_DOUBLE_COLON") { + + /* + * Convert all class tokens like T_CLASS, T_TRAIT, T_ENUM and T_INTERFACE into T_CLASSDEF + */ + $this->tokens[$offset] = new class(T_CLASSDEF, $token->text, $token->line, $token->pos) extends PhpToken { + public function getTokenName(): ?string { + return "T_CLASSDEF"; + } + }; + + $this->pending = $this->tokens[$offset]; + } + + break; + + case "T_FN": + case "T_FUNCTION": + $this->pending = $token; + + break; + + case "T_CURLY_OPEN": + array_push($this->blocks, $token); + + break; + + case "}": + if (($block = end($this->blocks)) !== false && $block->is(T_CURLY_OPEN)) { + $this->tokens[$offset] = new class(T_CURLY_CLOSE, $token->text, $token->line, $token->pos) extends PhpToken { + public function getTokenName(): ?string { + return "T_CURLY_CLOSE"; + } + }; + } + + array_pop($this->blocks); + + break; + + case "{": + case ";": + case "T_DOUBLE_ARROW": + if ( + $tokenName != "T_DOUBLE_ARROW" || ($this->pending !== null && $this->pending->is(T_FN)) + ) { + $bypass = $this->pending !== null && $this->pending->is([T_FUNCTION, T_FN]); + + if ($tokenName != ";") { + if ($this->pending !== null) { + array_push($this->blocks, $this->pending); + + } else { + array_push($this->blocks, $token); + } + + } else { + while (($block = end($this->blocks)) !== false && $block->is(T_FN)) { + array_pop($this->blocks); + } + } + + $this->pending = null; + + if ($offset >= $minOffset) { + $break = true; + } + } + + if (!($bypass ?? false)) { + break; + } + + case "T_CONST": + case "T_VARIABLE": + case "T_CASE": + if ($token->is(T_VARIABLE)) { + $token->text = substr($token->text, 1); + } + + /* + * A pending block is the beginning of a definition block, + * like 'class ...' or 'function ...' before + * the beginning '{' block character. + * + * A block (not pending) is when we are within a block body like a class or function. + * It can also be an 'if' statement or similar, which is why we later check the block type. + */ + if ( + $bypass ?? false + || + ( + ($block = $this->pending) !== null && $block->is([T_FUNCTION, T_FN]) + ) + || + ( + ($block = end($this->blocks)) !== false && $block->is(T_CLASSDEF) + ) + ) { + $cur = $offset; + $addKind = []; + + if ($token->is(T_VARIABLE) && !$block->is(T_CLASSDEF)) { + /* + * Convert T_VARIABLE to T_PARAM in function argument + */ + $this->tokens[$cur] = new class(T_PARAM, $token->text, $token->line, $token->pos) extends PhpToken { + public function getTokenName(): ?string { + return "T_PARAM"; + } + }; + + /* + * Rewind the pointer to where the type definition may begin + */ + while (($token = $this->tokens[--$cur])->is(["...", "&"]) || $token->isIgnorable()) {} + + } else { + if ($bypass ?? false) { + /* + * We are currently extracting a function return type. + * A class method is allowed to return a 'static' type + */ + $addKind[] = T_STATIC; // Add additional return type + + } else { + /* + * Advance the pointer to where the actual property begins. + */ + if ($token->is([T_CONST, T_CASE])) { + while (($token = $this->tokens[++$cur])->isIgnorable()) {} // The actual property comes after + } + + /* + * Convert T_VARIABLE or T_STRING to T_PROPERTY in a class body + */ + $this->tokens[$cur] = new class(T_PROPERTY, $token->text, $token->line, $token->pos) extends PhpToken { + public function getTokenName(): ?string { + return "T_PROPERTY"; + } + }; + } + + /* + * Rewind the pointer to where the type definition may begin + */ + while (($token = $this->tokens[--$cur])->isIgnorable()) {} + } + + $this->convertTypeDefs($cur); + } + + break; + + case "T_NAME_RELATIVE": + case "T_NAME_QUALIFIED": + case "T_NAME_FULLY_QUALIFIED": + /* + *Since 'ClassName' uses T_STRING it makes no sense for 'namespace\ClassName' not to + */ + $this->tokens[$offset] = new PhpToken(T_STRING, $token->text, $token->line, $token->pos); + + break; + + case "T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG": + case "T_AMPERSAND_NOT_FOLLOWED_BY_VAR_OR_VARARG": + /* + * Fix compatibility break besteen PHP 8.0 and 8.1+ + */ + $this->tokens[$offset] = new class($token->id, $token->text, $token->line, $token->pos) extends PhpToken { + public function getTokenName(): ?string { + return "&"; + } + }; + + } + } + } + + $this->scanned = $offset; + } + + /** + * Extract type def information from functions and properties + * + * @internal + */ + private function convertTypeDefs(int $offset, array $addKind = []): void { + $token = $this->tokens[$offset]; + + if ($token->is(static::$DATATYPE_IDS) || $token->is($addKind)) { + $value = $token->text; + $line = $token->line; + $pos = $token->pos; + $ofs = $offset; + + /* + * Extract all the typedef tokens + */ + while (($token = $this->tokens[--$offset])->is(["|", "&"]) || $token->is($addKind) + || $token->is(static::$DATATYPE_IDS) || $token->isIgnorable()) { + + if (!$token->isIgnorable()) { + $value = $token->text . $value; + $this->tokens[$offset] = static::$T_IGNORE; + + /* Line and position should start at the beginning + * of the type definition and we are moving backwards + */ + $line = $token->line; + $pos = $token->pos; + } + } + + if ($this->tokens[$offset]->is("?")) { + $value = "?" . $value; + $this->tokens[$offset] = static::$T_IGNORE; + } + + /* + * Convert all of the typedef tokens into a single T_TYPEDEF + */ + $this->tokens[$ofs] = new class(T_TYPEDEF, $value, $line, $pos) extends PhpToken { + public function getTokenName(): ?string { + return "T_TYPEDEF"; + } + }; + } + } + + /** + * + */ + public function getIterator(): Traversable { + while (!($token = $this->getNext())->is("\0")) { + yield $token; + } + } + + /** + * To a raw move to a specific offset + * + * Unlike `moveToNext` and `moveToPrevious`, this method + * does not take ignorable tokens into consideration. + * It will simply move the pointer to the specified offset. + * + * This method works will when paired with `getOffset`. + * + * @param $offset + * The offset to move to + * + * @param $whence + * How to apply the offset, based on the `OFFSET_` constants + */ + public function moveTo(int $offset, int $whence = Lexer::OFFSET_SET): bool { + if ($whence != Lexer::OFFSET_SET) { + if ($whence == Lexer::OFFSET_END) { + $offset = $this->length + $offset; + + } else { + $offset = $this->offset + $offset; + } + + if ($offset < -1 || $offset > $this->length) { + return false; + } + + } else if ($offset > $this->length || $offset < -1) { + return false; + } + + $this->offset = $offset; + + if ($this->scan && $offset > $this->scanned) { + $this->scan($offset); + } + + return true; + } + + /** + * Move pointer to the next token, ignoring all ignorable tokens. + * + * @param $kind + * Keep moving until it reaches a token matching $kind. + * If EOF is reached, the pointer will not advance and `FALSE` is retured. + * + * @param $stopAt + * When defining $kind, this will define a different stop point rather than EOF. + * + * @return + * Returns `FALSE` on `EOF` or `TRUE` on success + */ + public function moveToNext(int|string|array|null $kind = null, int|string|array $stopAt = "\0"): bool { + $offset = $this->offset; + + do { + if ($this->scan && $offset >= $this->scanned) { + $this->scan($offset+1); + } + + if (($token = $this->tokens[++$offset] ?? null) !== null) { + if (!$token->isIgnorable() + && ($kind === null || $token->is($kind))) { + + $this->offset = $offset; + + return true; + } + } + + } while ($token !== null && !$token->is($stopAt)); + + return false; + } + + /** + * Move pointer to the previous token, ignoring all ignorable tokens. + * + * @param $kind + * Keep moving until it reaches a token matching $kind. + * If BOF is reached, the pointer will not advance and `FALSE` is retured. + * + * @param $stopAt + * When defining $kind, this will define a different stop point rather than EOF. + * + * @return + * Returns `FALSE` on `BOF` or `TRUE` on success + */ + public function moveToPrevious(int|string|array|null $kind = null, int|string|array $stopAt = "\0"): bool { + $offset = $this->offset; + + do { + if (($token = $this->tokens[--$offset] ?? null) !== null) { + if (!$token->isIgnorable() + && ($kind === null || $token->is($kind))) { + + $this->offset = $offset; + + return true; + } + } + + } while ($token !== null && !$token->is($stopAt)); + + return false; + } + + /** + * Get the current token being pointed to + */ + public function getCurrent(): PhpToken { + if (($token = $this->tokens[$this->offset] ?? null) === null) { + return static::$T_NULL; + } + + return $token; + } + + /** + * Advance the pointer and return the next token, ignoring all ignorable tokens. + * + * @note + * This is the same as calling `moveToNext` followed by `getCurrent`. + * + * @param $kind + * Keep moving until it reaches a token matching $kind. + * + * @param $stopAt + * When defining $kind, this will define a different stop point rather than EOF. + * + * @return + * Returns a `T_NULL` token on failure. + */ + public function getNext(int|string|array|null $kind = null, int|string|array $stopAt = "\0"): PhpToken { + if ($this->moveToNext($kind, $stopAt)) { + return $this->getCurrent(); + } + + return static::$T_NULL; + } + + /** + * Only advance the pointer and return the next token if it matches. + * + * This is the same as calling `getNext`, only it will only advance and + * return the token if it matches $kind. This is equal to combining + * `peakNext` with `getNext`. + * + * @param $kind + * Match to compare + * + * @return + * Returns a `T_NULL` token on mismatch. + */ + public function getNextIf(int|string|array $kind): PhpToken { + if ($this->peakNext()->is($kind)) { + return $this->getNext(); + } + + return static::$T_NULL; + } + + /** + * Only advance the pointer and return the next token if it does not match. + * + * This is the same as calling `getNext`, only it will only advance and + * return the token if it's a mismatch with $kind. + * + * @param $kind + * Match to compare + * + * @return + * Returns a `T_NULL` token on match. + */ + public function getNextUnless(int|string|array $kind): PhpToken { + if (!$this->peakNext()->is($kind)) { + return $this->getNext(); + } + + return static::$T_NULL; + } + + /** + * Return the next token without advancing the pointer, ignoring all ignorable tokens. + * + * @param $kind + * Keep moving until it reaches a token matching $kind. + * + * @param $stopAt + * When defining $kind, this will define a different stop point rather than EOF. + * + * @return + * Returns a `T_NULL` token on failure. + */ + public function peakNext(int|string|array|null $kind = null, int|string|array $stopAt = "\0"): PhpToken { + $token = static::$T_NULL; + $offset = $this->getOffset(); + + if ($this->moveToNext($kind, $stopAt)) { + $token = $this->getCurrent(); + } + + $this->moveTo($offset); + + return $token; + } + + /** + * Retreat the pointer and return the previous token, ignoring all ignorable tokens. + * + * @note + * This is the same as calling `moveToPrevious` followed by `getCurrent`. + * + * @param $kind + * Keep moving until it reaches a token matching $kind. + * + * @param $stopAt + * When defining $kind, this will define a different stop point rather than EOF. + * + * @return + * Returns a `T_NULL` token on failure. + */ + public function getPrevious(int|string|array|null $kind = null, int|string|array $stopAt = "\0"): PhpToken { + if ($this->moveToPrevious($kind, $stopAt)) { + return $this->getCurrent(); + } + + return static::$T_NULL; + } + + /** + * Only retreat the pointer and return the previous token if it matches. + * + * This is the same as calling `getPrevious`, only it will only retreat and + * return the token if it matches $kind. This is equal to combining + * `peakPrevious` with `getPrevious`. + * + * @param $kind + * Match to compare + * + * @return + * Returns a `T_NULL` token on mismatch. + */ + public function getPreviousIf(int|string|array $kind): PhpToken { + if ($this->peakPrevious()->is($kind)) { + return $this->getPrevious(); + } + + return static::$T_NULL; + } + + /** + * Only retreat the pointer and return the previous token if it does not match. + * + * This is the same as calling `getPrevious`, only it will only retreat and + * return the token if it's a mismatch with $kind. + * + * @param $kind + * Match to compare + * + * @return + * Returns a `T_NULL` token on match. + */ + public function getPreviousUnless(int|string|array $kind): PhpToken { + if (!$this->peakPrevious()->is($kind)) { + return $this->getPrevious(); + } + + return static::$T_NULL; + } + + /** + * Return the previous token without retreating the pointer, ignoring all ignorable tokens. + * + * @param $kind + * Keep moving until it reaches a token matching $kind. + * + * @param $stopAt + * When defining $kind, this will define a different stop point rather than EOF. + * + * @return + * Returns a `T_NULL` token on failure. + */ + public function peakPrevious(int|string|array|null $kind = null, int|string|array $stopAt = "\0"): PhpToken { + $token = static::$T_NULL; + $offset = $this->getOffset(); + + if ($this->moveToPrevious($kind, $stopAt)) { + $token = $this->getCurrent(); + } + + $this->moveTo($offset); + + return $token; + } + + /** + * Get the current pointer offset + */ + public function getOffset(): int { + return $this->offset; + } +} + +Lexer::__static_construct(); diff --git a/src/debug/entities/Argument.php b/src/debug/entities/Argument.php new file mode 100755 index 0000000..7609659 --- /dev/null +++ b/src/debug/entities/Argument.php @@ -0,0 +1,121 @@ +getName(); + } + + /** + * Get the argument name + */ + public function getName(): string { + return $this->name; + } + + /** + * Get the argument type + */ + public function getType(): Type { + return $this->type; + } + + /** + * Whether this is a nullable argument + */ + public function isNullable(): bool { + if ($this->type instanceof UnionType) { + return $this->type->hasNativeNull(); + } + + return false; + } + + /** + * Whether this is an optional argument + * + * An optional argument is one that provides a default value + */ + public function isOptional(): bool { + return ($this->flags & T_OPTIONAL) > 0; + } + + /** + * Whether this argument is passed by reference + */ + public function isByRef(): bool { + return ($this->flags & T_BYREF) > 0; + } + + /** + * Whether this is a variable length argument + */ + public function isVariadic(): bool { + return ($this->flags & T_VARIADIC) > 0; + } +} diff --git a/src/debug/entities/Clazz.php b/src/debug/entities/Clazz.php new file mode 100755 index 0000000..33644dd --- /dev/null +++ b/src/debug/entities/Clazz.php @@ -0,0 +1,316 @@ + Name::class, 'label' => Name::class, ...] + + /** @ignore */ + protected array $properties = []; // ['name' => Property::class, ...] + + /** @ignore */ + protected array $methods = []; // ['name' => Routine::class, ...] + + /** + * Construct a new Class + * + * @param $name + * The name of the clas + * + * @param $flags + * Class flags + * + * @param $extends + * A parent class name + * + * @param $implements + * An array of interface names being used by this class + */ + public function __construct( + /** @ignore */ + protected Name $name, + + /** @ignore */ + protected int $flags = Clazz::T_CLASS, + + /** @ignore */ + protected Name|null $extends = null, + + /** @ignore */ + protected array $implements = [] + + ) {} + + /** + * @ignore + * @php + */ + public function __toString(): string { + return (string) $this->getName(); + } + + /** + * Whether this class is anonymous + */ + public function isAnonymous(): bool { + return ($this->flags & static::T_ANONYMOUS) == static::T_ANONYMOUS; + } + + /** + * Whether this class is final + */ + public function isFinal(): bool { + return ($this->flags & static::T_FINAL) == static::T_FINAL; + } + + /** + * Whether this class is abstract + */ + public function isAbstract(): bool { + return ($this->flags & static::T_ABSTRACT) == static::T_ABSTRACT; + } + + /** + * Whether this class is a trait class + */ + public function isTrait(): bool { + return ($this->flags & static::T_TRAIT) == static::T_TRAIT; + } + + /** + * Whether this class is an interface + */ + public function isInterface(): bool { + return ($this->flags & static::T_INTERFACE) == static::T_INTERFACE; + } + + /** + * Whether this class is an enum class + */ + public function isEnum(): bool { + return ($this->flags & static::T_ENUM) == static::T_ENUM; + } + + /** + * Get the class name + */ + public function getName(): Name { + return $this->name; + } + + /** + * Get the parent class name + */ + public function getExtends(): Name|null { + return $this->extends; + } + + /** + * Get a specified interface name + * + * @param $label + * Name of the interface to return + */ + public function getImplement(string $label): Name|null { + foreach ($this->implements as $impl) { + if ($label == $impl->getName()) { + return $impl; + } + } + + return null; + } + + /** + * Return all interface names used by this class + */ + public function getImplements(): array { + return $this->implements; + } + + /** + * Add a trait name to this class + * + * @note + * Trying to add an already existing trait will result in an exception + * + * @param $name + * A trait name to add + */ + public function addTrait(Name $name): void { + $label = $name->getLabel(); + + if (!isset($this->traits[$label])) { + $this->traits[$label] = $name; + + } else { + throw new Exception("Trying to re-add trait " . $name); + } + } + + /** + * Get a specified trait name + * + * @param $label + * Name of the trait to return + */ + public function getTrait(string $label): ?Name { + return $this->traits[$label] ?? null; + } + + /** + * Return all trait names used by this class + */ + public function getTraits(): array { + return $this->traits; + } + + /** + * Add a property to this class + * + * @note + * Trying to add an already existing property will result in an exception + * + * @param $prop + * A property to add + */ + public function addProperty(Property $prop): void { + $name = (string) $prop->getName(); + + if (!isset($this->properties[$name])) { + $this->properties[$name] = $prop; + + } else { + throw new Exception("Trying to re-add property " . $prop); + } + } + + /** + * Get a specified property + * + * @param $name + * Name of the property to return + */ + public function getProperty(string $name): ?Property { + return $this->properties[$name] ?? null; + } + + /** + * Return all properties within by this class + */ + public function getProperties(): array { + return $this->properties; + } + + /** + * Add a method to this class + * + * @note + * Trying to add an already existing method will result in an exception + * + * @param $func + * A method to add + */ + public function addMethod(Routine $func): void { + $name = (string) $func->getName(); + + if (!isset($this->methods[$name])) { + $this->methods[$name] = $func; + + } else { + throw new Exception("Trying to re-add routine " . $func); + } + } + + /** + * Get a specified method + * + * @param $name + * Name of the method to return + */ + public function getMethod(string $name): ?Routine { + return $this->methods[$name] ?? null; + } + + /** + * Return all methods within by this class + */ + public function getMethods(): array { + return $this->methods; + } + + /** + * Provides a Traversable to iterate through all members + */ + public function getIterator(): Traversable { // yield Member::class + foreach (["properties", "methods"] as $type) { + foreach ($this->$type as $name => $member) { + if (!$member->isAnonymous()) { + yield $name => $member; + } + } + } + } +} diff --git a/src/debug/entities/Document.php b/src/debug/entities/Document.php new file mode 100755 index 0000000..410888c --- /dev/null +++ b/src/debug/entities/Document.php @@ -0,0 +1,117 @@ +type = match ($type) { + "const" => 2, + "function" => 1, + + default => 0 + }; + } + + /** + * Get the import type + */ + public function getType(): string { + return match ($this->type) { + 0 => "class", + 1 => "function", + 2 => "const" + }; + } +} diff --git a/src/debug/entities/IntersectType.php b/src/debug/entities/IntersectType.php new file mode 100755 index 0000000..b136f6d --- /dev/null +++ b/src/debug/entities/IntersectType.php @@ -0,0 +1,68 @@ +getName(); + + if ($type->isNative()) { + throw new Exception("Cannot use native types in intersection"); + } + } + + if (count($names) == 0) { + throw new Exception("You must declare at least one type"); + } + + $this->name = implode("&", $names); + $this->types = $types; + } + + /** + * Provides a Traversable to iterate through the types within + */ + public function getIterator(): Traversable { // yield Type::class + foreach ($this->types as $type) { + yield $type; + } + } +} diff --git a/src/debug/entities/Member.php b/src/debug/entities/Member.php new file mode 100755 index 0000000..ca5d2f5 --- /dev/null +++ b/src/debug/entities/Member.php @@ -0,0 +1,140 @@ +getName(); + } + + /** + * Get the type of this member + */ + public function getType(): Type { + return $this->type; + } + + /** + * Get the name of this member + */ + public function getName(): Name { + return $this->name; + } + + /** + * Whether this member is public + */ + public function isPublic(): bool { + return ($this->flags & Member::T_PUBLIC) == Member::T_PUBLIC; + } + + /** + * Whether this member is protected + */ + public function isProtected(): bool { + return ($this->flags & Member::T_PROTECTED) == Member::T_PROTECTED; + } + + /** + * Whether this member is private + */ + public function isPrivate(): bool { + return ($this->flags & Member::T_PRIVATE) == Member::T_PRIVATE; + } + + /** + * Whether this member is static + */ + public function isStatic(): bool { + return ($this->flags & Member::T_STATIC) == Member::T_STATIC; + } + + /** + * Whether this member is final + */ + public function isFinal(): bool { + return ($this->flags & Member::T_FINAL) == Member::T_FINAL; + } +} diff --git a/src/debug/entities/Name.php b/src/debug/entities/Name.php new file mode 100755 index 0000000..0443c4b --- /dev/null +++ b/src/debug/entities/Name.php @@ -0,0 +1,100 @@ +namespace = substr($path, 0, $pos); + $this->name = substr($path, $pos+1); + + } else { + $this->name = $path; + } + + $this->alias = $alias; + } + + /** + * Get the label for this name + * + * This returns a basename without any namespace part. + * If an alias is defined, this is what get's returned. + * Otherwise it will return the name, with namespace stripped. + */ + public function getLabel(): string { + return $this->alias != null ? + $this->alias : $this->name; + } + + /** + * Get the string representation of this name path + * + * This will always return the complete named path + * with any namespace. + */ + public function getName(): string { + if ($this->namespace != null) { + return "{$this->namespace}\\{$this->name}"; + } + + return $this->name; + } + + /** + * Get the namespace of this name path + */ + public function getNamespace(): string|null { + return $this->namespace; + } + + /** + * @ignore + * @php + */ + public function __toString(): string { + return $this->getName(); + } +} diff --git a/src/debug/entities/Property.php b/src/debug/entities/Property.php new file mode 100755 index 0000000..34bba28 --- /dev/null +++ b/src/debug/entities/Property.php @@ -0,0 +1,54 @@ +flags & Property::T_READONLY) == Property::T_READONLY; + } + + /** + * Whether this member is an enum case + */ + public function isEnumCase(): bool { + return ($this->flags & Property::T_CASE) == Property::T_CASE; + } +} diff --git a/src/debug/entities/Routine.php b/src/debug/entities/Routine.php new file mode 100755 index 0000000..d19f2f1 --- /dev/null +++ b/src/debug/entities/Routine.php @@ -0,0 +1,177 @@ + Argument::class, ...] + + /** @ignore */ + protected array $classes = []; // ['name' => Clazz::class, ...] + + /** @ignore */ + protected array $routines = []; // ['name' => Routine::class, ...] + + /** @ignore */ + protected int $flags = 0; + + /** + * Construct a new Routine + * + * @param $name + * The name of the routine + * + * @param $type + * The routine return type + * + * @param $flags + * Routine flags + * + * @param $params + * Routine parameters + */ + public function __construct(Name $name, Type $type, int $flags = Member::T_PUBLIC, array $params = []) { + parent::__construct($name, $type, $flags); + + foreach ($params as $param) { + if ($param instanceof Argument) { + $this->params[$param->getName()] = $param; + + } else { + throw new Exception("The params parameter must be populated with instances of ". Argument::class); + } + } + } + + /** + * Whether this routine returns by reference + */ + public function isByRef(): bool { + return ($this->flags & Routine::T_BYREF) == Routine::T_BYREF; + } + + /** + * Whether this member is abstract + */ + public function isAbstract(): bool { + return ($this->flags & Routine::T_ABSTRACT) == Routine::T_ABSTRACT; + } + + /** + * Whether this member is anonymous + */ + public function isAnonymous(): bool { + return ($this->flags & Routine::T_ANONYMOUS) == Routine::T_ANONYMOUS; + } + + /** + * Get a specified argument + * + * @param $name + * Name of the argument + */ + public function getArgument(string $name): ?Argument { + return $this->params[$name] ?? null; + } + + /** + * Provides a Traversable to iterate through all arguments + */ + public function getIterator(): Traversable { // yield Argument::class + foreach ($this->arguments as $name => $param) { + yield $name => $param; + } + } + + /** + * Add an anonymous class + * + * @param $class + * The class to add + */ + public function addClass(Clazz $class): void { + $label = $class->getName()->getLabel(); + + if (!isset($this->classes[$label])) { + $this->classes[$label] = $class; + + } else { + throw new Exception("Trying to re-add inner class " . $class->getName()); + } + } + + /** + * Return all of the anonymous classes within this routine + */ + public function getClasses(): array { + return $this->classes; + } + + /** + * Add a closure + * + * @param $func + * The closure to add + */ + public function addFunction(Routine $func): void { + $label = $func->getName()->getLabel(); + + if (!isset($this->routines[$label])) { + $this->routines[$label] = $func; + + } else { + throw new Exception("Trying to re-add function " . $func->getName()); + } + } + + /** + * Return all of the closures within this routine + */ + public function getFunctions(): array { + return $this->routines; + } +} diff --git a/src/debug/entities/Type.php b/src/debug/entities/Type.php new file mode 100755 index 0000000..a07dab7 --- /dev/null +++ b/src/debug/entities/Type.php @@ -0,0 +1,59 @@ +native; + } +} diff --git a/src/debug/entities/UnionType.php b/src/debug/entities/UnionType.php new file mode 100755 index 0000000..f0c02ab --- /dev/null +++ b/src/debug/entities/UnionType.php @@ -0,0 +1,102 @@ +getName(); + + if (!$type->isNative()) { + $isNative = false; + + } else { + $this->natives[] = $type->getName(); + } + } + + if (count($names) == 0) { + throw new Exception("You must declare at least one type"); + } + + $this->name = implode("|", $names); + $this->native = $isNative; + $this->types = $types; + } + + /** + * Check to see if a specific or any native types exists + * within this union + * + * @param $type + * Optional native type to check for. + * If this is not provided, any native type will return `TRUE` + */ + public function hasNative(string|null $type = null): bool { + if ($type == null) { + return count($this->natives) > 0; + } + + return in_array($type, $this->natives); + } + + /** + * Check to see if this union is nullable + * + * @note + * This is the same as `hasNative("null")` + */ + public function hasNativeNull(): bool { + return $this->hasNative("null"); + } + + /** + * Provides a Traversable to iterate through the types within + */ + public function getIterator(): Traversable { // yield Type::class + foreach ($this->types as $type) { + yield $type; + } + } +} diff --git a/tests/src/LexerTest.php b/tests/src/LexerTest.php new file mode 100755 index 0000000..abbd885 --- /dev/null +++ b/tests/src/LexerTest.php @@ -0,0 +1,131 @@ +prop; + } + + private obj1&obj2 \$prop; + } + + ", true); + + $this->assertTrue( + $lexer->getNext()->is(T_NAMESPACE) && $lexer->getNext()->is(T_STRING) + ); + + $this->assertEquals( + "lib\\utils", + (string) $lexer->getCurrent() + ); + + $this->assertTrue( + $lexer->moveToNext(T_CLASSDEF) + ); + + $this->assertFalse( + $lexer->moveToNext(T_ELLIPSIS, T_PROPERTY) + ); + + $this->assertEquals( + "\0", + (string) $lexer->getNext(T_ELLIPSIS, T_PROPERTY) + ); + + $this->assertEquals( + "MyClass", + (string) $lexer->getNext() + ); + + $this->assertTrue( + $lexer->moveToNext(T_TYPEDEF) + ); + + $this->assertEquals( + "?int", + (string) $lexer->getCurrent() + ); + + $this->assertTrue( + $lexer->getNext()->is(T_PROPERTY) + ); + + $this->assertEquals( + "prop", + (string) $lexer->getCurrent() + ); + + $this->assertTrue( + $lexer->moveToNext(T_ELLIPSIS) && ($token = $lexer->peakPrevious())->is("&") + ); + + $this->assertEquals( + "&", + $token->getTokenName() + ); + + $this->assertTrue( + $lexer->moveToNext(":") && $lexer->peakNext()->is(T_TYPEDEF) + ); + + $this->assertFalse( + $lexer->moveToPrevious(T_CLASSDEF, T_PROPERTY) + ); + + $this->assertEquals( + "\0", + (string) $lexer->getPrevious(T_CLASSDEF, T_PROPERTY) + ); + + $this->assertEquals( + "int|null", + (string) $lexer->getNextIf(T_TYPEDEF) + ); + + $this->assertTrue( + $lexer->moveToNext(T_PRIVATE) && $lexer->getNext()->is(T_TYPEDEF) + ); + + $this->assertEquals( + "obj1&obj2", + (string) $lexer->getCurrent() + ); + } +}