Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #1

Merged
merged 8 commits into from
Dec 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/ci-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
on:
pull_request:
branches:
- master

name: CI Branch Dev

jobs:
phpunit:
runs-on: ubuntu-latest
container:
image: umutphp/php-docker-images-for-ci:latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install Composer
run: |
apt-get update
apt-get install -y unzip
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php --install-dir=/usr/local/bin --filename=composer
php -r "unlink('composer-setup.php');"
- name: Install composer dependencies
run: |
ls -la
composer install --no-scripts
- name: Run Testsuite
run: |
./vendor/bin/phpunit tests --color
- name: Run PHPstan (Static Analysis Tool)
run: |
vendor/bin/phpstan analyse
3 changes: 0 additions & 3 deletions .idea/codeception.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/php-di.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/phpspec.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
}
],
"require-dev": {
"phpunit/phpunit": "^10.5"
"phpunit/phpunit": "^10.5",
"phpstan/phpstan": "^1.10"
}
}
64 changes: 63 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
parameters:
level: 1
paths:
- src
33 changes: 33 additions & 0 deletions src/Contracts/ContainerContract.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

declare(strict_types=1);

namespace Danu\PhpDi\Contracts;

interface ContainerContract
{
/**
* Finds an entry of the container by its identifier and returns it.
*
* @param string $id Identifier of the entry to look for.
*
* @throws NotFoundExceptionInterface No entry was found for **this** identifier.
* @throws ContainerExceptionInterface Error while retrieving the entry.
*
* @return mixed Entry.
*/
public function get(string $id): mixed;

/**
* Returns true if the container can return an entry for the given identifier.
* Returns false otherwise.
*
* `has($id)` returning true does not mean that `get($id)` will not throw an exception.
* It does however mean that `get($id)` will not throw a `NotFoundExceptionInterface`.
*
* @param string $id Identifier of the entry to look for.
*
* @return bool
*/
public function has(string $id): bool;
}
15 changes: 15 additions & 0 deletions src/Exception/ContainerException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Danu\PhpDi\Exception;

class ContainerException extends InternalException
{
/**
* @param string $id
* @return static
*/
public static function NotFoundContainer(string $id): static
{
return self::make("No entry was found for **this** identifier: {$id}");
}
}
17 changes: 17 additions & 0 deletions src/Exception/InternalException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

namespace Danu\PhpDi\Exception;

class InternalException extends \Exception
{
/**
* @param string $message
* @return static
*/
public static function make(string $message): static
{
return new self($message);
}
}
2 changes: 1 addition & 1 deletion vendor/bin/.phpunit.result.cache
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":1,"defects":[],"times":{"Tests\\ContainerTest::test":0.001}}
{"version":1,"defects":{"Tests\\ContainerTest::test":5},"times":{"Tests\\ContainerTest::test":0.001}}
1 change: 1 addition & 0 deletions vendor/composer/autoload_files.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@

return array(
'6124b4c8570aa390c21fafd04a26c69f' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/deep_copy.php',
'9b38cf48e83f5d8f60375221cd213eee' => $vendorDir . '/phpstan/phpstan/bootstrap.php',
'ec07570ca5a812141189b1fa81503674' => $vendorDir . '/phpunit/phpunit/src/Framework/Assert/Functions.php',
);
1 change: 1 addition & 0 deletions vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class ComposerStaticInitbc181d4bd2112906a6482d7e62dd327f
{
public static $files = array (
'6124b4c8570aa390c21fafd04a26c69f' => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy/deep_copy.php',
'9b38cf48e83f5d8f60375221cd213eee' => __DIR__ . '/..' . '/phpstan/phpstan/bootstrap.php',
'ec07570ca5a812141189b1fa81503674' => __DIR__ . '/..' . '/phpunit/phpunit/src/Framework/Assert/Functions.php',
);

Expand Down
66 changes: 66 additions & 0 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,71 @@
},
"install-path": "../phar-io/version"
},
{
"name": "phpstan/phpstan",
"version": "1.10.48",
"version_normalized": "1.10.48.0",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "087ed4b5f4a7a6e8f3bbdfbfe98ce5c181380bc6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/087ed4b5f4a7a6e8f3bbdfbfe98ce5c181380bc6",
"reference": "087ed4b5f4a7a6e8f3bbdfbfe98ce5c181380bc6",
"shasum": ""
},
"require": {
"php": "^7.2|^8.0"
},
"conflict": {
"phpstan/phpstan-shim": "*"
},
"time": "2023-12-08T14:34:28+00:00",
"bin": [
"phpstan",
"phpstan.phar"
],
"type": "library",
"installation-source": "dist",
"autoload": {
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "PHPStan - PHP Static Analysis Tool",
"keywords": [
"dev",
"static analysis"
],
"support": {
"docs": "https://phpstan.org/user-guide/getting-started",
"forum": "https://github.com/phpstan/phpstan/discussions",
"issues": "https://github.com/phpstan/phpstan/issues",
"security": "https://github.com/phpstan/phpstan/security/policy",
"source": "https://github.com/phpstan/phpstan-src"
},
"funding": [
{
"url": "https://github.com/ondrejmirtes",
"type": "github"
},
{
"url": "https://github.com/phpstan",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan",
"type": "tidelift"
}
],
"install-path": "../phpstan/phpstan"
},
{
"name": "phpunit/php-code-coverage",
"version": "10.1.9",
Expand Down Expand Up @@ -1698,6 +1763,7 @@
"nikic/php-parser",
"phar-io/manifest",
"phar-io/version",
"phpstan/phpstan",
"phpunit/php-code-coverage",
"phpunit/php-file-iterator",
"phpunit/php-invoker",
Expand Down
9 changes: 9 additions & 0 deletions vendor/composer/installed.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@
'aliases' => array(),
'dev_requirement' => true,
),
'phpstan/phpstan' => array(
'pretty_version' => '1.10.48',
'version' => '1.10.48.0',
'reference' => '087ed4b5f4a7a6e8f3bbdfbfe98ce5c181380bc6',
'type' => 'library',
'install_path' => __DIR__ . '/../phpstan/phpstan',
'aliases' => array(),
'dev_requirement' => true,
),
'phpunit/php-code-coverage' => array(
'pretty_version' => '10.1.9',
'version' => '10.1.9.0',
Expand Down
Loading