@@ -61,8 +61,10 @@ Where the FqsenResolver can resolve:
6161In order to resolve a type you will have to instantiate the class ` \phpDocumentor\Reflection\TypeResolver `
6262and call its ` resolve ` method like this:
6363
64- $typeResolver = new \phpDocumentor\Reflection\TypeResolver();
65- $type = $typeResolver->resolve('string|integer');
64+ ``` php
65+ $typeResolver = new \phpDocumentor\Reflection\TypeResolver();
66+ $type = $typeResolver->resolve('string|integer');
67+ ```
6668
6769In this example you will receive a Value Object of class ` \phpDocumentor\Reflection\Types\Compound ` that has two
6870elements, one of type ` \phpDocumentor\Reflection\Types\String_ ` and one of type
@@ -77,8 +79,10 @@ in which namespace the given expression occurs and which namespace aliases (or i
7779A Fully Qualified Structural Element Name is a reference to another element in your code bases and can be resolved using
7880the ` \phpDocumentor\Reflection\FqsenResolver ` class' ` resolve ` method, like this:
7981
80- $fqsenResolver = new \phpDocumentor\Reflection\FqsenResolver();
81- $fqsen = $fqsenResolver->resolve('\phpDocumentor\Reflection\FqsenResolver::resolve()');
82+ ``` php
83+ $fqsenResolver = new \phpDocumentor\Reflection\FqsenResolver();
84+ $fqsen = $fqsenResolver->resolve('\phpDocumentor\Reflection\FqsenResolver::resolve()');
85+ ```
8286
8387In this example we resolve a Fully Qualified Structural Element Name (meaning that it includes the full namespace, class
8488name and element name) and receive a Value Object of type ` \phpDocumentor\Reflection\Fqsen ` .
9599For example, you have this file:
96100
97101``` php
98- <?php
99102namespace My\Example;
100103
101104use phpDocumentor\Reflection\Types;
@@ -121,22 +124,28 @@ play.
121124
122125You can do this by manually creating a Context like this:
123126
124- $context = new \phpDocumentor\Reflection\Types\Context(
125- '\My\Example',
126- [ 'Types' => '\phpDocumentor\Reflection\Types']
127- );
127+ ``` php
128+ $context = new \phpDocumentor\Reflection\Types\Context(
129+ '\My\Example',
130+ [ 'Types' => '\phpDocumentor\Reflection\Types']
131+ );
132+ ```
128133
129134Or by using the ` \phpDocumentor\Reflection\Types\ContextFactory ` to instantiate a new context based on a Reflector
130135object or by providing the namespace that you'd like to extract and the source code of the file in which the given
131136type expression occurs.
132137
133- $contextFactory = new \phpDocumentor\Reflection\Types\ContextFactory();
134- $context = $contextFactory->createFromReflector(new ReflectionMethod('\My\Example\Classy', '__construct'));
138+ ``` php
139+ $contextFactory = new \phpDocumentor\Reflection\Types\ContextFactory();
140+ $context = $contextFactory->createFromReflector(new ReflectionMethod('\My\Example\Classy', '__construct'));
141+ ```
135142
136143or
137144
138- $contextFactory = new \phpDocumentor\Reflection\Types\ContextFactory();
139- $context = $contextFactory->createForNamespace('\My\Example', file_get_contents('My/Example/Classy.php'));
145+ ``` php
146+ $contextFactory = new \phpDocumentor\Reflection\Types\ContextFactory();
147+ $context = $contextFactory->createForNamespace('\My\Example', file_get_contents('My/Example/Classy.php'));
148+ ```
140149
141150### Using the Context
142151
@@ -145,8 +154,10 @@ class as second argument and the Resolvers will take this into account when reso
145154
146155To obtain the resolved class name for the ` @var ` tag in the example above you can do:
147156
148- $typeResolver = new \phpDocumentor\Reflection\TypeResolver();
149- $type = $typeResolver->resolve('Types\Context', $context);
157+ ``` php
158+ $typeResolver = new \phpDocumentor\Reflection\TypeResolver();
159+ $type = $typeResolver->resolve('Types\Context', $context);
160+ ```
150161
151162When you do this you will receive an object of class ` \phpDocumentor\Reflection\Types\Object_ ` for which you can call
152163the ` getFqsen ` method to receive a Value Object that represents the complete FQSEN. So that would be
@@ -161,8 +172,10 @@ the `getFqsen` method to receive a Value Object that represents the complete FQS
161172Another example is on how to resolve the FQSEN of a method as can be seen with the ` @see ` tag in the example above. To
162173resolve that you can do the following:
163174
164- $fqsenResolver = new \phpDocumentor\Reflection\FqsenResolver();
165- $type = $fqsenResolver->resolve('Classy::otherFunction()', $context);
175+ ``` php
176+ $fqsenResolver = new \phpDocumentor\Reflection\FqsenResolver();
177+ $type = $fqsenResolver->resolve('Classy::otherFunction()', $context);
178+ ```
166179
167180Because Classy is a Class in the current namespace its FQSEN will have the ` My\Example ` namespace and by calling the
168181` resolve ` method of the FQSEN Resolver you will receive an ` Fqsen ` object that refers to
0 commit comments