You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here is the same example in an object-oriented way, where the async method must be prefixed with the <code>async_</code> keyword, and the class that has the async method must use the <code>DevNet\System\Tweak</code> trait to enable this feature.
114
+
Here is the same example in an object-oriented way, where the async method must be prefixed with the <code>async_</code> keyword, and the class that has the async method must use the trait <code>DevNet\System\MethodTrait</code> to enable this feature.
115
115
</p>
116
116
<pre><codeclass="language-php"><?php
117
117
118
118
use DevNet\System\IO\FileStream;
119
-
use DevNet\System\Tweak;
119
+
use DevNet\System\MethodTrait;
120
120
121
121
use function DevNet\System\await;
122
122
123
123
class Reader {
124
124
125
-
use Tweak;
125
+
use MethodTrait;
126
126
127
127
public async_readJsonAsync(function($path): string
Copy file name to clipboardExpand all lines: src/app/core/extension/extension.component.html
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -12,17 +12,17 @@ <h1>Extension Methods</h1>
12
12
</p>
13
13
<h3>Extended class</h3>
14
14
<p>
15
-
The extended class is the class that the extension method operates on, and must include the trait <code>DevNet\System\Tweak</code> to enable this feature like in the following code example:
15
+
The extended class is the class that the extension method operates on, and must include the trait <code>DevNet\System\MethodTrait</code> to enable this feature like in the following code example:
16
16
</p>
17
17
<pre><codeclass="language-php"><?php
18
18
19
19
namespace Application\Models;
20
20
21
-
use DevNet\System\Tweak;
21
+
use DevNet\System\MethodTrait;
22
22
23
23
class Employee
24
24
{
25
-
use Tweak;
25
+
use MethodTrait;
26
26
27
27
public string $Name;
28
28
public float $Salary ;
@@ -73,7 +73,7 @@ <h3>Calling the extension method</h3>
73
73
</p>
74
74
<br>
75
75
<blockquoteclass="alert alert-info">
76
-
<b>Note:</b> One of the best examples of extension methods is the <b>LINQ</b> methods that allow to perform queries on collections of type <code>IEnumerable</code>, More details about this feature can be found in the <arouterLink="/docs/core/linq">LINQ</a> section.
76
+
<b>Note:</b> One of the best examples of extension methods is the <b>LINQ</b> methods that allow to perform queries on collections of type <code>IEnumerable</code>, More details about this feature in the upcoming section.
Copy file name to clipboardExpand all lines: src/app/core/generics/generics.component.html
+8-8Lines changed: 8 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ <h3>Generic type parameter</h3>
19
19
To define a type parameter in a generic class, define a type that inherits from <code>DevNet\System\Parameter</code> and attribute that type parameter to that generic class using the <code>DevNet\System\Generic</code> attribute, then set the generic type arguments through the constructor injection.
20
20
</p>
21
21
<p>
22
-
To work with this feature, you need to include the <code>DevNet\System\Tweak</code> trait in your generic class and the method that deals with the generic parameter should be private to trigger a magic method in the background for the type-checking and the injection of the value argument into the parameter type instance that works as a wrapper. Then you can get the argument value by invoking that wrapper as a callable.
22
+
To work with this feature, you need to include the trait <code>DevNet\System\MethodTrait</code> in your generic class and the method that deals with the generic parameter should be private to trigger a magic method in the background for the type-checking and the injection of the value argument into the parameter type instance that works as a wrapper. Then you can get the argument value by invoking that wrapper as a callable.
23
23
</p>
24
24
<p>
25
25
Here is an example explaining how to create a generic class using this feature:
@@ -31,15 +31,15 @@ <h3>Generic type parameter</h3>
31
31
use DevNet\System\Collections\Enumerator;
32
32
use DevNet\System\Collections\IEnumerable;
33
33
use DevNet\System\Generic;
34
-
use DevNet\System\Tweak;
34
+
use DevNet\System\MethodTrait;
35
35
36
36
// Defining the type parameter T as a type of the items in the collection.
37
37
class T extends \Devnet\System\Parameter {}
38
38
39
39
#[Generic(T::class)]
40
40
class Collection implements IEnumerable
41
41
{
42
-
use Tweak;
42
+
use MethodTrait;
43
43
44
44
private array $items = [];
45
45
@@ -78,15 +78,15 @@ <h3>Generic type argument</h3>
78
78
$employee->Name = 'Alice';
79
79
80
80
// Create an instance of type Collection<Employee>
81
-
$collection = new Collection(Employee::class);
81
+
$employees = new Collection(Employee::class);
82
82
83
83
// Now this method accepts only arguments of type Employee, other wise will throw a TypeException.
84
-
$collection->add($employee);
84
+
$employees->add($employee);
85
85
</code></pre>
86
86
<br>
87
87
<h3>Checking generic type</h3>
88
88
<p>
89
-
Every class uses the <code>Tweak</code> has a <code>getType()</code> method that returns a reflection class type. You can use this reflection type to examine the generic type and its type parameters, and you can also use the <code>TypeOf()</code> function to create an instance of a type that represents a generic type that you want use for compare.
89
+
Every class uses the <code>MethodTrait</code> has a <code>getType()</code> method that returns a reflection class type. You can use this reflection type to examine the generic type and its type parameters, and you can also use the <code>TypeOf()</code> function to create an instance of a type that represents a generic type that you want use for compare.
90
90
</p>
91
91
<pre><codeclass="language-php"><?php
92
92
@@ -129,15 +129,15 @@ <h3>Multiple type parameters</h3>
LINQ, or Language Integrated Query, is an integration of query capabilities as expressions of extension methods against data, such as in-memory data, document databases, or SQL databases.
12
12
</p>
13
13
<p>
14
-
Any collection class of type <code>IEnumerable</code> or <code>IQueryable</code> that uses the <code>DevNet\System\Extension\Tweak</code> to support the extension method can take advantage of using LINQ extension methods.
14
+
Any collection class of type <code>IEnumerable</code> or <code>IQueryable</code> that uses the <code>DevNet\System\MethodTrait</code> to support the extension method can take advantage of using LINQ extension methods.
15
15
</p>
16
16
<p>
17
17
The difference between <code>IEnumerable</code> and <code>IQueryable</code> types is that the implementation of the <code>IEnumerable</code> type, like the <code>ArrayList</code>, uses LINQ against in-memory data, while the implementation of the <code>IQueryable</code> type, like the <code>EntitySet</code> repository of DevNet Entity ORM, uses LINQ against SQL database, which means that this one uses <code>IQueryProvider</code> to compile the predicate expressions of the LINQ methods to SQL query syntax.
Copy file name to clipboardExpand all lines: src/app/core/overview/overview.component.html
+7-7Lines changed: 7 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -11,13 +11,13 @@ <h1>Overview</h1>
11
11
DevNet Core is the heart of the DevNet framework, and all of its components rely on it. It is a base class library that provides several fundamental features that make it easier to develop applications in PHP. These features include:
Copy file name to clipboardExpand all lines: src/app/core/properties/properties.component.html
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -15,17 +15,17 @@ <h3>Getter</h3>
15
15
A getter is a function bound to a computed property and returns a value when that property is looked up.
16
16
</p>
17
17
<p>
18
-
To use a getter for a computed property in DevNet, you need first to include the trait <code>DevNet\System\Tweak</code> in your class to enable this feature, then define the computed property as a method prefixed with <code>get</code> that returns a value.
18
+
To use a getter for a computed property in DevNet, you need first to include the trait <code>DevNet\System\PropertyTrait</code> in your class to enable this feature, then define the computed property as a method prefixed with <code>get</code> that returns a value.
<b>Important:</b> The client should send back the JWT token in the Authorization header using the Bearer schema in the following format: <code>Authorization: Bearer <token></code>
0 commit comments