Skip to content

Commit

Permalink
Doc: IsClassProperty moved to new, class-oriented format
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartherbert committed Jun 10, 2017
1 parent 8f579e2 commit 3de28d2
Show file tree
Hide file tree
Showing 34 changed files with 814 additions and 2 deletions.
@@ -0,0 +1,27 @@
<?php

require_once 'vendor/autoload.php';
require_once __DIR__ . '/ExampleClass.inc.php';

// --- TARGET START ---
// defaults
// --- TARGET STOP ---
// --- PREAMBLE START ---
// This example shows you how to check if a property is a class property.
// --- PREAMBLE STOP ---

// --- EXAMPLE START ---
use GanbaroDigital\MissingBits\ClassesAndObjects\IsClassProperty;

$checker = new IsClassProperty;

// here, $refProp reflects a static property
$refClass = new ReflectionClass(ExampleClass::class);
$refProp = $refClass->getProperty('value1');
var_dump($checker->inspect($refProp));

// here, $refProp reflects an object's property
$target = new ExampleClass;
$refObj = new ReflectionObject($target);
$refProp = $refObj->getProperty('value2');
var_dump($checker->inspect($refProp));
7 changes: 7 additions & 0 deletions doc-examples/IsClassProperty/__construct/ExampleClass.inc.php
@@ -0,0 +1,7 @@
<?php

class ExampleClass
{
public static $value1 = "I am public static value1";
public $value2 = "I am public value2";
}
@@ -0,0 +1,25 @@
<?php

require_once 'vendor/autoload.php';
require_once __DIR__ . '/ExampleClass.inc.php';

// --- TARGET START ---
// defaults
// --- TARGET STOP ---
// --- PREAMBLE START ---
// This example shows you how to check if a property is a class property
// --- PREAMBLE STOP ---

// --- EXAMPLE START ---
use GanbaroDigital\MissingBits\ClassesAndObjects\IsClassProperty;

// here, $refProp reflects a static property
$refClass = new ReflectionClass(ExampleClass::class);
$refProp = $refClass->getProperty('value1');
var_dump(IsClassProperty::check($refProp));

// here, $refProp reflects an object's property
$target = new ExampleClass;
$refObj = new ReflectionObject($target);
$refProp = $refObj->getProperty('value2');
var_dump(IsClassProperty::check($refProp));
7 changes: 7 additions & 0 deletions doc-examples/IsClassProperty/check/ExampleClass.inc.php
@@ -0,0 +1,7 @@
<?php

class ExampleClass
{
public static $value1 = "I am public static value1";
public $value2 = "I am public value2";
}
@@ -0,0 +1,34 @@
<?php

require_once 'vendor/autoload.php';
require_once __DIR__ . '/ExampleClass.inc.php';

// --- TARGET START ---
// defaults
// --- TARGET STOP ---
// --- PREAMBLE START ---
// This example shows you how to check if a list contains only class properties.
// --- PREAMBLE STOP ---

// --- EXAMPLE START ---
use GanbaroDigital\MissingBits\ClassesAndObjects\IsClassProperty;

$refClass = new ReflectionClass(ExampleClass::class);
$refProp1 = $refClass->getProperty('value1');

// here, $refProp reflects an object's property
$target = new ExampleClass;
$refObj = new ReflectionObject($target);
$refProp2 = $refObj->getProperty('value2');

// this list only contains class properties
var_dump(IsClassProperty::checkList([
$refProp1
]));

// this list contains both class properties
// and object properties
var_dump(IsClassProperty::checkList([
$refProp1,
$refProp2
]));
7 changes: 7 additions & 0 deletions doc-examples/IsClassProperty/checkList/ExampleClass.inc.php
@@ -0,0 +1,7 @@
<?php

class ExampleClass
{
public static $value1 = "I am public static value1";
public $value2 = "I am public value2";
}
@@ -0,0 +1,27 @@
<?php

require_once 'vendor/autoload.php';
require_once __DIR__ . '/ExampleClass.inc.php';

// --- TARGET START ---
// defaults
// --- TARGET STOP ---
// --- PREAMBLE START ---
// This example shows you how to check if a property is a class property.
// --- PREAMBLE STOP ---

// --- EXAMPLE START ---
use GanbaroDigital\MissingBits\ClassesAndObjects\IsClassProperty;

$checker = new IsClassProperty;

// here, $refProp reflects a static property
$refClass = new ReflectionClass(ExampleClass::class);
$refProp = $refClass->getProperty('value1');
var_dump($checker->inspect($refProp));

// here, $refProp reflects an object's property
$target = new ExampleClass;
$refObj = new ReflectionObject($target);
$refProp = $refObj->getProperty('value2');
var_dump($checker->inspect($refProp));
7 changes: 7 additions & 0 deletions doc-examples/IsClassProperty/inspect/ExampleClass.inc.php
@@ -0,0 +1,7 @@
<?php

class ExampleClass
{
public static $value1 = "I am public static value1";
public $value2 = "I am public value2";
}
@@ -0,0 +1,36 @@
<?php

require_once 'vendor/autoload.php';
require_once __DIR__ . '/ExampleClass.inc.php';

// --- TARGET START ---
// defaults
// --- TARGET STOP ---
// --- PREAMBLE START ---
// This example shows you how to check if a list contains only class properties.
// --- PREAMBLE STOP ---

// --- EXAMPLE START ---
use GanbaroDigital\MissingBits\ClassesAndObjects\IsClassProperty;

$checker = new IsClassProperty;

$refClass = new ReflectionClass(ExampleClass::class);
$refProp1 = $refClass->getProperty('value1');

// here, $refProp reflects an object's property
$target = new ExampleClass;
$refObj = new ReflectionObject($target);
$refProp2 = $refObj->getProperty('value2');

// this list only contains class properties
var_dump($checker->inspectList([
$refProp1
]));

// this list contains both class properties
// and object properties
var_dump($checker->inspectList([
$refProp1,
$refProp2
]));
7 changes: 7 additions & 0 deletions doc-examples/IsClassProperty/inspectList/ExampleClass.inc.php
@@ -0,0 +1,7 @@
<?php

class ExampleClass
{
public static $value1 = "I am public static value1";
public $value2 = "I am public value2";
}
@@ -0,0 +1,25 @@
<?php

require_once 'vendor/autoload.php';
require_once __DIR__ . '/ExampleClass.inc.php';

// --- TARGET START ---
// defaults
// --- TARGET STOP ---
// --- PREAMBLE START ---
// This example shows you how to use the shorthand notation, to avoid creating a variable for the checker.
// --- PREAMBLE STOP ---

// --- EXAMPLE START ---
use GanbaroDigital\MissingBits\ClassesAndObjects\IsClassProperty;

// here, $refProp reflects a static property
$refClass = new ReflectionClass(ExampleClass::class);
$refProp = $refClass->getProperty('value1');
var_dump(IsClassProperty::using()->inspect($refProp));

// here, $refProp reflects an object's property
$target = new ExampleClass;
$refObj = new ReflectionObject($target);
$refProp = $refObj->getProperty('value2');
var_dump(IsClassProperty::using()->inspect($refProp));
7 changes: 7 additions & 0 deletions doc-examples/IsClassProperty/using/ExampleClass.inc.php
@@ -0,0 +1,7 @@
<?php

class ExampleClass
{
public static $value1 = "I am public static value1";
public $value2 = "I am public value2";
}
@@ -1,3 +1,3 @@
<div class="code-metrics">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="90" height="20"><g shape-rendering="crispEdges"><path fill="#555" d="M0 0h59v20H0z"/><path fill="#4c1" d="M59 0h31v20H59z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="29.5" y="14">coverage</text><text x="73.5" y="14">100</text></g></svg>&nbsp;<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="86" height="20"><g shape-rendering="crispEdges"><path fill="#555" d="M0 0h69v20H0z"/><path fill="#4c1" d="M69 0h17v20H69z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="34.5" y="14">complexity</text><text x="76.5" y="14">1</text></g></svg>&nbsp;<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="56" height="20"><g shape-rendering="crispEdges"><path fill="#555" d="M0 0h39v20H0z"/><path fill="#4c1" d="M39 0h17v20H39z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="19.5" y="14">CRAP</text><text x="46.5" y="14">1</text></g></svg>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100" height="20"><g shape-rendering="crispEdges"><path fill="#555" d="M0 0h59v20H0z"/><path fill="#dfb317" d="M59 0h41v20H59z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="29.5" y="14">coverage</text><text x="78.5" y="14">66.67</text></g></svg>&nbsp;<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="86" height="20"><g shape-rendering="crispEdges"><path fill="#555" d="M0 0h69v20H0z"/><path fill="#4c1" d="M69 0h17v20H69z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="34.5" y="14">complexity</text><text x="76.5" y="14">2</text></g></svg>&nbsp;<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="56" height="20"><g shape-rendering="crispEdges"><path fill="#555" d="M0 0h39v20H0z"/><path fill="#4c1" d="M39 0h17v20H39z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="19.5" y="14">CRAP</text><text x="46.5" y="14">2</text></g></svg>
</div>
@@ -0,0 +1,3 @@
<div class="code-metrics">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="76" height="20"><g shape-rendering="crispEdges"><path fill="#555" d="M0 0h59v20H0z"/><path fill="#e05d44" d="M59 0h17v20H59z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="29.5" y="14">coverage</text><text x="66.5" y="14">0</text></g></svg>&nbsp;<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="86" height="20"><g shape-rendering="crispEdges"><path fill="#555" d="M0 0h69v20H0z"/><path fill="#4c1" d="M69 0h17v20H69z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="34.5" y="14">complexity</text><text x="76.5" y="14">1</text></g></svg>&nbsp;<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="56" height="20"><g shape-rendering="crispEdges"><path fill="#555" d="M0 0h39v20H0z"/><path fill="#4c1" d="M39 0h17v20H39z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="19.5" y="14">CRAP</text><text x="46.5" y="14">2</text></g></svg>
</div>
@@ -0,0 +1,26 @@
### Example 1: Check For Class Property

This example shows you how to check if a property is a class property.

```php
use GanbaroDigital\MissingBits\ClassesAndObjects\IsClassProperty;

$checker = new IsClassProperty;

// here, $refProp reflects a static property
$refClass = new ReflectionClass(ExampleClass::class);
$refProp = $refClass->getProperty('value1');
var_dump($checker->inspect($refProp));

// here, $refProp reflects an object's property
$target = new ExampleClass;
$refObj = new ReflectionObject($target);
$refProp = $refObj->getProperty('value2');
var_dump($checker->inspect($refProp));
```
The code above produces this output on PHP v5.6.30, PHP v7.0.20, PHP v7.1.6:

```
bool(true)
bool(false)
```
@@ -0,0 +1,7 @@
<pre><code class="language-php">
class ExampleClass
{
public static $value1 = "I am public static value1";
public $value2 = "I am public value2";
}
</code></pre>
@@ -0,0 +1,24 @@
### Example 1: Check For Class Property

This example shows you how to check if a property is a class property

```php
use GanbaroDigital\MissingBits\ClassesAndObjects\IsClassProperty;

// here, $refProp reflects a static property
$refClass = new ReflectionClass(ExampleClass::class);
$refProp = $refClass->getProperty('value1');
var_dump(IsClassProperty::check($refProp));

// here, $refProp reflects an object's property
$target = new ExampleClass;
$refObj = new ReflectionObject($target);
$refProp = $refObj->getProperty('value2');
var_dump(IsClassProperty::check($refProp));
```
The code above produces this output on PHP v5.6.30, PHP v7.0.20, PHP v7.1.6:

```
bool(true)
bool(false)
```
7 changes: 7 additions & 0 deletions docs/.i/examples/IsClassProperty/check/ExampleClass.inc.twig
@@ -0,0 +1,7 @@
<pre><code class="language-php">
class ExampleClass
{
public static $value1 = "I am public static value1";
public $value2 = "I am public value2";
}
</code></pre>
@@ -0,0 +1,33 @@
### Example 1: Check List For Class Properties

This example shows you how to check if a list contains only class properties.

```php
use GanbaroDigital\MissingBits\ClassesAndObjects\IsClassProperty;

$refClass = new ReflectionClass(ExampleClass::class);
$refProp1 = $refClass->getProperty('value1');

// here, $refProp reflects an object's property
$target = new ExampleClass;
$refObj = new ReflectionObject($target);
$refProp2 = $refObj->getProperty('value2');

// this list only contains class properties
var_dump(IsClassProperty::checkList([
$refProp1
]));

// this list contains both class properties
// and object properties
var_dump(IsClassProperty::checkList([
$refProp1,
$refProp2
]));
```
The code above produces this output on PHP v5.6.30, PHP v7.0.20, PHP v7.1.6:

```
bool(true)
bool(false)
```
@@ -0,0 +1,7 @@
<pre><code class="language-php">
class ExampleClass
{
public static $value1 = "I am public static value1";
public $value2 = "I am public value2";
}
</code></pre>
@@ -0,0 +1,26 @@
### Example 1: Check For Class Property

This example shows you how to check if a property is a class property.

```php
use GanbaroDigital\MissingBits\ClassesAndObjects\IsClassProperty;

$checker = new IsClassProperty;

// here, $refProp reflects a static property
$refClass = new ReflectionClass(ExampleClass::class);
$refProp = $refClass->getProperty('value1');
var_dump($checker->inspect($refProp));

// here, $refProp reflects an object's property
$target = new ExampleClass;
$refObj = new ReflectionObject($target);
$refProp = $refObj->getProperty('value2');
var_dump($checker->inspect($refProp));
```
The code above produces this output on PHP v5.6.30, PHP v7.0.20, PHP v7.1.6:

```
bool(true)
bool(false)
```
@@ -0,0 +1,7 @@
<pre><code class="language-php">
class ExampleClass
{
public static $value1 = "I am public static value1";
public $value2 = "I am public value2";
}
</code></pre>

0 comments on commit 3de28d2

Please sign in to comment.