for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace kujaff\VersionsBundle\Model;
use kujaff\VersionsBundle\Exception\BundleNotFoundException;
trait BundleInformations
{
/**
* Return bundle informations
*
* @param string $name
* @return \Symfony\Component\HttpKernel\Bundle\Bundle
* @throws BundleNotFoundException
*/
protected function getBundleInformations($name)
$bundles = $this->container->get('kernel')->getBundles();
container
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
if (array_key_exists($name, $bundles) === false) {
throw new BundleNotFoundException('Bundle "' . $name . '" not found.');
}
return $bundles[$name];
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: